1、开发平台
CPU:RK3566
编译环境:Ubuntu18.04
内核版本:kernel 4.19
2、目的
因为RK3566/RK3568支持SDIO3.0并且向下兼有SDIO2.0接口,由于核心板在VCC_IO6上将电压定为了3.3V,无法改变为1.8V,所以没有办法支持SDIO3.0,所以这次需要调试SDIO2.0模式下的WiFi。
3、原理图
4、调试分析
从Rockchip软件包中的Rockchip_Developer_Guide_Linux_WIFI_BT_CN.pdf doc操作文档可以得出:WiFi 部分共有两部分供电组成,一个是主控端的IO:SDIO_CLK/CMD/D0~D3,它需要外部供电,如VCCIO6。另一个是WiFi模块的IO的供电,wifi模块中的22引脚,两部分供电必须一致否则会导致WiFi异常;对于支持SDIO3.0 超高速模式的WiFi模块,必须供电1.8V,但对于仅支持SDIO2.0高速模式的WiFi模块,供电1.8/3.3V都是可以的,切记必须保持一致;
第一步
我们先用万用表测量这些引脚的电压,如果SDIO_CLK/CMD/D0D3、VCCIO6电压都一样的话,视为正常,可以认为电源管理这一项没有问题。D3这些引脚电平为1.8V,如果SDIO2.0的话把该引脚拉低,并且SDIO_CLK/CMD/D0-D3这些引脚电平为3.3V。显然,这次我们需要将该引脚拉低。
第二步
查看一下ap6256芯片手册文档,看到如下图,其中wifi中的第9脚表明,如果需要SDIO3.0模式的话就把该引脚拉高,并且SDIO_CLK/CMD/D0
这里有个小贴士,如果将WIFI第29脚接地的话,用O欧电阻串联,我试过用10K电阻串联,结果还是高电平1。
第三步
设备树的配置和WiFi驱动模块的编译
DTS:IO电源域的配置
&pmu_io_domains {
status ="okay";
pmuio1-supply =<&vcc3v3_pmu>;
pmuio2-supply =<&vcc3v3_pmu>;
vccio1-supply =<&vccio_acodec>;
vccio3-supply =<&vccio_sd>;
vccio4-supply =<&vcc_3v3>;
vccio5-supply =<&vcc_3v3>;
vccio6-supply =<&vcc_3v3>;
vccio7-supply =<&vcc_3v3>;};
sdio_pwrseq: sdio-pwrseq {
compatible ="mmc-pwrseq-simple";
clocks =<&rk809 1>;
clock-names ="ext_clock";
pinctrl-names ="default";
pinctrl-0 =<&wifi_enable_h>;
/*
* On the module itself this is one of these (depending
* on the actual card populated):
* - SDIO_RESET_L_WL_REG_ON
* - PDN (power down when low)
*/
reset-gpios =<&gpio3 RK_PD5 GPIO_ACTIVE_LOW>;};
wireless_wlan: wireless-wlan {
compatible ="wlan-platdata";
pinctrl-names ="default";
rockchip,grf =<&grf>;
wifi_chip_type ="ap6256";
pinctrl-0 =<&wifi_host_wake_irq>;
WIFI,host_wake_irq =<&gpio3 RK_PD4 GPIO_ACTIVE_HIGH>;
status ="okay";};&sdmmc2 {
max-frequency =<50000000>;
supports-sdio;
bus-width =<4>;
disable-wp;
cap-sd-highspeed;
cap-sdio-irq;
keep-power-in-suspend;
mmc-pwrseq =<&sdio_pwrseq>;
non-removable;
pinctrl-names ="default";
pinctrl-0 =<&sdmmc2m0_bus4 &sdmmc2m0_cmd &sdmmc2m0_clk>;
sd-uhs-sdr104;
status ="okay";};
第四步
模块正常加载的打印信息
安装上一步编译好的wifi模块
[root@RK356X:/]# insmod bcmdhd.ko [13.746289] dhd_module_init: in Dongle Host Driver, version 1.57# 9.77.41.22 (r-20191105-2)(20191120-1)[13.746322]======== dhd_wlan_init_plat_data ========[13.746332][WLAN_RFKILL]: rockchip_wifi_get_oob_irq: Enter
[13.746431] dhd_wlan_init_gpio: WL_HOST_WAKE=-1, oob_irq=101, oob_irq_flags=0x414
[13.746444] dhd_wlan_init_gpio: WL_REG_ON=-1
[13.746454] dhd_wifi_platform_load: Enter
[13.746465] Power-up adapter 'DHD generic adapter'[13.747680] wifi_platform_set_power =1[13.747702]======== PULL WL_REG_ON(-1) HIGH!========[13.747709][WLAN_RFKILL]: rockchip_wifi_power: 1[13.747716][WLAN_RFKILL]: rockchip_wifi_power: toggle =false[13.747723][WLAN_RFKILL]: wifi turn on power [GPIO-1-0][14.052582] wifi_platform_bus_enumerate device present 1[14.052607]======== Card detection to detect SDIO card!========[14.052614] mmc3:mmc host rescan start![14.068802] bcmsdh_register: register client driver
[14.069043] bcmsdh_sdmmc_probe: Enter num=1[14.069667] bcmsdh_sdmmc_probe: Enter num=2[14.069692] bus num (host idx)=3, slot num (rca)=1[14.069704] found adapter info 'DHD generic adapter'[14.069862] sdioh_attach: set sd_f2_blocksize 256[14.069981] sdioh_attach: sd clock rate =0[14.070303] dhdsdio_probe : no mutex held. set lock
[14.070426] F1 signature read @0x18000000=0x15294345
[14.073767] F1 signature OK, socitype:0x1 chip:0x4345 rev:0x9 pkg:0x2
[14.074377] DHD: dongle ram size is set to 819200(orig 819200) at 0x198000
[14.074471][dhd] dhd_conf_set_chiprev :chip=0x4345, chiprev=9[14.074598][dhd] CFG80211-ERROR) wl_setup_wiphy : Registering Vendor80211
[14.074923][dhd] CFG80211-ERROR) wl_setup_wiphy : SAE support
[14.075159][dhd] CFG80211-ERROR) wl_init_prof : wl_init_prof: No profile
[14.076396] dhd_attach(): thread:dhd_watchdog_thread:2cf started
[14.076531] dhd_attach(): thread:dhd_dpc:2d0 started
[14.076639] dhd_attach(): thread:dhd_rxf:2d1 started
[14.076666] dhd_deferred_work_init: work queue initialized
[14.076678] dhd_tcpack_suppress_set: TCP ACK Suppress mode 0 -> mode 2[14.076715] dhd_bus_set_default_min_res_mask: Unhandled chip id[14.077020] sdioh_cis_read: func_cis_ptr[0]=0x10ac
[14.086499] Dongle Host Driver, version 1.579.77.41.22 (r-20191105-2)(20191120-1)[14.087282] Register interface [wlan0] MAC: d4:9c:dd:23:dc:e4
[14.087282][14.087394] dhd_tcpack_suppress_set: TCP ACK Suppress mode 2 -> mode 0[14.087415] dhd_wl_ioctl: returning as busstate=0[14.087427] dhd_dbg_detach_pkt_monitor, 2204[14.087437] dhd_bus_devreset: == Power OFF ==[14.087710] bcmsdh_oob_intr_unregister: Enter
[14.087723] bcmsdh_oob_intr_unregister: irq is not registered
[14.087738] dhd_txglom_enable: enable0[14.087747] dhd_bus_devreset: WLAN OFF DONE
[14.087798] wifi_platform_set_power =0[14.087811]======== PULL WL_REG_ON(-1) LOW!========[14.087822][WLAN_RFKILL]: rockchip_wifi_power: 0[14.087840][WLAN_RFKILL]: rockchip_wifi_power: toggle =false[14.087850][WLAN_RFKILL]: wifi shut off power [GPIO-1-1][14.087860] dhdsdio_probe : the lock is released.
[14.088309] dhd_module_init: Exit err=0[14.089291] dhd_ioctl_entry: Interface is down
[14.089316][dhd] WEXT-ERROR) wl_iw_get_essid : Error getting the SSID -22[14.109960] dhd_open: Enter 00000000e8c47884
[14.109987] dhd_open : no mutex held. set lock
[14.110002][14.110002] Dongle Host Driver, version 1.579.77.41.22 (r-20191105-2)(20191120-1)[14.110021][dhd-wlan0] wl_android_wifi_on :ing_wifi_on=0[14.110030] wifi_platform_set_power =1[14.110040]======== PULL WL_REG_ON(-1) HIGH!========[14.110049][WLAN_RFKILL]: rockchip_wifi_power: 1[14.110058][WLAN_RFKILL]: rockchip_wifi_power: toggle =false[14.110067][WLAN_RFKILL]: wifi turn on power [GPIO-1-0][14.436192] sdio_reset_comm():
[14.451491] mmc_host mmc3: Bus speed (slot 0)= 375000Hz (slot req 400000Hz, actual 375000HZ div =0)[14.468368] dwmmc_rockchip fe000000.dwmmc: failed to set rate 100000Hz
[14.468387] mmc_host mmc3: Bus speed (slot 0)= 375000Hz (slot req 100000Hz, actual 93750HZ div =2)[14.522770] mmc3: queuing unknown CIS tuple 0x80 (2 bytes)[14.529588] mmc3: queuing unknown CIS tuple 0x80 (3 bytes)[14.536495] mmc3: queuing unknown CIS tuple 0x80 (3 bytes)[14.549329] mmc3: queuing unknown CIS tuple 0x80 (7 bytes)[14.565034] mmc3: queuing unknown CIS tuple 0x81 (9 bytes)[14.784621] dwmmc_rockchip fe000000.dwmmc: failed to set rate 100000Hz
[14.784782] mmc_host mmc3: Bus speed (slot 0)= 50000000Hz (slot req 50000000Hz, actual 50000000HZ div =0)[14.784933] sdioh_start: set sd_f2_blocksize 256[14.785560][14.785560][14.785560] dhd_bus_devreset: == WLAN ON ==[14.785793] F1 signature read @0x18000000=0x15294345
[14.791979] F1 signature OK, socitype:0x1 chip:0x4345 rev:0x9 pkg:0x2
[14.793292] DHD: dongle ram size is set to 819200(orig 819200) at 0x198000
[14.793477] dhd_bus_set_default_min_res_mask: Unhandled chip id[14.797068][dhd] dhd_conf_read_config : Ignore config file /vendor/etc/firmware/config.txt
[14.797158][dhd] dhd_conf_set_path_params : Final fw_path=/vendor/etc/firmware/fw_bcm43456c5_ag.bin
[14.797204][dhd] dhd_conf_set_path_params : Final nv_path=/vendor/etc/firmware/nvram_ap6256.txt
[14.797243][dhd] dhd_conf_set_path_params : Final clm_path=/vendor/etc/firmware/clm_bcm43456c5_ag.blob
[14.797280][dhd] dhd_conf_set_path_params : Final conf_path=/vendor/etc/firmware/config.txt
[14.798975] dhd_os_open_image: /vendor/etc/firmware/fw_bcm43456c5_ag.bin (612559 bytes)open success
[15.086703] dhd_os_open_image: /vendor/etc/firmware/nvram_ap6256.txt (2732 bytes)open success
[15.088667] NVRAM version: AP6256_NVRAM_V1.4_06112021
[15.091514] dhdsdio_write_vars: Download, Upload and compare of NVRAM succeeded.
[15.182315] dhd_bus_init: enable 0x06, ready 0x06 (waited 0us)[15.183212] bcmsdh_oob_intr_register: HW_OOB irq=101flags=0x4
[15.183786] dhd_get_memdump_info: File [/data/misc/wifi/.memdump.info] doesn't exist
[15.183849] dhd_get_memdump_info: MEMDUMP ENABLED =2[15.188370] Disable tdls_auto_op failed. -1[15.188431] dhd_tcpack_suppress_set: TCP ACK Suppress mode 0 -> mode 1[15.189623] dhd_apply_default_clm: Ignore clm file /vendor/etc/firmware/clm_bcm43456c5_ag.blob
[15.194103] Firmware up: op_mode=0x0005, MAC=d4:9c:dd:23:dc:e4
[15.210297] Driver: 1.579.77.41.22 (r-20191105-2)(20191120-1)[15.210297] Firmware: wl0: Jun 11202113:06:16 version 7.45.96.91 (8d24bff@SYNA)(r745790) FWID 01-82a62ae es7.c5.n4.a3
[15.210297] CLM: 9.2.9 (2016-02-03 04:34:31)[15.210751] dhd_txglom_enable: enable1[15.210771][dhd] dhd_conf_set_txglom_params :txglom_mode=copy
[15.210781][dhd] dhd_conf_set_txglom_params :txglomsize=36, deferred_tx_len=0[15.210794][dhd] dhd_conf_set_txglom_params :txinrx_thres=128, dhd_txminmax=-1
[15.210807][dhd] dhd_conf_set_txglom_params :tx_max_offset=0, txctl_tmo_fix=300[15.210824][dhd] dhd_conf_get_disable_proptx :fw_proptx=1, disable_proptx=-1
[15.211894] dhd_wlfc_hostreorder_init(): successful bdcv2 tlv signaling, 64[15.213700] dhd_pno_init: Support Android Location Service
[15.233986][dhd] CFG80211-ERROR) wl_cfg80211_event : Event handler is not created
[15.234698] dhd_rtt_init : FTM is supported
[15.234717] dhd_preinit_ioctls: SensorHub diabled 0[15.235545] dhd_preinit_ioctls failed to set ShubHub disable
[15.237655][dhd] CFG80211-ERROR) wl_cfg80211_event : Event handler is not created
[15.237677][dhd] dhd_conf_map_country_list : CN/38
[15.237686][dhd] dhd_conf_set_country :set country CN, revision 38[15.240675][dhd] dhd_conf_set_country : Country code: CN (CN/38)[15.245912][dhd-wlan0] wl_android_wifi_on : Success
[15.301768] dhd_open : the lock is released.
[15.301835] dhd_open: Exit ret=0
查看是否有wlan节点
[root@RK356X:/]# ifconfig
eth0 Link encap:Ethernet HWaddr 06:51:A7:C1:B1:A4
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:35
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:84 errors:0 dropped:0 overruns:0 frame:0
TX packets:84 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5488 (5.3 KiB) TX bytes:5488 (5.3 KiB)
wlan0 Link encap:Ethernet HWaddr D4:9C:DD:23:DC:E4
inet addr:169.254.14.168 Bcast:169.254.255.255 Mask:255.255.0.0
inet6 addr: fe80::5340:dd3a:6601:58d7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:2681 (2.6 KiB)
异常分析
如果在加载模块的时候报以下错误:
[root@RK356X:/]# insmod bcmdhd.ko [17.552661] dhd_module_init: in Dongle Host Driver, version 1.579.77.41.22 (r-20191105-2)(20191120-1)[17.552700]======== dhd_wlan_init_plat_data ========[17.552708][WLAN_RFKILL]: rockchip_wifi_get_oob_irq: Enter
[17.552804] dhd_wlan_init_gpio: WL_HOST_WAKE=-1, oob_irq=101, oob_irq_flags=0x414
[17.552817] dhd_wlan_init_gpio: WL_REG_ON=-1
[17.552827] dhd_wifi_platform_load: Enter
[17.552840] Power-up adapter 'DHD generic adapter'[17.552900] wifi_platform_set_power =1[17.552943]======== PULL WL_REG_ON(-1) HIGH!========[17.552954][WLAN_RFKILL]: rockchip_wifi_power: 1[17.552975][WLAN_RFKILL]: rockchip_wifi_power: toggle =false[17.552983][WLAN_RFKILL]: wifi turn on power [GPIO-1-0][17.859951] wifi_platform_bus_enumerate device present 1[17.860022]======== Card detection to detect SDIO card!========[17.860047] mmc3:mmc host rescan start![19.876530] failed to power up DHD generic adapter, 1 retry left
[19.892724] wifi_platform_set_power =0[19.892744]======== PULL WL_REG_ON(-1) LOW!========[19.892752][WLAN_RFKILL]: rockchip_wifi_power: 0[19.892766][WLAN_RFKILL]: rockchip_wifi_power: toggle =false[19.892773][WLAN_RFKILL]: wifi shut off power [GPIO-1-1][19.892779] wifi_platform_bus_enumerate device present 0[19.892785]======== Card detection to remove SDIO card!========[19.892791] mmc3:mmc host rescan start![19.892841] wifi_platform_set_power =1[19.892853]======== PULL WL_REG_ON(-1) HIGH!========[19.892862][WLAN_RFKILL]: rockchip_wifi_power: 1[19.892871][WLAN_RFKILL]: rockchip_wifi_power: toggle =false[19.892880][WLAN_RFKILL]: wifi turn on power [GPIO-1-0][20.196502] wifi_platform_bus_enumerate device present 1[20.196567]======== Card detection to detect SDIO card!========[20.196594] mmc3:mmc host rescan start![22.223271] failed to power up DHD generic adapter, 0 retry left
[22.239490] wifi_platform_set_power =0[22.239511]======== PULL WL_REG_ON(-1) LOW!========[22.239520][WLAN_RFKILL]: rockchip_wifi_power: 0[22.239536][WLAN_RFKILL]: rockchip_wifi_power: toggle =false[22.239544][WLAN_RFKILL]: wifi shut off power [GPIO-1-1][22.239550] wifi_platform_bus_enumerate device present 0[22.239556]======== Card detection to remove SDIO card!========[22.239563] mmc3:mmc host rescan start![22.239569] failed to power up DHD generic adapter, max retry reached**
[22.239608] unregister wifi platform drivers
[22.239620] wifi_platform_bus_enumerate device present 0[22.239637]======== Card detection to remove SDIO card!========[22.239654] mmc3:mmc host rescan start![22.239668]======== dhd_wlan_deinit_plat_data ========[22.239680] dhd_module_init: Failed to load the driver, try cnt 0[22.239730] dhd_module_init: Failed to load driver max retry reached**
[22.239745] dhd_module_init: Exit err=-19
首先检查一下WL_REG_ON的引脚在设备树DTS中无有配置错误,有没有被拉高。在加载的WiFi模块的时候,用万用表测量一下WL_REG_ON引脚有拉高过没有。
你可以尝试屏蔽一下sdmmc2节点中的sd-uhs-sdr104;
如果重启后再次加载WIFI模块,报以下错误:
[root@RK356X:/]# insmod bcmdhd.ko [10.928437] dhd_module_init: in Dongle Host Driver, version 1.579.77.41.2
2(r-20191105-2)(20191120-1)[10.928479]======== dhd_wlan_init_plat_data ========[10.928488][WLAN_RFKILL]: rockchip_wifi_get_oob_irq: Enter
[10.928578] dhd_wlan_init_gpio: WL_HOST_WAKE=-1, oob_irq=101, oob_irq_flags=0x414
[10.928593] dhd_wlan_init_gpio: WL_REG_ON=-1
[10.928602] dhd_wifi_platform_load: Enter
[10.928617] Power-up adapter 'DHD generic adapter'[10.930180] wifi_platform_set_power =1[10.930202]======== PULL WL_REG_ON(-1) HIGH!========[10.930209][WLAN_RFKILL]: rockchip_wifi_power: 1[10.930216][WLAN_RFKILL]: rockchip_wifi_power: toggle =false[10.930223][WLAN_RFKILL]: wifi turn on power [GPIO-1-0][11.235616] wifi_platform_bus_enumerate device present 1[11.235685]======== Card detection to detect SDIO card!========[11.235711] mmc3:mmc host rescan start![11.251918] bcmsdh_register: register client driver
[11.252159] bcmsdh_sdmmc_probe: Enter num=1[11.252732] bcmsdh_sdmmc_probe: Enter num=2[11.252752] bus num (host idx)=3, slot num (rca)=1[11.252761] found adapter info 'DHD generic adapter'[11.252847] sdioh_attach: set sd_f2_blocksize 256[11.252896] sdioh_attach: sd clock rate =0[11.253474] dhdsdio_probe : no mutex held. set lock
[11.253613] F1 signature read @0x18000000=0x19258389
[11.254260] bcmsdh_sdmmc: Failed to Read word F1:@0x0e000=ffffffff, Err: 0xffffffac
[11.254283] bcmsdh_reg_read: error reading addr 0xe000 size 4[11.254352] bcmsdh_sdmmc: Failed to Read word F1:@0x0e004=ffffffff, Err: 0xffffffac
[11.254364] bcmsdh_reg_read: error reading addr 0xe004 size 4[11.254449] bcmsdh_sdmmc: Failed to Read word F1:@0x0e008=ffffffff, Err: 0xffffffac
[11.254462] bcmsdh_reg_read: error reading addr 0xe008 size 4[11.254528] bcmsdh_sdmmc: Failed to Read word F1:@0x0e00c=ffffffff, Err: 0xffffffac
[11.254541] bcmsdh_reg_read: error reading addr 0xe00c size 4[11.254606] bcmsdh_sdmmc: Failed to Read word F1:@0x0e010=ffffffff, Err: 0xffffffac
[11.254618] bcmsdh_reg_read: error reading addr 0xe010 size 4[11.254684] bcmsdh_sdmmc: Failed to Read word F1:@0x0e014=ffffffff, Err: 0xffffffac
[11.254696] bcmsdh_reg_read: error reading addr 0xe014 size 4[11.288620] bcmsdh_sdmmc: Failed to Read word F1:@0x0e6c4=ffffffff, Err: 0xffffffac
[11.288634] bcmsdh_reg_read: error reading addr 0xe6c4 size 4[11.288715] bcmsdh_sdmmc: Failed to Read word F1:@0x0e6c8=ffffffff, Err: 0xffffffac
[11.288732] bcmsdh_reg_read: error reading addr 0xe6c8 size 4
** 165 console messages dropped **
[23.502328] dhd_wifi_platform_load_sdio: sdio_register_driver timeout or error
[23.502577] wifi_platform_set_power =0[23.502598]======== PULL WL_REG_ON(-1) LOW!========[23.502612][WLAN_RFKILL]: rockchip_wifi_power: 0[23.502637][WLAN_RFKILL]: rockchip_wifi_power: toggle =false[23.502651][WLAN_RFKILL]: wifi shut off power [GPIO-1-1][23.502662] wifi_platform_bus_enumerate device present 0[23.502674]======== Card detection to remove SDIO card!========[23.502687] mmc3:mmc host rescan start![23.502698] unregister wifi platform drivers
[23.502709] wifi_platform_bus_enumerate device present 0[23.502720]======== Card detection to remove SDIO card!========[23.502732] mmc3:mmc host rescan start![23.502744]======== dhd_wlan_deinit_plat_data ========[23.502753] dhd_module_init: Failed to load the driver, try cnt 0[23.502803] dhd_module_init: Failed to load driver max retry reached**
[23.502817] dhd_module_init: Exit err=-62
[33.955649] vcc3v3_lcd1_n: disabling
这个错误大多原因是WiFi模块中SDIO接口有问题,导致通讯不了,识别不到。
这个你可以将sdmmc2节点中的bus-width = <4>改成bus-width = <1>,这样重新测试,如果成功了,证明是SDIO线序问题。
总结
这次的WiFi模块调试相比上次ap6212WiFi驱动调试笔记又有不一样的收获,这次是纠结在bus-width=<4>为4线一直不行,当把bus-width改为1后(sdio单线模式)后,就能顺利加载模块了。电压不一样也会影响WIFI不能正常工作,如何去切换SDIO3.0和SDIO2.0模式。
版权归原作者 赟赟、嵌入式 所有, 如有侵权,请联系我们删除。