• I.MX6 AW-NB177NF WIFI 驱动移植问题


    /********************************************************************************
     *                  I.MX6 AW-NB177NF WIFI 驱动移植问题
     * 说明:
     *     之前驱动移植,但看不到有wlan设备产生,于是感觉是wifi驱动出了问题,于是开始
     * 分析厂家提供的wifi驱动,发现id对应的信息不对,经过与FAE确认之后并验证,确实是
     * 这个问题导致的。
     *
     *                                              2016-6-20 深圳 南山平山村 曾剑锋
     *******************************************************************************/
    
    一、参考文档:
        1. AW-NB177NF-DS-BC-Rev0.3_single Ant.pdf
        2. 基于linux-2.6.38.8内核的SDIO/wifi驱动分析(转)
           http://www.cnblogs.com/hoys/archive/2013/01/09/2853715.html
    
    二、wifi 驱动注册设备驱动的id相关代码:
        ......
        static const struct sdio_device_id sdio_ids[] =
        {
        #ifdef CONFIG_RTL8723B
            { SDIO_DEVICE(0x024c, 0xB723),.driver_data = RTL8723B},
        #endif
        #ifdef CONFIG_RTL8188E
            { SDIO_DEVICE(0x024c, 0x8179),.driver_data = RTL8188E},
        #endif //CONFIG_RTL8188E
        
        #ifdef CONFIG_RTL8821A
            { SDIO_DEVICE(0x024c, 0x8821),.driver_data = RTL8821},
        #endif //CONFIG_RTL8821A
        
        #ifdef CONFIG_RTL8192E
            { SDIO_DEVICE(0x024c, 0x818B),.driver_data = RTL8192E},
        #endif //CONFIG_RTL8192E
        
        #if defined(RTW_ENABLE_WIFI_CONTROL_FUNC) /* temporarily add this to accept all sdio wlan id */
            { SDIO_DEVICE_CLASS(SDIO_CLASS_WLAN) },
        #endif
            { /* end: all zeroes */             },
        };
        ......
        #define SDIO_DEVICE(vend,dev) 
            .class = SDIO_ANY_ID, 
            .vendor = (vend), .device = (dev)
        ......
        #define SDIO_ANY_ID (~0)
        ......
    
    三、获取SDIO设备信息代码位置如下:
        static int sdio_init_func(struct mmc_card *card, unsigned int fn)
        {
            int ret;
            struct sdio_func *func;
    
            BUG_ON(fn > SDIO_MAX_FUNCS);
    
            func = sdio_alloc_func(card);
            if (IS_ERR(func))
                return PTR_ERR(func);
    
            func->num = fn;
    
            if (!(card->quirks & MMC_QUIRK_NONSTD_SDIO)) {
                ret = sdio_read_fbr(func);
                if (ret)
                    goto fail;
    
                ret = sdio_read_func_cis(func);
                if (ret)
                    goto fail;
            } else {
                func->vendor = func->card->cis.vendor;
                func->device = func->card->cis.device;
                func->max_blksize = func->card->cis.blksize;
            }
    
            card->sdio_func[fn - 1] = func;
    
            printk("check sdio, func->vendor: 0x%x, func->device: 0x%x, func->max_blksize: 0x%x.
    ", func->vendor, func->device, func-       >max_blksize);
            return 0;
    
        fail:
            /*
             * It is okay to remove the function here even though we hold
             * the host lock as we haven't registered the device yet.
             */
            sdio_remove_func(func);
            return ret;
        }
            
    四、SDIO驱动获取到的信息:
        func->vendor: 0x24c, func->device: 0x626, func->max_blksize: 0x200.
    
    五、解决办法:
        { SDIO_DEVICE(0x024c, 0x626),.driver_data = RTL8723B},
    
    六、查看结果:
        root@android:/ # busybox ifconfig -a
        can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
                  NOARP  MTU:16  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:10 
                  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
                  Interrupt:142 
    
        can1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
                  NOARP  MTU:16  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:10 
                  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
                  Interrupt:143 
    
        ip6tnl0   Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
                  NOARP  MTU:1452  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:0 
                  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
        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:16436  Metric:1
                  RX packets:4683 errors:0 dropped:0 overruns:0 frame:0
                  TX packets:4683 errors:0 dropped:0 overruns:0 carrier:0
                  collisions:0 txqueuelen:0 
                  RX bytes:703477 (686.9 KiB)  TX bytes:703477 (686.9 KiB)
    
        sit0      Link encap:IPv6-in-IPv4  
                  NOARP  MTU:1480  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:0 
                  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
        tunl0     Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-10-00-00-00-00-00-00-00-00-00  
                  NOARP  MTU:1480  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:0 
                  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
        wlan0     Link encap:Ethernet  HWaddr 80:A5:89:49:6E:81  
                  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)
    
        root@android:/ #
    
    七、Linux kernel log:
        RTL871X: module init start
        RTL871X: rtl8723bs v4.3.16_13854.20150410_BTCOEX20150119-5844
        RTL871X: build time: Jun 20 2016 09:05:58
        RTL871X: rtl8723bs BT-Coex version = BTCOEX20150119-5844
        RTL871X: module init ret=0
        ......
        check sdio, func->vendor: 0x24c, func->device: 0x626, func->max_blksize: 0x200.
        mmc2: new high speed SDIO card at address 0001
        ......
        RTL871X: register rtw_netdev_ops to netdev_ops
        RTL871X: rtw_hal_config_rftype RF_Type is 3 TotalTxPath is 1 
        RTL871X: Chip Version Info: CHIP_8723B_Normal_Chip_TSMC_B_CUT_1T1R_RomVer(0)
        RTL871X: EEPROM type is E-FUSE
        RTL871X: SetHwReg8723B: bMacPwrCtrlOn=1
        RTL871X: PowerOnCheck: val_mix:0x0000063f, res:0x0000063f
        RTL871X: PowerOnCheck: 0x100 the result of cmd52 and cmd53 is the same.
        RTL871X: PowerOnCheck: 0x1B8 test Pass.
        RTL871X: _ReadAdapterInfo8723BS, 0x4e=0xe2
        RTL871X: hal_EfuseSwitchToBank: Efuse switch bank to 0
        RTL871X: hal_ReadEFuse_WiFi: data end at address=0xad
        RTL871X: Efuse Realmap:
        08 28 00 62 07 0D 45 10 02 00 00 
        29 29 29 29 28 28 2F 2F 2F 2E 2E E0 FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF 2D 2D 2D 2D 2D 2D 
        2D 2D 2D 2D 2D E0 FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF 20 2C 20 00 00 00 FF FF 
        FF 29 20 11 00 00 00 FF 00 FF 12 FF FF FF FF FF 
        3E 10 01 02 23 00 00 FF 20 04 4C 02 26 06 21 02 
        0C 00 22 04 00 08 00 32 FF 21 02 0C 00 22 2A 01 
        01 00 00 00 00 00 00 00 00 00 00 00 02 00 FF FF 
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
        00 EB 00 6E 01 00 00 00 00 FF 80 A5 89 49 6E 81 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
        RTL871X: Hal_EfuseParseBTCoexistInfo_8723B: Enable BT-coex, ant_num=1
        RTL871X: Hal_EfuseParsePackageType_8723B phy efuse read 0x1FB =fc 
        RTL871X: PackageType = 0x4
        RTL871X: Hal_EfuseParseVoltage_8723B hwinfo[EEPROM_Voltage_ADDR_8723B] =62 
        EXT4-fs (mmcblk0p5): mounted filesystem with ordered data mode. Opts: (null)
        RTL871X: Hal_EfuseParseVoltage_8723B pHalData->adjuseVoltageVal =6 
        RTL871X: AutoloadFail =0,
        RTL871X: pHalData->EEPROMRFGainVal=f0
        RTL871X: EEPRORFGainOffset = 0x29
        RTL871X: SetHwReg8723B: bMacPwrCtrlOn=0
        RTL871X: <==== _ReadAdapterInfo8723BS in 300 ms
        RTL871X: Hal_ChannelPlanToRegulation ChannelPlan:0x20,Regulation(2_4G/5G):0x03,0x03
        RTL871X: init_channel_set ChannelPlan ID 20 Chan num:13  
        EXT4-fs (mmcblk0p4): warning: checktime reached, running e2fsck is recommended
        RTL871X: rtw_alloc_macid(eth%d) if1, hwaddr:ff:ff:ff:ff:ff:ff macid:1
        RTL871X: rtw_register_early_suspend
        RTL871X: Init_ODM_ComInfo_8723b(): fab_ver=0 cut_ver=0
        RTL871X: rtw_macaddr_cfg mac addr:80:a5:89:49:6e:81
        RTL871X: bDriverStopped:1, bSurpriseRemoved:0, bup:0, hw_init_completed:0
        RTL871X: rtw_ndev_init(wlan0)
        RTL871X: _rtw_drv_register_netdev, MAC Address (if1) = 80:a5:89:49:6e:81
        ......
    八、Linux 命令行打开wifi:
        root@android:/ # netcfg
        lo       UP                                   127.0.0.1/8   0x00000049 00:00:00:00:00:00
        can0     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        can1     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        tunl0    DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        sit0     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        ip6tnl0  DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        wlan0    DOWN                                   0.0.0.0/0   0x00001002 80:a5:89:49:6e:81
        root@android:/ # busybox ifconfig wlan0 up
        RTL871X: +871x_drv - drv_open, bup=0
        RTL871X: FW does not exist before power on!!
        RTL871X: SetHwReg8723B: bMacPwrCtrlOn=1
        RTL871X: PowerOnCheck: val_mix:0x0000063f, res:0x0000063f
        RTL871X: PowerOnCheck: 0x100 the result of cmd52 and cmd53 is the same.
        RTL871X: PowerOnCheck: 0x1B8 test Pass.
        RTL871X: Power on ok!
        RTL871X: rtl8723b_FirmwareDownload fw: FW_NIC, size: 32108
        RTL871X: rtl8723b_FirmwareDownload: fw_ver=23 fw_subver=0000 sig=0x5301, Month=03, Date=26, Hour=14, Minute=35
        RTL871X: rtl8723b_FirmwareDownload(): Shift for fw header!
        RTL871X: polling_fwdl_chksum: Checksum report OK! (1, 0ms), REG_MCUFWDL:0x00070305
        RTL871X: _8051Reset8723: Finish
        RTL871X: _FWFreeToGo: Polling FW ready OK! (297, 30ms), REG_MCUFWDL:0x000702c6
        RTL871X: FWDL success. write_fw:1, 300ms
        RTL871X:  <=== rtl8723b_FirmwareDownload()
        RTL871X: HalDetectPwrDownMode(): PDN=0
        RTL871X: Set RF Chip ID to RF_6052 and RF type to 3.
        RTL871X: _init_available_page_threshold(): Enable Tx FIFO Page Threshold H:0x7a7a,N:0x7575,L:0x7575
        RTL871X: ===>phy_SwChnl8723B: Channel = 1
        RTL871X: pDM_Odm TxPowerTrackControl = 1
        RTL871X: ===>phy_SwChnl8723B: Channel = 1
        RTL871X: #### hw_var_set_opmode() -5250 iface_type(0) mode = 2 ####
        RTL871X: Using the default RF gain.
        RTL871X: MAC Address = 80:a5:89:49:6e:81
        RTL871X: start rtl8723bs_xmit_thread(wlan0)
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=9 seq=0 len=7
        RTL871X: -871x_drv - drv_open, bup=1
        ADDRCONF(NETDEV_UP): wlan0: link is not ready
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=1 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=2 len=7
        root@android:/ # RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=3 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=4 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=5 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=6 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=7 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=8 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=9 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=10 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=11 len=7
        RTL871X: rtl8723b_c2h_packet_handler: C2H, ID=11 seq=12 len=7
        RTL871X: IsBtDisabled=0, IsBtControlLps=0
        RTL871X: ==>rtw_ps_processor .fw_state(8)
        RTL871X: ==>ips_enter cnts:1
        RTL871X: nolinked power save enter
        RTL871X: ===> rtw_ips_pwr_down...................
        RTL871X: ====> rtw_ips_dev_unload...
        RTL871X: rtl8723bs_hal_deinit: issue H2C to FW when entering IPS
        RTL871X: rtl8723b_set_FwPwrModeInIPS_cmd()
        RTL871X: rtl8723bs_hal_deinit  polling REG_HMETFR=0x4, cnt=1 
        RTL871X: rtl8723bs_hal_deinit  polling REG_HMETFR=0x0, cnt=2 
        RTL871X: rtl8723bs_hal_deinit: write rpwm=81
        RTL871X: rtl8723bs_hal_deinit  polling 0x100=0xea, cnt=1 
        RTL871X: polling done when entering IPS, check result : 0x100=0xea, cnt=1, MAC_1cc=0xea
        RTL871X: <=== rtw_ips_pwr_down..................... in 70ms
    
        root@android:/ # netcfg                                                        
        lo       UP                                   127.0.0.1/8   0x00000049 00:00:00:00:00:00
        can0     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        can1     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        tunl0    DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        sit0     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        ip6tnl0  DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00
        wlan0    UP                                     0.0.0.0/0   0x00001043 80:a5:89:49:6e:81
  • 相关阅读:
    Requests
    探索式测试(概念)
    IDEA_Java+maven+selenium3+testng自动化测试环境安装
    RobotFramework Formate
    Robot Framework_dictionary search
    Git
    配置robotframework框架的自动化环境
    Python学习之路
    对 Jenkins+ANT+Jmeter 接口测试的实践
    自动生成测试脚本方案浅析
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/5600585.html
Copyright © 2020-2023  润新知