• android-AP6212配置


    一、调试背景

    硬件平台a33
    系统android
    wifi:ap6212a
    从内核日志看到模块能加载识别到fw_bcm43438a1.bin ,但是nvram加载的配置是nvram_ap6212.txt,虽然能正常工作,但是对比了一下nvram_ap6212.txt 和nvram_ap6212a.txt还是有差异的
    内核日志:

    [   26.488791] [dhd] sdioh_attach: set sd_f2_blocksize 256
    [   26.494959] [dhd] sdioh_attach: sd clock rate = 50000000
    [   26.501230] [dhd] dhdsdio_probe : no mutex held
    [   26.506381] [dhd] dhdsdio_probe : set mutex lock
    [   26.511786] [dhd] F1 signature read @0x18000000=0x1541a9a6
    [   26.520666] [dhd] F1 signature OK, socitype:0x1 chip:0xa9a6 rev:0x1 pkg:0x4
    [   26.529455] [dhd] DHD: dongle ram size is set to 524288(orig 524288) at 0x0
    [   26.538303] [dhd] STATIC-MSG) dhd_wlan_mem_prealloc : section 7, size 26016
    [   26.546243] [dhd] dhd_conf_set_chiprev : devid=0xa9a6, chip=0xa9a6, chiprev=1
    [   26.554445] [dhd] STATIC-MSG) dhd_wlan_mem_prealloc : section 0, size 10320
    [   26.564263] [dhd] STATIC-MSG) dhd_wlan_mem_prealloc : section 5, size 65536
    [   26.574767] [dhd] STATIC-MSG) dhd_wlan_mem_prealloc : section 19, size 65652
    [   26.582815] [dhd] STATIC-MSG) dhd_wlan_mem_prealloc : section 20, size 262144
    [   26.591063] [dhd] STATIC-MSG) dhd_wlan_mem_prealloc : section 22, size 65536
    [   26.599175] [dhd] dhd_attach(): thread:dhd_watchdog_thread:8a4 started
    [   26.606930] [dhd] dhd_attach(): thread:dhd_dpc:8a5 started
    [   26.613481] [dhd] dhd_attach(): thread:dhd_rxf:8aa started
    [   26.619645] [dhd] dhd_deferred_work_init: work queue initialized
    [   26.626464] [dhd] dhd_tcpack_suppress_set: TCP ACK Suppress mode 0 -> mode 2
    [   26.634387] [dhd] dhd_tcpack_suppress_set: TCPACK_INFO_MAXNUM=4, TCPDATA_INFO_MAXNUM=4
    [   26.643438] [dhd] sdioh_cis_read: func_cis_ptr[0]=0x1070
    [   26.661258] [dhd] STATIC-MSG) dhd_wlan_mem_prealloc : section 1, size 10300
    [   26.669071] [dhd] STATIC-MSG) dhd_wlan_mem_prealloc : section 2, size 65536
    [   26.677001] [dhd] dhdsdio_probe_init: making DHD_BUS_DOWN
    [   26.683472] [dhd] wifi_platform_get_mac_addr
    [   26.688517] audit: type=1400 audit(1716882474.400:377): avc:  denied  { read } for  pid=1588 comm="android.hardwar" name="aura_mac.txt" dev="mmcblk0p11" ino=9 scontext=u:r:hal_wifi_default:s0 tcontext=u:object_r:vfat:s0 tclass=file permissive=1
    [   26.712797] audit: type=1400 audit(1716882474.423:378): avc:  denied  { open } for  pid=1588 comm="android.hardwar" path="/private/ULI/factory/aura_mac.txt" dev="mmcblk0p11" ino=9 scontext=u:r:hal_wifi_default:s0 tcontext=u:object_r:vfat:s0 tclass=file permissive=1
    [   26.739466] [dhd] Dongle Host Driver, version 101.10.361.33 (wlan=r892223-20230607-2)\x0adrivers/net/wireless/bcmdhd compiled on May  9 2024 at 14:10:01\x0a
    [   26.761310] [dhd] Register interface [wlan0]  MAC: 04:c2:9b:0b:be:9d\x0a
    [   26.772027] [dhd] [wlan0] wl_android_wifi_off : in g_wifi_on=1, on_failure=1
    [   26.784655] [dhd] dhd_bus_devreset: == Power OFF ==
    [   26.792231] [dhd] dhd_bus_stop: making DHD_BUS_DOWN
    [   26.797832] [dhd] dhd_bus_devreset: making dhdpub up FALSE
    [   26.804995] [dhd] dhd_txglom_enable: enable 0
    [   26.809972] [dhd] dhd_bus_devreset: making DHD_BUS_DOWN
    [   26.816260] [dhd] wifi_platform_set_power = 0, delay: 0 msec
    [   26.822672] [dhd] ======== PULL WL_REG_ON(-1) LOW! ========
    [   26.829514] [dhd] [wlan0] wl_android_wifi_off : out
    [   26.835053] [dhd] dhdsdio_probe : mutex is released.
    [   26.841396] [dhd] _dhd_module_init: Exit err=0
    [   26.852181] [dhd] dhd_pri_open : no mutex held
    [   26.857224] [dhd] dhd_pri_open : set mutex lock
    [   26.862395] [dhd] [wlan0] dhd_open : Enter
    [   26.867128] [dhd] Dongle Host Driver, version 101.10.361.33 (wlan=r892223-20230607-2)\x0adrivers/net/wireless/bcmdhd compiled on May  9 2024 at 14:10:01\x0a
    [   26.885342] [dhd] dhd_open: ######### called for ifidx=0 #########
    [   26.892307] [dhd] [wlan0] wl_android_wifi_on : in g_wifi_on=0
    [   26.898820] [dhd] wifi_platform_set_power = 1, delay: 200 msec
    [   26.905426] [dhd] ======== PULL WL_REG_ON(-1) HIGH! ========
    [   26.912109] sunxi-wlan soc@1c00000:wlan: check wlan wlan_power voltage: 3300000
    [   26.920610] sunxi-wlan soc@1c00000:wlan: check wlan io_regulator voltage: 3300000
    [   27.254520] [dhd] sdio_sw_reset: call mmc_hw_reset
    [   27.260004] sunxi-mmc sdc1: sdc set ios:clk 0Hz bm PP pm OFF vdd 0 width 1 timing LEGACY(SDR12) dt B
    [   27.278701] sunxi-mmc sdc1: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
    [   27.298048] sunxi-mmc sdc1: no vqmmc,Check if there is regulator
    [   27.320656] sunxi-mmc sdc1: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
    [   27.347654] sunxi-mmc sdc1: smc 1 p1 err, cmd 52, RTO !!
    [   27.355974] sunxi-mmc sdc1: smc 1 p1 err, cmd 52, RTO !!
    [   27.362618] sunxi-mmc sdc1: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
    [   27.376225] sunxi-mmc sdc1: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
    [   27.391003] sunxi-mmc sdc1: smc 1 p1 err, cmd 8, RTO !!
    [   27.410920] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
    [   27.419102] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
    [   27.430284] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
    [   27.442063] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
    [   27.455857] mmc1: queuing unknown CIS tuple 0x81 (9 bytes)
    [   27.573243] sunxi-mmc sdc1: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing SD-HS(SDR25) dt B
    [   27.584573] sunxi-mmc sdc1: sdc set ios:clk 50000000Hz bm PP pm ON vdd 21 width 1 timing SD-HS(SDR25) dt B
    [   27.596241] sunxi-mmc sdc1: sdc set ios:clk 50000000Hz bm PP pm ON vdd 21 width 4 timing SD-HS(SDR25) dt B
    [   27.608599] [dhd] sdioh_start: set sd_f2_blocksize 256
    [   27.615291] [dhd] dhd_bus_devreset: == Power ON ==
    [   27.621812] [dhd] F1 signature read @0x18000000=0x1541a9a6
    [   27.635071] [dhd] F1 signature OK, socitype:0x1 chip:0xa9a6 rev:0x1 pkg:0x4
    [   27.644918] [dhd] DHD: dongle ram size is set to 524288(orig 524288) at 0x0
    [   27.654212] [dhd] dhd_bus_devreset: making DHD_BUS_DOWN
    [   27.660189] [dhd] dhdsdio_probe_init: making DHD_BUS_DOWN
    [   27.666803] [dhd] dhd_conf_set_path_params : Final fw_path=/vendor/modules/fw_bcm43438a1.bin
    [   27.676332] [dhd] dhd_conf_set_path_params : Final nv_path=/system/vendor/modules/nvram_ap6212.txt
    [   27.685667] audit: type=1400 audit(1716882475.396:379): avc:  denied  { sigchld } for  pid=1657 comm="touch-watcher.s" scontext=u:object_r:zygote_exec:s0 tcontext=u:object_r:zygote_exec:s0 tclass=process permissive=1
    [   27.686269] audit: type=1400 audit(1716882475.396:380): avc:  denied  { use } for  pid=1657 comm="touch-watcher.s" path="/dev/null" dev="tmpfs" ino=3878 scontext=u:object_r:zygote_exec:s0 tcontext=u:r:init:s0 tclass=fd permissive=1
    [   27.686316] audit: type=1400 audit(1716882475.396:381): avc:  denied  { write } for  pid=1657 comm="touch-watcher.s" path="/dev/null" dev="tmpfs" ino=3878 scontext=u:object_r:zygote_exec:s0 tcontext=u:object_r:null_device:s0 tclass=chr_file permissive=1
    [   27.686460] audit: type=1400 audit(1716882475.396:382): avc:  denied  { search } for  pid=1657 comm="touch-watcher.s" name="/" dev="mmcblk0p11" ino=1 scontext=u:object_r:zygote_exec:s0 tcontext=u:object_r:vfat:s0 tclass=dir permissive=1
    [   27.783053] [dhd] dhd_conf_set_path_params : Final clm_path=/vendor/modules/clm_bcm43438a1.blob
    [   27.793123] [dhd] dhd_conf_set_path_params : Final conf_path=/system/vendor/modules/config_ap6212.txt
    [   27.804683] [dhd] dhd_get_download_buffer: Open image file failed /system/vendor/modules/config_ap6212.txt
    [   27.816135] [dhd] dhd_conf_read_config : Ignore config file /system/vendor/modules/config_ap6212.txt
    [   27.832171] [dhd] dhd_os_open_image1: /vendor/modules/fw_bcm43438a1.bin (422837 bytes) open success
    [   27.970379] [dhd] dhd_os_open_image1: /system/vendor/modules/nvram_ap6212.txt (993 bytes) open success
    [   27.982570] [dhd] #AP6212_NVRAM_V1.0.2_20191121\x0d
    [   27.990595] [dhd] dhdsdio_write_vars: Download, Upload and compare of NVRAM succeeded.
    [   28.075452] [dhd] dhd_bus_init: enable 0x06, ready 0x06 (waited 0us)
    [   28.092029] [dhd] wlc_ver_major 4, wlc_ver_minor 1
    [   28.100655] [dhd] dhd_preinit_ioctls: preinit_status IOVAR not supported, use legacy preinit
    [   28.110291] [dhd] dhd_tcpack_suppress_set: TCP ACK Suppress mode 2 -> mode 0
    [   28.118166] [dhd] dhd_tcpack_suppress_set: TCPACK_INFO_MAXNUM=4, TCPDATA_INFO_MAXNUM=4
    [   28.127626] [dhd] wifi_platform_get_mac_addr
    [   28.133226] [dhd] dhd_legacy_preinit_ioctls: use firmware generated mac_address 04:c2:9b:0b:be:9d
    [   28.143230] [dhd] dhd_apply_default_clm: Ignore clm file /vendor/modules/clm_bcm43438a1.blob
    [   28.157618] [dhd] Firmware up: op_mode=0x0005, MAC=04:c2:9b:0b:be:9d
    [   28.165476] [dhd] Disable tdls_auto_op failed. -1
    [   28.173637] [dhd] dhd_legacy_preinit_ioctls Set scancache failed -23
    [   28.183688] [dhd] dhd_legacy_preinit_ioctls: event_log_max_sets: 31 ret: -23
    [   28.194803] [dhd] arp_enable:1 arp_ol:0
    [   28.212388] [dhd]   Driver: 101.10.361.33 (wlan=r892223-20230607-2)\x0a[dhd]   Firmware: wl0: Jan 14 2022 15:16:34 version 7.45.96.123 (g0180acf3) FWID 01-457251af es7.c5.n4.a3\x0a[dhd]   CLM: 7.11.15 (2014-05-26 10:53:55) 
    [   28.238088] [dhd] dhd_txglom_enable: enable 1
    [   28.243193] [dhd] dhd_conf_set_txglom_params : txglom_mode=copy
    [   28.249969] [dhd] dhd_conf_set_txglom_params : txglomsize=36, deferred_tx_len=0
    [   28.258464] [dhd] dhd_conf_set_txglom_params : txinrx_thres=-1, dhd_txminmax=1
    [   28.266500] [dhd] dhd_conf_set_txglom_params : tx_max_offset=0, txctl_tmo_fix=300
    [   28.274861] [dhd] dhd_conf_get_disable_proptx : fw_proptx=1, disable_proptx=-1
    [   28.284522] [dhd] dhd_wlfc_hostreorder_init(): successful bdcv2 tlv signaling, 64
    [   28.295746] [dhd] dhd_pno_init: Support Android Location Service
    [   28.304990] [dhd] dhd_wl_ioctl_get_intiovar: get int iovar wnm_bsstrans_resp failed, ERR -23
    [   28.316103] [dhd] failed to get wnm_bsstrans_resp
    [   28.322874] [dhd] failed to set WNM capabilities
    [   28.358690] [dhd] dhd_legacy_preinit_ioctls: Failed to get preserve log # !
    [   28.394091] [dhd] dhd_conf_set_country : set country CN, revision 0
    [   28.404311] [dhd] dhd_conf_set_country : Country code: CN (CN/0)
    [   28.418057] [dhd] CONFIG-ERROR) dhd_conf_set_intiovar : ampdu_mpdu setting failed -29
    [   28.427496] [dhd] [wlan0] wl_android_wifi_on : Success
    [   28.462432] [dhd] CFG80211-ERROR) __wl_update_wiphybands : error reading vhtmode (-23)
    [   28.473781] [dhd] CFG80211-ERROR) __wl_update_wiphybands : error get bw_cap 6g (-13)
    [   28.496174] [dhd] CFG80211-ERROR) init_roam_cache : roamscan_mode iovar failed. -23
    [   28.505609] [dhd] CFG80211-ERROR) wl_cfg80211_up : Failed to enable RCC.
    [   28.514893] [dhd] [wlan0] dhd_open : Exit ret=0
    [   28.520644] [dhd] [wlan0] dhd_pri_open : tx queue started
    [   28.526727] [dhd] dhd_pri_open : mutex is released.
    [   28.591116] init: starting service 'wpa_supplicant'...
    [   28.599845] init: Created socket '/dev/socket/wpa_wlan0', mode 660, user 1010, group 1010
    [   28.801936] [dhd] P2P interface registered
    [   28.817711] [dhd] WLC_E_IF: NO_IF set, event Ignored\x0d
    [   28.825435] [dhd] P2P interface started
    [   28.862224] [dhd] Random MAC OUI to be used - da:1:19
    [   28.885774] [dhd] net_os_enable_packet_filter: val = 0
    [   28.893666] [dhd] net_os_rxfilter_add_remove: add_remove = 0, num = 2
    [   28.903356] [dhd] net_os_enable_packet_filter: val = 1
    [   28.911497] [dhd] net_os_enable_packet_filter: val = 0
    [   28.918641] [dhd] net_os_rxfilter_add_remove: add_remove = 0, num = 3
    [   28.929275] [dhd] net_os_enable_packet_filter: val = 1
    

    二、排查思路

    查看内核代码:
    android/longan/kernel/linux-4.9/drivers/net/wireless/bcmdhd/dhd_config.c

    typedef struct chip_name_map_t {
    	uint chip;
    	uint chiprev;
    	uint ag_type;
    	char *chip_name;
    	char *module_name;
    } chip_name_map_t;
    
    /* Map of WLC_E events to connection failure strings */
    #define DONT_CARE	9999
    const chip_name_map_t chip_name_map[] = {
    	/* ChipID			Chiprev	AG	 	ChipName	ModuleName  */
    #ifdef BCMSDIO
    	{BCM43362_CHIP_ID,	0,	DONT_CARE,	"bcm40181a0",		""},
    	{BCM43362_CHIP_ID,	1,	DONT_CARE,	"bcm40181a2",		""},
    	{BCM4330_CHIP_ID,	4,	FW_TYPE_G,	"bcm40183b2",		""},
    	{BCM4330_CHIP_ID,	4,	FW_TYPE_AG,	"bcm40183b2_ag",	""},
    	{BCM43430_CHIP_ID,	0,	DONT_CARE,	"bcm43438a0",		""},
    	{BCM43430_CHIP_ID,	1,	DONT_CARE,	"bcm43438a1",		""},
    	{BCM43430_CHIP_ID,	2,	DONT_CARE,	"bcm43436b0",		""},
    	{BCM43012_CHIP_ID,	1,	FW_TYPE_G,	"bcm43013b0",		""},
    	{BCM43012_CHIP_ID,	1,	FW_TYPE_AG,	"bcm43013c0_ag",	""},
    	{BCM43012_CHIP_ID,	2,	DONT_CARE,	"bcm43013c1_ag",	""},
    	{BCM4334_CHIP_ID,	3,	DONT_CARE,	"bcm4334b1_ag",		""},
    	{BCM43340_CHIP_ID,	2,	DONT_CARE,	"bcm43341b0_ag",	""},
    	{BCM43341_CHIP_ID,	2,	DONT_CARE,	"bcm43341b0_ag",	""},
    	{BCM4324_CHIP_ID,	5,	DONT_CARE,	"bcm43241b4_ag",	""},
    	{BCM4335_CHIP_ID,	2,	DONT_CARE,	"bcm4339a0_ag",		""},
    	{BCM4339_CHIP_ID,	1,	DONT_CARE,	"bcm4339a0_ag",		""},
    	{BCM4345_CHIP_ID,	6,	DONT_CARE,	"bcm43455c0_ag",	""},
    	{BCM43454_CHIP_ID,	6,	DONT_CARE,	"bcm43455c0_ag",	""},
    	{BCM4345_CHIP_ID,	9,	DONT_CARE,	"bcm43456c5_ag",	""},
    	{BCM43454_CHIP_ID,	9,	DONT_CARE,	"bcm43456c5_ag",	""},
    	{BCM4354_CHIP_ID,	1,	DONT_CARE,	"bcm4354a1_ag",		""},
    	{BCM4354_CHIP_ID,	2,	DONT_CARE,	"bcm4356a2_ag",		""},
    	{BCM4356_CHIP_ID,	2,	DONT_CARE,	"bcm4356a2_ag",		""},
    	{BCM4371_CHIP_ID,	2,	DONT_CARE,	"bcm4356a2_ag",		""},
    	{BCM43569_CHIP_ID,	3,	DONT_CARE,	"bcm4358a3_ag",		""},
    	{BCM4359_CHIP_ID,	5,	DONT_CARE,	"bcm4359b1_ag",		""},
    	{BCM4359_CHIP_ID,	9,	DONT_CARE,	"bcm4359c0_ag",		""},
    	{BCM43751_CHIP_ID,	1,	DONT_CARE,	"bcm43751a1_ag",	""},
    	{BCM43751_CHIP_ID,	2,	DONT_CARE,	"bcm43751a2_ag",	""},
    	{BCM43752_CHIP_ID,	1,	DONT_CARE,	"bcm43752a1_ag",	""},
    	{BCM43752_CHIP_ID,	2,	DONT_CARE,	"bcm43752a2_ag",	""},
    #endif
    	......
    };
    
    
    //匹配代码,根据探测到的sdio devices_id来匹配
    const chip_name_map_t*
    dhd_conf_match_chip(dhd_pub_t *dhd, uint ag_type)
    {
    	uint chip, chiprev;
    	int i;
    
    	chip = dhd->conf->chip;
    	chiprev = dhd->conf->chiprev;
    
    	for (i=0; ichip == chip && row->chiprev == chiprev &&
    				(row->ag_type == ag_type ||
    					ag_type == DONT_CARE || row->ag_type == DONT_CARE)) {
    			return row;
    		}
    	}
    
    	return NULL;
    }
    
    

    有配置bcm43438a0和bcm43438a1

    三、根据日志定位

    static bool
    dhdsdio_probe_attach(struct dhd_bus *bus, osl_t *osh, void *sdh, void *regsva,
                         uint16 devid)
    {
    	......
    	/* si_attach() will provide an SI handle and scan the backplane */
    	if (!(bus->sih = si_attach((uint)devid, osh, regsva, DHD_BUS, sdh,
    	                           &bus->vars, &bus->varsz))) {
    		DHD_ERROR(("%s: si_attach failed!\n", __FUNCTION__));
    		goto fail;
    	}
    #ifdef DHD_DEBUG   //bus->sih->chip 和bus->sih->chiprev 来表示模块唯一ID
    	DHD_ERROR(("F1 signature OK, socitype:0x%x chip:0x%4x rev:0x%x pkg:0x%x\n",
    		bus->sih->socitype, bus->sih->chip, bus->sih->chiprev, bus->sih->chippkg));
    #endif /* DHD_DEBUG */
      ......
    }
    

    3.1 android hal层配置

    查看android hal 代码

    3.2查看蓝牙相关的配置

    已经添加了ap6212 和ap6212a

    static const fw_auto_detection_entry_t fw_auto_detection_table[] = {
        {"4343A0","BCM43438A0"},     //AP6212
        {"BCM4350C0","BCM4354A1"},   //AP6354
        {"BCM4335C0","BCM4339A0"},   //AP6335
        {"BCM4354A2","BCM4356A2"},   //AP6356
        {"BCM4359C0","BCM4359C0"},   //AP6359
        {"BCM4349B1","BCM4359B1"},   //AP6359
        {"BCM4330B1","BCM40183B2"},  //AP6330
        {"BCM4324B3","BCM43241B4"},  //AP62X2
        {"BCM20702A","BCM20710A1"},  //AP6210B
        {"BCM43430B0","BCM4343B0"},  //AP6236
        {"BCM43430A1","BCM43438A1"}, //AP6212A
        {NULL, NULL}
    };
    
    

    3.3hal 解析底层探测到的wifi设备信息,将解析的模块信息写入

    property_set(“wlan.hardware.info”, info);

    内核上报地方:
    kernel/linux-4.9/drivers/mmc/core/sdio_bus.c
    
    static int sdio_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
    {
    	struct sdio_func *func = dev_to_sdio_func(dev);
    	unsigned int deviceid = func->device;
    	printk("%s: cis_chipvendor:0x%x,deviceid:0x%x ,func->num=%d\n", __func__,cis_chipvendor,deviceid,func->num);
    
    	if (add_uevent_var(env,
    			"SDIO_CLASS=%02X", func->class))
    		return -ENOMEM;
    	if (cis_chipvendor == 0x8101) {	//for awcm wifi module
    		if (func->device == 0xa9a6) {
    			deviceid = 0x8172;	//awnm372sm wifi
    		} else {
    			deviceid = cis_chipvendor; //awcm390sm wifi
    		}
    	}
    	if (add_uevent_var(env,
    			"SDIO_ID=%04X:%04X", func->vendor, deviceid))
    		return -ENOMEM;
    
    	printk("%s: SDIO_ID=%04X:%04X", __func__, func->vendor, deviceid);
    
    	if (add_uevent_var(env,
    			"MODALIAS=sdio:c%02Xv%04Xd%04X",
    			func->class, func->vendor, func->device))
    		return -ENOMEM;
    
    	return 0;
    }
    
    
    android 数据解析:
    android/hardware/libhardware_legacy/wifi_hardware_info/wifi_hardware_info.c
    
    static void parse_uevent(char *msg, struct wifi_hardware_info *wifiinfo)
    {
    	......
        if (!strncmp(subsystem, "sdio", 4)) {
            ALOGI("get uevent, sdio_id = %s", sdio_id);
            strcpy(device_type, "sdio");
            char *subid = strrchr(sdio_id, ':');
            if (subid == NULL) {
                return;
            }
            subid++;
            strcpy(sdio_device_id, subid);
            device_id = strtoul(sdio_device_id, NULL, 16);
            device_id += 0x10000;   //底层只上报device_id ,片选设备0x01没有上报,导致应用层无法区分ap6212和ap6212a  chip:0xa9a6 rev:0x1 pkg:0x4)
        }
    	......
    
    }
    
    

    3.4 最后查看到wifi_list 只定义device_id = 0x1a9a6 ,解析出来的模块是ap6212

    void get_driver_module_arg(char* arg) 设置nvram_path的时候只识别出ap6212
    底层只上报device_id

    android/hardware/libhardware_legacy/wifi_hardware_info/wifi_hardware_info.c
    struct wifi_hardware_info {
        unsigned long device_id;
        char *module_name;
        char *driver_name;
        char *driver_module_name;
        char *vendor_name;
        char *fw_path_sta;
        char *fw_path_ap;
        char *fw_path_p2p;
    };
    
    static const struct wifi_hardware_info wifi_list[] = {
        {
            .device_id   = 0x1a9a6,	//设备ID,通过内核sdio_probe 可以查看到此ID 
            .module_name = "ap6212",  //模块名字
            .driver_name = "bcmdhd",   //驱动名字
            .driver_module_name = "bcmdhd",
            .vendor_name = "broadcom",
            .fw_path_sta = "/system/vendor/modules/fw_bcm43438a0.bin",  //驱动bin文件
            .fw_path_ap  = "/system/vendor/modules/fw_bcm43438a0_apsta.bin",
            .fw_path_p2p = "/system/vendor/modules/fw_bcm43438a0_p2p.bin",
        }
    }
    
    void get_driver_module_arg(char* arg)
    {
       ...............................
        const char *vendor_name = get_wifi_vendor_name();
        if(strcmp(vendor_name, "realtek") == 0) {
            const char *driver_module_arg = "ifname=wlan0 if2name=p2p0";
            snprintf(module_arg, sizeof(module_arg), "%s", driver_module_arg);
        } else if(strcmp(vendor_name, "broadcom") == 0) {
            const char *nvram_path = "nvram_path=/system/vendor/modules/nvram";
            const char *config_path = "config_path=/system/vendor/modules/config";
        **snprintf(module_arg, sizeof(module_arg), "%s_%s.txt %s_%s.txt",
                nvram_path, get_wifi_module_name(), config_path, get_wifi_module_name());
        }
        ...............................
    }
    

    解决如下:

    android/hardware/libhardware_legacy/wifi_hardware_info/wifi_hardware_info.c
    //在wifi_list 添加ap6212a的配置是行不通的
    static const struct wifi_hardware_info wifi_list[] = {
      {
            .device_id   = 0x1a9a6,	//设备ID,通过内核sdio_probe 可以查看到此ID 
            .module_name = "ap6212",  //模块名字
            .driver_name = "bcmdhd",   //驱动名字
            .driver_module_name = "bcmdhd",
            .vendor_name = "broadcom",
            .fw_path_sta = "/system/vendor/modules/fw_bcm43438a1.bin",  //驱动bin文件
            .fw_path_ap  = "/system/vendor/modules/fw_bcm43438a1_apsta.bin",
            .fw_path_p2p = "/system/vendor/modules/fw_bcm43438a1_p2p.bin",
        }
    }
    

    日志分析

    从分析来看内核sdio_bus_uevent 生产上报的env 数据比较早,还没区分是ap6212还是ap6212a,所以只能从内核方面入手解决。

    再重新分析bin文件能加载对,但是nvram加载不对,原因在于如下: dhd_conf_get_module_name,获取到的模块名字为空,导致底层最终使用的nvram是由应用传递下来的。而在这个时候,已经拿到ag_type 是可以区分ap6212和ap6212a了。

    kernel/linux-4.9/drivers/net/wireless/bcmdhd/dhd_config.c
    
    const chip_name_map_t*dhd_conf_match_chip(dhd_pub_t *dhd, uint ag_type)
    {
    	uint chip, chiprev;
    	int i;
    	chip = dhd->conf->chip;
    	chiprev = dhd->conf->chiprev;
    	for (i=0; ichip == chip && row->chiprev == chiprev &&
    				(row->ag_type == ag_type ||
    					ag_type == DONT_CARE || row->ag_type == DONT_CARE)) {
    			return row;
    		}
    	}
    	return NULL;
    }
    
    
    char *dhd_conf_get_module_name(dhd_pub_t *dhd, int ag_type){
    	const chip_name_map_t *row_chip = NULL;
    	char *name = NULL;
    	{
    		row_chip = dhd_conf_match_chip(dhd, ag_type);
    		if (row_chip && strlen(row_chip->module_name)) {
    			name = row_chip->module_name;
    		}
    	}
    	return name;
    }
    
    
    void dhd_conf_set_nv_name_by_chip(dhd_pub_t *dhd, char *nv_path, int ag_type)
    {
    	......
    	name_ptr = &nv_path[i];
    
    	module_name = dhd_conf_get_module_name(dhd, ag_type);	//为空,导致使用hal传递下来的nvram配置
    	if (module_name) {
    		strcpy(name_ptr, "nvram_");
    		strcat(name_ptr, module_name);
    #ifdef BCMUSBDEV_COMPOSITE
    		strcat(name_ptr, "_cusb");
    #endif
    		strcat(name_ptr, ".txt");
    		printk("dhd_conf_set_nv_name_by_chip module_name=%s\n", module_name);
    	}
    	strcpy(nv_name, name_ptr);
    	......
    }
    

    再回头看,原来是没有定义ap6212和ap6212a模块,导致这里取出来是空。

    最终解决如下:

    const chip_name_map_t chip_name_map[] = {
    	/* ChipID			Chiprev	AG	 	ChipName	ModuleName  */
    	{BCM43430_CHIP_ID,	0,	DONT_CARE,	"bcm43438a0",		""},
    	{BCM43430_CHIP_ID,	1,	DONT_CARE,	"bcm43438a1",		""},
    	{BCM43430_CHIP_ID,	2,	DONT_CARE,	"bcm43436b0",		""},
    }
    
    修改:
    const chip_name_map_t chip_name_map[] = {
    	/* ChipID			Chiprev	AG	 	ChipName	ModuleName  */
    	{BCM43430_CHIP_ID,	0,	DONT_CARE,	"bcm43438a0",		"ap6212"},
    	{BCM43430_CHIP_ID,	1,	DONT_CARE,	"bcm43438a1",		"ap6212a"},
    	{BCM43430_CHIP_ID,	2,	DONT_CARE,	"bcm43436b0",		""},
    }
    

    这样就能正确加载nvram_ap6212a.txt

  • 相关阅读:
    (附源码)springboot农田灌溉设备管理系统 毕业设计 260931
    区间与邻域
    QT 5.14.2版本 MAC环境安装部署流程
    一文读懂云渲染“串流”全链路时延及优化策略
    SQL语言(一)数据查询
    MySQL的MHA
    Webpack vs Vite的核心差异
    基于JSP的网络教学平台的设计与实现
    SpringMvc学习之旅与Thymeleaf的常用用法
    我理解的游戏数据模型
  • 原文地址:https://blog.csdn.net/huangkaiyue1/article/details/139330759