当前位置:网站首页>WiFi ap6212 driver transplantation and debugging analysis technical notes

WiFi ap6212 driver transplantation and debugging analysis technical notes

2022-04-23 18:15:00 Talent、me

Help the customer debug this time wifi modular ap6212 modular ( BCM43438), Due to the problem of hardware design , This leads to various driver loading error messages , And there are few such wrong information on the Internet , That's a headache , I have to feel it slowly . This time is based on imx6 Platform debugging , stay imx6dl and imx6ul Both models have been debugged successfully .

Drive migration

Address Links :wifi Driver and firmware download
explain :
bcmdhd Driver source code , To be compiled into driver .
cyw43438-7.46.58.15.bin yes firmware The firmware .
NB197SM.nvram_20181105_AZ_Joe.txt yes nvram The configuration file .

** Configure driver bcmdhd In the directory Makefile In the document DHD_PLATFORM **
Platform dependent START
DHD_PLATFORM ?= imx
Configure the firmware loading path , open Kconfig

config BCMDHD_FW_PATH 
depends on BCMDHD 
string "Firmware path" 
default "/lib/firmware/ap6256/cyw43438-7.46.58.15.bin" 
---help--- 
Path to the firmware file. 
config BCMDHD_NVRAM_PATH 
depends on BCMDHD 
string "NVRAM path" 
default "/etc/firmware/NB197SM.nvram_20181105_AZ_Joe.txt" 
---help---
 Path to the calibration file.

Device tree configuration

regulators {
     
	wlreg_on: [email protected] {
     
		compatible = "regulator-fixed";
		regulator-min-microvolt = <3300000>;
	  	regulator-max-microvolt = <3300000>; 
	  	regulator-name = "wlreg_on";
	    gpio = <&gpio1 30 0>; /* WL_REG_ON */ 
	    startup-delay-us = <100>;
	    enable-active-high;
	 };
};
bcmdhd_wlan_0: [email protected] {
     
	compatible = "android,bcmdhd_wlan"; 
	gpios = <&gpio1 31 0>; /* WL_HOST_WAKE */ 
	wlreg_on-supply = <&wlreg_on>; 
};

//SDIO To configure 
&usdhc1 {
     
	pinctrl-names = "default"; 
	pinctrl-0 = <&pinctrl_wifi>;
 	bus-width = <4>;
	keep-power-in-suspend;
	enable-sdio-wakeup;
	no-1-8-v;
	non-removable;
	cd-post;
	pm-ignore-notify;
	wifi-host; 
	status = "okay";
    pinctrl_wifi: wifigrp {
     
		fsl,pins = < 
		MX6UL_PAD_SD1_CMD__USDHC1_CMD 0x17059 
		MX6UL_PAD_SD1_CLK__USDHC1_CLK 0x10071 
		MX6UL_PAD_SD1_DATA0__USDHC1_DATA0 0x17059 
		MX6UL_PAD_SD1_DATA1__USDHC1_DATA1 0x17059 
		MX6UL_PAD_SD1_DATA2__USDHC1_DATA2 0x17059 
		MX6UL_PAD_SD1_DATA3__USDHC1_DATA3 0x17059 
		MX6UL_PAD_UART5_TX_DATA__GPIO1_IO30 0x03029 /* WL_REG_ON */ 
		MX6UL_PAD_UART5_RX_DATA__GPIO1_IO31 0x03029 /* WL_HOST_WAKE*/ 
		>;
 };

Drive loading

Load the driver into the kernel , I did not wifi Compile into modules .ko, If it is loaded successfully, the following information will be printed .

dhd_module_init in
Power-up adapter 'DHD generic adapter'
 - irq 50 [flags 1044], firmware: (null), nvram: (null)
 - bus type -1, bus num -1, slot num -1
wifi_platform_bus_enumerate device present 1
F1 signature read @0x18000000=0x1541a9a6
F1 signature OK, socitype:0x1 chip:0xa9a6 rev:0x1 pkg:0x4
DHD: dongle ram size is set to 524288(orig 524288) at 0x0
CFG80211-ERROR) wl_setup_wiphy : Registering Vendor80211
wl_create_event_handler(): thread:wl_event_handler:5b started
CFG80211-ERROR) wl_event_handler : tsk Enter, tsk = 0xa84a1490
dhd_attach(): thread:dhd_watchdog_thread:5c started
dhd_attach(): thread:dhd_dpc:5d started
dhd_attach(): thread:dhd_rxf:5e started
dhd_deferred_work_init: work queue initialized 
Dongle Host Driver, version 1.363.125.17 (r)
Compiled in drivers/net/wireless/bcmdhd on Nov  5 2021 at 13:41:01
Register interface [wlan0]  MAC: 00:90:4c:11:22:33
CFG80211-ERROR) wl_event_handler : was terminated
wl_destroy_event_handler(): thread:wl_event_handler:5b terminated OK
usb-storage 2-1.1:1.0: USB Mass Storage device detected
dhd_wl_ioctl: returning as busstate=0
dhd_bus_devreset: == Power OFF ==
scsi host0: usb-storage 2-1.1:1.0
dhd_bus_devreset:  WLAN OFF DONE
dhd_module_init out

This information is understood in several layers

1. The driver starts loading
dhd_module_init in

2. The module card device has been normally recognized by the kernel
mmc0: new high speed SDIO card at address 0001
F1 signature read @0x18000000=0x1541a9a6
F1 signature OK, socitype:0x1 chip:0xa9a6 rev:0x1 pkg:0x4

3. Loading successful , obtain MAC Address and driver version number
Dongle Host Driver, version 1.363.125.17
Compiled in drivers/net/wireless/bcmdhd on Nov 5 2021 at 13:41:01
Register interface [wlan0] MAC: 00:90:4c:11:22:33

4. End of driver loading
dhd_module_init out

Question 1 :
If you configure in the kernel wifi drive , However, the information that the module starts loading is not printed out in the startup information , You need to check wifi Whether the driver has been selected to compile in a modular way .

Question two :
If the following information is printed when the driver is loaded , Need to check the hardware interface :(WL_REG_ON) Enable feet and (WL_HOST_WAKE) Whether the wake-up foot is pulled high , Use a multimeter to measure these two pins . If you don't pull it up , Please change other places in the driver to pull it up or force it up from the hardware .
 Insert picture description here

dhd_module_init in
Power-up adapter 'DHD generic adapter'
 - irq 50 [flags 1044], firmware: (null), nvram: (null)
 - bus type -1, bus num -1, slot num -1
wifi_platform_bus_enumerate device present 1
Hfailed to power up DHD generic adapter, 3 retry left
wifi_platform_bus_enumerate device present 0
wifi_platform_bus_enumerate device present 1
Hfailed to power up DHD generic adapter, 2 retry left
wifi_platform_bus_enumerate device present 0
wifi_platform_bus_enumerate device present 1
Hfailed to power up DHD generic adapter, 1 retry left
wifi_platform_bus_enumerate device present 0
wifi_platform_bus_enumerate device present 1
Hfailed to power up DHD generic adapter, 0 retry left
wifi_platform_bus_enumerate device present 0
H1failed to power up DHD generic adapter, max retry reached**
dhd_module_init out
** If the following print message appears :**
```bash
mmc0: error -110 whilst initialising SDIO card

It may be caused by unstable power supply at startup , perhaps sdio There is something wrong with the wiring .

After the driver is successfully loaded , start-up WiFi

If in execution ifconfig wlan0 up When the command , Print the following message , It belongs to normal startup .

[email protected]:~# rfkill unblock all
[email protected]:~# ifconfig wlan0 up

Dongle Host Driver, version 1.363.125.17 (r)
Compiled in drivers/net/wireless/bcmdhd on Nov  5 2021 at 13:41:01
wl_android_wifi_on in

dhd_bus_devreset: == WLAN ON ==
F1 signature read @0x18000000=0x1541a9a6
F1 signature OK, socitype:0x1 chip:0xa9a6 rev:0x1 pkg:0x4
DHD: dongle ram size is set to 524288(orig 524288) at 0x0
_dhdsdio_download_firmware:  8078 
dhdsdio_download_state: 4067
dhdsdio_download_state: 4075
dhdsdio_download_state: 4086
dhdsdio_download_state: 4239
dhdsdio_download_code_file: download firmware /lib/firmware/ap6256/fw_bcm43456c5_ag.bin
dhd_os_open_image: download firmware /lib/firmware/ap6256/fw_bcm43456c5_ag.bin
dhdsdio_download_nvram:  8024 
dhd_os_open_image: download firmware /lib/firmware/ap6256/nvram_ap6256.txt
dhdsdio_download_nvram:  8028 
dhdsdio_download_state: 4067
dhdsdio_write_vars: Download, Upload and compare of NVRAM succeeded.
dhdsdio_download_state: 4239
dhd_bus_devreset:  8364 
dhd_bus_init: 4510
dhd_bus_init: enable 0x06, ready 0x06 (waited 0us)
dhd_bus_init: 4634
Disable tdls_auto_op failed. -1
Firmware up: op_mode=0x0005, MAC=20:4e:f6:25:f1:1b
dhd_os_open_image: download firmware /system/etc/wifi/bcmdhd_clm.blob
dhd_preinit_ioctls Set txbf failed  -23
dhd_preinit_ioctls Set ampdu_mpdu to 16 failed  -29
dhd_preinit_ioctls pspretend_threshold for HostAPD failed  -23
Firmware version = wl0: Jun 19 2018 02:10:20 version 7.46.58.15 (r692018 CY) FWID 01-ab22dc42 es4.c3.n4
dhd_wlfc_hostreorder_init(): successful bdcv2 tlv signaling, 64
dhd_pno_init: Support Android Location Service
MACEVENT: WLC_E_IF 54, MAC 20:4e:f6:25:f1:1b, status 0, reason 0, auth 0
rtt_do_get_ioctl: failed to send getbuf proxd iovar (CMD ID : 1), status=-23
dhd_rtt_init : FTM is not supported
dhd_interworking_enable: failed to set WNM info, ret=-23
MACEVENT: WLC_E_IF 54, MAC 20:4e:f6:25:f1:1b, status 0, reason 0, auth 0
MACEVENT: WLC_E_IF 54, MAC 20:4e:f6:25:f1:1b, status 0, reason 0, auth 0
CFG80211-ERROR) wl_update_wiphybands : error reading vhtmode (-23)
wl_create_event_handler(): thread:wl_event_handler:360 started
CFG80211-ERROR) wl_event_handler : tsk Enter, tsk = 0xa84a1490

1. prove WiFi The firmware has been loaded normally .
dhdsdio_download_code_file: download firmware /lib/firmware/ap6256/fw_bcm43456c5_ag.bin
dhd_os_open_image: download firmware /lib/firmware/ap6256/fw_bcm43456c5_ag.bin
dhd_os_open_image: download firmware /lib/firmware/ap6256/nvram_ap6256.txt
dhdsdio_write_vars: Download, Upload and compare of NVRAM succeeded.

If this error occurs
dhdsdio_membytes: membytes transfer failed
dhdsdio_membytes: FAILED to set window back to 0x18000000
dhdsdio_download_code_file: error -1 on writing 2048 membytes at 0x00004800
You need to check sdio There is a problem with the wiring of the , There's something wrong with communication , Can't download .

ifconfig wlan0 up

Dongle Host Driver, version 1.363.125.17 (r)
Compiled in drivers/net/wireless/bcmdhd on Nov  5 2021 at 13:41:01
wl_android_wifi_on in
dhd_bus_devreset: == WLAN ON ==
F1 signature read @0x18000000=0x1541a9a6
F1 signature OK, socitype:0x1 chip:0xa9a6 rev:0x1 pkg:0x4
DHD: dongle ram size is set to 524288(orig 524288) at 0x0
_dhdsdio_download_firmware:  8078 
dhdsdio_download_state: 4067
dhdsdio_download_state: 4075
dhdsdio_download_state: 4086
dhdsdio_download_state: 4239
dhdsdio_download_code_file: download firmware /lib/firmware/ap6256/fw_bcm43456c5_ag.bin
dhd_os_open_image: download firmware /lib/firmware/ap6256/fw_bcm43456c5_ag.bin
mmc0: Timeout waiting for hardware interrupt.
dhdsdio_membytes: membytes transfer failed
dhdsdio_membytes: FAILED to set window back to 0x18000000
dhdsdio_download_code_file: error -1 on writing 2048 membytes at 0x00004800
_dhdsdio_download_firmware: dongle image file download failed
dhdsdio_htclk: Failed access turning clock off: -35
dhd_bus_devreset Failed to download binary to the dongle
dhd_net_bus_devreset: dhd_bus_devreset: -35
dhd_open : wl_android_wifi_on failed (-35)
wl_android_wifi_off in
dhd_wl_ioctl: returning as busstate=0

If the following error occurs :

[   11.325715] brcmfmac: brcmf_sdio_htclk: HT Avail timeout (1000000): clkctl 0x50

Need to check the firmware nvramxxx.txt In the document xtalfreq Parameters of , This parameter is related to the frequency of the passive crystal oscillator , The crystal oscillator uses 26M, It needs to be changed to xtalfreq=26000 Talent .

After the above steps are completed normally , Connect WIFI step

Execution instruction : wpa_supplicant -B -Dnl80211 -iwlan0 -c /etc/wpa_supplicant.conf &
These commands will be printed continuously :

[email protected]:~# wpa_supplicant -B -Dnl80211 -iwlan0 -c /etc/wpa_supplicant.conf &
[email protected]:~# kill 884CFG80211-ERROR) wl_run_escan : LEGACY_SCAN sync ID: 4660, bssidx: 0
[email protected]:~# MACEVENT: WLC_E_ESCAN_RESULT 69, MAC 00:00:00:00:00:00, status 0 

If the above print message appears , You need to check whether your crystal oscillator is consistent with wifi The specifications are consistent . For example, the specification uses 26MHZ , And you use... On your hardware 32.768MHZ, The above printed information will appear

Experience

This time, debug this WIFI modular , There are many problems in the hardware , It leads to the thought that it is caused by the problem of software , A waste of time , How to summarize , In the future, we will avoid hitting the wall .

版权声明
本文为[Talent、me]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210610471538.html