0x01 调试WIFI/BT
1. 确认几个关键点
rk_linux\kernel\drivers\net\wireless\rockchip_wlan\rkwifi\rk_wifi_config.c
#define VENDOR_ETC_FIRMWARE "/vendor/etc/firmware/" #define SYSTEM_ETC_FIRMWARE "/system/etc/firmware/" if (chip == WIFI_AP6256) { sprintf(fw, "%s%s", ANDROID_FW_PATH, "fw_bcm43456C5_ag.bin"); sprintf(nvram, "%s%s", ANDROID_FW_PATH, "nvram_ap6256.txt"); }
rk_linux/kernel/arch/arm64/boot/dts/rockchip$ vi rkxxxx-wr-lp4-linux.dts
rk_linux/kernel$ vi arch/arm64/configs/rockchip_linux_defconfig
CONFIG_AP6XXX=m
CONFIG_AP6XXX涉及的文件。
rk_linux/kernel$ grep -rn "CONFIG_AP6XXX" drivers/net/wireless/rockchip_wlan/Makefile:2:obj-$(CONFIG_AP6XXX) += rkwifi/ drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/Makefile:119:obj-$(CONFIG_AP6XXX) += bcmdhd.o drivers/net/wireless/rockchip_wlan/rkwifi/Makefile:5:obj-$(CONFIG_AP6XXX) += bcmdhd/ drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c:188:#ifdef CONFIG_AP6XXX
2. 拷贝驱动文件
到external/rkwifibt/firmware/broadcom/AP6256/wifi目录 , 拷贝出fw_bcm43456c5_ag.binWIFI驱动文件 , nvram_ap6256.tx蓝牙驱动文件, 到主板上/vendor/etc/firmware/ 目录 , 没有则新建。
rk_linux/external/rkwifibt/firmware/broadcom/AP6256/wifi$ ls fw_bcm43456c5_ag.bin nvram_ap6256.tx
3. 加载bcmdhd驱动
lsmod //查看当前所有加载的ko insmod bcmdhd.ko //在板子里 敲命令手动加载bcm驱动 rrmod bcmdhd.ko //移除bcm驱动
正常情况下手动加载成功后lsmod会出现bcmdhd, 表示加载成功。
4. 命令行连接WiFi
nmcli device wifi list #查看wifi列表 nmcli dev wifi connect WIFINAME password WIFIPWD #连接wifi
敲完nmcli device wfi list正常情况下会出现wifi列表 , 如果没有出现可能是前面步骤2没有拷贝 , 或者本身模块问题。
5. bcmdhd自动加载的问题
bcmdhd默认m编译出ko文件 , 但是不会拷贝到文件系统里 , 需要通过脚本打包到rootfs里。
其次 如果要自动加载 , 需要通过命令行脚本 在开机启动的时候执行 insmod bcmdhd.ko 。
已尝试过把bcmdhd改成y , wifi 驱动加载不出来。
0x02 调试BT
1.安装蓝牙协议栈
(确保)安装 bluez,该软件包提供蓝牙的协议栈。
linux可以了 , 用的最新wifi/bt固件 , gpio改了 , 然后要执行
apt install bluez
2.调试蓝牙命令
# 蓝牙下电 echo 0 > /sys/class/rfkill/rfkill0/state sleep 1 # 蓝牙上电 echo 1 > /sys/class/rfkill/rfkill0/state sleep 1 # 指定串口 brcm_patchram_plus1 --enable_hci --no2bytes --tosleep 200000 --baudrate 9600 --patchram /system/etc/firmware/BCM4345C5.hcd /dev/ttyS0 & sleep 5 chmod 777 /dev/ttyS0 chmod 777 /dev/ttyS4 sleep 3 # 打开hci0 hciconfig hci0 up 执行: cd /opt 执行: rz > 导入brcm_patchram_plus1文件(这玩意是我编译出来的) 执行: chmod 777 /usr/bin/brcm_patchram_plus1 执行: ./brcm_patchram_plus1 --enable_hci --no2bytes --tosleep 200000 --baudrate 9600 \ --patchram /system/etc/firmware/BCM4345C5.hcd /dev/ttyS0 & ( 必须出现以下打印 ###AMPAK FW Auto detection patch version = [v1.1 20161117]### FW folder path = /system/etc/firmware proc_resetchip id = BCM4345C5 要把system/目录下所有777 需要执行这2行才能看到打印结果 , echo 0 > /sys/class/rfkill/rfkill0/state echo 1 > /sys/class/rfkill/rfkill0/state ) 执行: hciconfig hci0 up(要出现hci0设备,没有则是有问题) 执行: bluetoothctl 进入蓝牙模式后 输入power on 输入scan on 输入discoverable on 输入pair on 输入完以上---可以在手机上看到ubuntu.server的蓝牙 点击这个名字 匹配 , 会提示输入yes/no 输入yes即可连接 输入devices 可以查看附近设备 ---其他命令 sudo systemctl start bluetooth sudo systemctl enable bluetooth bluetoothctl 进入[bluetooth]# 模式 [bluetooth]# help Available commands: list List available controllers show [ctrl] Controller information select <ctrl> Select default controller devices List available devices paired-devices List paired devices power <on/off> Set controller power pairable <on/off> Set controller pairable mode discoverable <on/off> Set controller discoverable mode agent <on/off/capability> Enable/disable agent with given capability default-agent Set agent as the default one set-scan-filter-uuids [uuid1 uuid2 ...] Set scan filter uuids set-scan-filter-rssi [rssi] Set scan filter rssi, and clears pathloss set-scan-filter-pathloss [pathloss] Set scan filter pathloss, and clears rssi set-scan-filter-transport [transport] Set scan filter transport set-scan-filter-clear Clears discovery filter. scan <on/off> Scan for devices info [dev] Device information pair [dev] Pair with device trust [dev] Trust device untrust [dev] Untrust device block [dev] Block device unblock [dev] Unblock device remove <dev> Remove device connect <dev> Connect device disconnect [dev] Disconnect device list-attributes [dev] List attributes select-attribute <attribute> Select attribute attribute-info [attribute] Select attribute read Read attribute value write <data=[xx xx ...]> Write attribute value notify <on/off> Notify attribute value register-profile <UUID ...> Register profile to connect unregister-profile Unregister profile version Display version quit Quit program root@ubuntu:/mnt/usb# systemctl status bluetooth.service ● bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor pre> Active: active (running) since Sun 2023-01-29 07:32:08 UTC; 1h 18min ago Docs: man:bluetoothd(8) Main PID: 436 (bluetoothd) Status: "Running" CGroup: /system.slice/bluetooth.service └─436 /usr/lib/bluetooth/bluetoothd