10/16/2012

Can not connection to Softap for security

Kernel : 2.6.37

WiFi module : WG7310 ( Inside WL127x )

在Android Jelly Bean 底下,當打開hostspot時,發現只能連接OPEN方式,任何加密都無法被連接上。

起初以為是自己從ICS移稙到JB時,Frameworks出了問題,結果不是。

底下是錯誤的log :

D/hostapd ( 2058): random: Got 5/20 bytes from /dev/random
I/hostapd ( 2058): random: Only 5/20 bytes of strong random data available from /dev/random
I/hostapd ( 2058): random: Not enough entropy pool available for secure operations
I/hostapd ( 2058): WPA: Not enough entropy in random pool for secure operations - update keys later when the first station connects
D/hostapd ( 2058): GMK - hexdump(len=32): [REMOVED]
D/hostapd ( 2058): Key Counter - hexdump(len=32): [REMOVED]
D/hostapd ( 2058): WPA: Delay group state machine start until Beacon frames have been configured
D/hostapd ( 2058): WPS: Building WPS IE for (Re)Association Response
D/hostapd ( 2058): WPS:  * Version (hardcoded 0x10)
D/hostapd ( 2058): WPS:  * Response Type (3)
D/hostapd ( 2058): WPS:  * Version2 (0x20)
D/hostapd ( 2058): nl80211: Set beacon (beacon_set=0)
D/hostapd ( 2058): WPA: Start group state machine to set initial keys
D/hostapd ( 2058): WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
D/hostapd ( 2058): GTK - hexdump(len=16): [REMOVED]
D/hostapd ( 2058): WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
D/hostapd ( 2058): wpa_driver_nl80211_set_key: ifindex=6 alg=3 addr=0x4006f0f1 key_idx=1 set_tx=1 seq_len=0 key_len=16
D/hostapd ( 2058):    broadcast key
D/hostapd ( 2058): nl80211: set_key failed; err=-2 No such file or directory)
D/hostapd ( 2058): wpa_driver_nl80211_set_operstate: operstate 0->1 (UP)

一直以為是TI的wpa_supplicant出了問題....結果竟然也不是 !

原來是kernel的某個config沒被打開,造成hostapd去產生一個隨機的dummy key時錯誤,wpa_supplicant去set key時自然會fail...

不清楚是不是所有的secure key都會通過 "/dev/random"  去對kernel做儲存,但就目前SoftAP而言,wpa_supplicant都是透過這種方式去儲存和產生所有的key number.  (STA就不知道了....)

在kernel config 把 "CONFIG_CRYPTO_ANSI_CPRNG" 打開就可以解決該問題了  !

8/22/2012

NCLP R5-SP1 WLAN Dirver for modules of Jorjin the inside TI WL12xx chip


#################################################################
#   README
#
#   Introduction Wlan Driver For Jorjin SiP Modules
#
#   NLCP Version        : R5_SP1
#   Operation system    : Linux / Android
#   Date                : July,24 2012
#   Mantainer           : Dicky Chiang <dickychiang@jorjin.com.tw>
#
#   Jorjin Technologies Inc - http://www.jorjin.com.tw/
#
#################################################################

NLCP(Native Linux Communication Package) is open source,which to integrated for TI.

The wlan driver will to support WG72xx/WG73xx/WG75xx of the Jorjin SiP modules.

Wirelees solutions of the between TI and Jorjin:
* WG72xx - Inside WL125x chip
* WG73xx - Inside WL127x chip
* WG75xx - Inside WL128x chip

Download site:

# git clone git://github.com/dickychiang/compat-wireless-r5-sp1.git

====================================================================================================
1. Build Instructions

Setting your environment:

# export YOUR_PATH=`pwd`
# export DRIVER_PATH=${YOUR_PATH}/
# export ARCH=arm
# export CROSS_COMPILE=
# export PATH=$PATH:
# export DESTDIR=
# export KLIB=
# export KLIB_BUILD=$KLIB

Building:

# make modules     # Only modules
# make install     # Build modules & install to your filesystem

====================================================================================================
2. Firmware

Choose for your module type then to copy into the filesystem.

For Android:
# cp ${DRIVER_PATH}/jorjin/firmware/WG73xx_fw/*.bin \
     /etc/firmware/ti-connectivity/
For Linux:
# cp ${DRIVER_PATH}/jorjin/firmware/WG73xx_fw/*.bin \
     /lib/firmware/ti-connectivity/

====================================================================================================

3. Copy driver module

# cp ${DRIVER_PATH}/compat/compat.ko                           $(DESTDIR)/system/lib/modules
# cp ${DRIVER_PATH}/drivers/net/wireless/wl12xx/wl12xx.ko      $(DESTDIR)/system/lib/modules
# cp ${DRIVER_PATH}/net/mac80211/mac80211.ko                   $(DESTDIR)/system/lib/modules
# cp ${DRIVER_PATH}/net/wireless/cfg80211.ko                   $(DESTDIR)/system/lib/modules
# cp ${DRIVER_PATH}/drivers/net/wireless/wl12xx/wl12xx_sdio.ko $(DESTDIR)/system/lib/modules
# cp ${DRIVER_PATH}/drivers/net/wireless/wl12xx/wl12xx_spi.ko  $(DESTDIR)/system/lib/modules

====================================================================================================
4. Insert module

Go to you filesystem then according to as below for insert module.

# insmod compat.ko
# insmod cfg80211.ko
# insmod mac80211.ko

Choose for your module type.
# insmod wl1251.ko
# insmod wl1251_sdio.ko

====================================================================================================
************************************
* Related WLAN tools & application *
************************************

1. Install SoftAP & wpa_supplicant_8 with R5-SP1 WLAN driver
# git clone git://github.com/dickychiang/hostap.git
# cd hostap
# git checkout R5_SP1_Maintenance_Release
# cd ../ ; cp -rf hostap/* $MYDROID/external/wpa_supplicant_8

2. Install ti-utils (calibration tools)
# git clone git://github.com/dickychiang/ti-utils.git
# cd ti-utils
# git checkout R5_SP1_Maintenance_Release
# cd ../ ; cp -rf ti-utils $MYDROID/external/ti-utils

3. Install IW (for Android version)
# git clone git://github.com/dickychiang/iw.git
# cd iw
# git checkout ol_R5.00.21
# cd ../ ; cp -rf iw $MYDROID/external/iw

4. Install crda(Central Regulatory Domain Agent)
# git clone git://github.com/dickychiang/crda.git
# cp -rf crda $MYDROID/external/crda

====================================================================================================
************************************
* How to Calibration *
************************************
The calibrator and other useful utilities for TI wireless solution,
based on wl12xx driver.

Calibration is a process in which specific radio configuration parameters are
generated and saved into the NVS file, later to be used by the wl12xx driver
upon initialization.
These configuration parameters are specific to the chip on the specific design
and therefore are sent back to the driver to store in non-volatile memory for
later use. Upon initialization, the wl12xx driver will load an NVS file where
it expects to read those parameters and send them to the chip.

The NVS file contains 2 main parts - one stores the calibration parameters and
the other one stores initialization information required for the wl12xx driver.


1. Install ti-utils (calibration tools)
# git clone git://github.com/dickychiang/ti-utils.git
# cd ti-utils
# git checkout R5_SP1_Maintenance_Release
# make
Don't forget to set your environment before make.

# cp ./calibrator /bin/

2. Copy ini files into the filesystem
For Andriod:
# cp ${DRIVER_PATH}/jorjin/ini_files/ \
${TAGET_OUT}/etc/firmware/ti-connectivity/TQS_S_2.6.ini 
For Native Linux:
# cp ${DRIVER_PATH}/jorjin/ini_files/ \
${ROOT_FS}/lib/firmware/ti-connectivity/TQS_S_2.6.ini 

3. Execute calibrator on your board
# rmmod wl12xx_sdio.ko
# calibrator plt autocalibrate     
         Device name. Probably wlan0
  Full path to wl12xx_sdio.ko kernel module                                                                             
         Full path to Radio param ini file
         Full path of nvs file. Must be the real path as wl12xx will load it
For example: 
# calibrator plt autocalibrate wlan0 \
/system/lib/modules/wl12xx_sdio.ko \
/etc/firmware/ti-connectivity/TQS_S_2.6.ini \
/etc/firmware/ti-connectivity/wl1271-nvs.bin 00:01:02:03:04:05

Appendix:

How to change MAC address in calibrated NVS

# calibrator set nvs_mac  []

If the MAC address missing, the random valid value will be added

====================================================================================================
**********************
* Building for Linux *
**********************

1. Install libnl-2.0

First to download it:

# git clone git://github.com/dickychiang/libnl-2.0.git

And export environment or can reference to script 'm.sh'

# export ROOTFS_PATH=
# export PATH=:$PATH
# export CROSS_COMPILE=
# ./configure --prefix=${ROOTFS}  CC=${CROSS_COMPILE}gcc --host=arm-linux LD=${CROSS_COMPILE}ld
# make
# make install

====================================================================================================
2. Install IW tool for wireless configuration

Download source code :

# git clone git://github.com/dickychiang/iw-linux.git

Export environment or reference script 'm.sh' for compile.

# export PKG_CONFIG_PATH=${ROOTFS_PATH}/lib/pkgconfig:$PKG_CONFIG_PATH
# export PKG_CONFIG_LIBDIR=${ROOTFS_PATH}/lib/:$PKG_CONFIG_LIBDIR
# export NFSROOT=${ROOTFS_PATH}
# make PREFIX=${NFSROOT} CC=${CROSS_COMPILE}gcc
# make PREFIX=${NFSROOT} CC=${CROSS_COMPILE}gcc install
====================================================================================================
3. How to use iw tool

Usually is commonly commands the following.

# iw wlan0 scan                     // Scan for Wifi network
# iw wlan0 connect            // Connect to specifc Access point (by its SSID)
# iw wlan0 disconnect               // Disconnect from the Access point that the Station is connected too   
# iw wlan0 link                     // Verify Link Status

For example as below:

# iw wlan0 scan
BSS 00:13:46:dd:e2:e9 (on wlan0)
TSF: 362449530606 usec (4d, 04:40:49)
freq: 2452
beacon interval: 100
capability: ESS Privacy ShortPreamble (0x0031)
    signal: -50.00 dBm
    last seen: 270 ms ago
    SSID: jjap
    Supported rates: 1.0* 2.0* 5.5* 11.0* 22.0 
    DS Parameter set: channel 9
    ERP: 
    Extended supported rates: 6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.

# iw wlan0 connect jjap keys 0:0397430202

# iw wlan0 link
Connected to 00:13:46:dd:e2:e9 (on wlan10)
SSID: jjap
freq: 2452
RX: 9400 bytes (96 packets)
TX: 0 bytes (0 packets)
    signal: -48 dBm
    tx bitrate: 1.0 MBit/s

    bss flags:      short-preamble
    dtim period:    3
    beacon int:     100

2/17/2012

Wlan driver of Jorjin SiP modules

if your use wlan modules for Jorjin, can reference my integrated of wlan driver in github.

The wlan driver will be supported WG7210, WG73x, WG75 modules,it running on the Linux 2.6.30 upon and Android GB/ICS.

So if your are interested, let us go ahead !

#################################################################
#

#   NLCP Version        : R4_12
#   Operation system    : Linux / Android
#   Date                       : Jan 2012
#   Mantainer               : Dicky Chiang
#
#################################################################

NLCP(Native Linux Communication Package) is open source with integrated for TI.

The wlan driver will to support WG72, WG73x, WG75x series of Jorjin SiP modules.

Dirver download site:

$ git clone git://github.com/dickychiang/compat-wireless-r4-12.git

========================================================================
1. How to build the driver

You can refer the script file "m.sh" for setting environment. For example:

# Export parameter
$ export ARCH=arm
$ export CROSS_COMPILE=
$ export KERNEL_PATH=
$ export KLIB=${KERNEL_PATH}
$ export KLIB_BUILD=${KERNEL_PATH}

# Compile it
$ make modules

========================================================================
2. Install .ko files

If you are compiled is completed, need to copy file ".ko" to your filesystem. Or reference the script file "cp.sh".

For example:

$ export ROOTFS=
$ cp compat/compat.ko ${ROOTFS}/lib/modules/
$ cp net/mac80211/mac80211.ko ${ROOTFS}/lib/modules
$ cp net/wireless/cfg80211.ko ${ROOTFS}/lib/modules

* WG72x
$ cp drivers/net/wireless/wl1251/*.ko ${ROOTFS}/lib/modules

* WG73x/WG75x
$ cp drivers/net/wireless/wl12xx/*.ko ${ROOTFS}/lib/modules

========================================================================
3. Firmware

Select your type of Jorjin SiP modules then to copy in filesystem.

For example:

$ cp jorjin/wg73x_fw/*.bin ${ROOTFS}/lib/firmware/ti-connectivity

========================================================================
4. Insert module

If boot in system, according to as below for insert module.

$ insmod compat.ko
$ insmod cfg80211.ko
$ insmod mac80211.ko

For your type.
$ insmod wl1251.ko
$ insmod wl1251_sdio.ko

********************************************
* Wireless Configuration (For Linux system)*
********************************************
----------------------------------------------------------------------------------------------------
IW commands are Linux based commands that are used as configuration utility for wireless devices.
IW commands also provide connection to WLAN devices however it is not supported advance security modes (supports Non secured networks and WEP only) therefore we normaly use that option for debug mode only while working without WPA supplicant.

IW commands is use 'nl80211' interface, so we need to install 'libnl' first then to support it.
----------------------------------------------------------------------------------------------------

1. Install libnl-2.0

First to download it:

$ git clone git://github.com/dickychiang/libnl-2.0.git

And export environment or can reference to script 'm.sh'

$ export ROOTFS_PATH=
$ export PATH=:$PATH
$ export CROSS_COMPILE=
$ ./configure --prefix=${ROOTFS}  CC=${CROSS_COMPILE}gcc --host=arm-linux LD=${CROSS_COMPILE}ld
$ make
$ make install
========================================================================
2. Install IW tool for wireless configuration

Download source code :

$ git clone git://github.com/dickychiang/iw-linux.git

Export environment or reference script 'm.sh' for compile.

$ export PKG_CONFIG_PATH=${ROOTFS_PATH}/lib/pkgconfig:$PKG_CONFIG_PATH
$ export PKG_CONFIG_LIBDIR=${ROOTFS_PATH}/lib/:$PKG_CONFIG_LIBDIR
$ export NFSROOT=${ROOTFS_PATH}
$ make PREFIX=${NFSROOT} CC=${CROSS_COMPILE}gcc
$ make PREFIX=${NFSROOT} CC=${CROSS_COMPILE}gcc install
========================================================================
3. How to using the iw tool

Usually, the following is commonly commands.

$ iw wlan0 scan                     // Scan for Wifi network
$ iw wlan0 connect           // Connect to specifc Access point (by its SSID)
$ iw wlan0 disconnect               // Disconnect from the Access point that the Station is connected too  
$ iw wlan0 link                     // Verify Link Status

For example as following:

$ iw wlan0 scan
BSS 00:13:46:dd:e2:e9 (on wlan0)
TSF: 362449530606 usec (4d, 04:40:49)
freq: 2452
beacon interval: 100
capability: ESS Privacy ShortPreamble (0x0031)
    signal: -50.00 dBm
    last seen: 270 ms ago
    SSID: jjap
    Supported rates: 1.0* 2.0* 5.5* 11.0* 22.0
    DS Parameter set: channel 9
    ERP:
    Extended supported rates: 6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.

$ iw wlan0 connect jjap keys 0:0397430202

$ iw wlan0 link
Connected to 00:13:46:dd:e2:e9 (on wlan10)
SSID: jjap
freq: 2452
RX: 9400 bytes (96 packets)
TX: 0 bytes (0 packets)
    signal: -48 dBm
    tx bitrate: 1.0 MBit/s

    bss flags:      short-preamble
    dtim period:    3
    beacon int:     100

1/05/2012

Porting to different the MMC interface


Author : Dicky Chiang
Date : Dec 2012

Introduce:
This document describes how to porting to a different the MMC interface.
All presentation will be based on the DM37x platform with Linux kernel 2.6.37 and NLCP WLAN driver.On Dm37x WLAN SDIO is connected to MMC2 bus. For example, the following will porting to MMC3 interface.

Step 1:
In file kernel/arch/arm/mach-omap2/board-omap3evm.c
Modify Initialization and pin-muxing if using any other MMC bus.
static struct omap2_hsmmc_info mmc[] = {
{
.mmc = 1,
.caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
.gpio_wp = 29,
},
#ifdef CONFIG_WL12XX_PLATFORM_DATA
{
.name = "wl1271",
.mmc = 3,
.caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
.gpio_wp = -EINVAL,
.gpio_cd = -EINVAL,
.nonremovable = true,
},
#endif
{} /* Terminator */
};
static struct omap_board_mux board_mux[] __initdata = {
#ifdef CONFIG_WL12XX_PLATFORM_DATA
/* WLAN IRQ - GPIO 112 */
OMAP3_MUX(CSI2_DX0, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
/* WLAN POWER ENABLE - GPIO 16 */
OMAP3_MUX(ETK_D2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
/* MMC3 SDIO pin muxes for WL12xx */
OMAP3_MUX(ETK_CLK, OMAP_MUX_MODE2 |
OMAP_PIN_INPUT_PULLUP),//CLK
OMAP3_MUX(ETK_CTL, OMAP_MUX_MODE2 |
OMAP_PIN_INPUT_PULLUP),//CMD
OMAP3_MUX(ETK_D3, OMAP_MUX_MODE2 |
OMAP_PIN_INPUT_PULLUP),//DATA3
OMAP3_MUX(ETK_D6, OMAP_MUX_MODE2 |
OMAP_PIN_INPUT_PULLUP),//DATA2
OMAP3_MUX(ETK_D5, OMAP_MUX_MODE2 |
OMAP_PIN_INPUT_PULLUP),//DATA1
OMAP3_MUX(ETK_D4, OMAP_MUX_MODE2 |
OMAP_PIN_INPUT_PULLUP),//DATA0
//USB gpio40
OMAP3_MUX(GPMC_A7, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT ),
#endif
{ .reg_offset = OMAP_MUX_TERMINATOR },
};

Modify regulator supply to register in kernel when the probe host MMC slot.
static struct regulator_consumer_supply panther_vmmc2_supply =
REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.2")


Step 2.
In file kernel/arch/arm/mach-omap2/devices.c
Add to supported MMC3 host controller at omap2_mmc_mux func.
/* For MMC3 the pins need to be muxed in the board-*.c files */
if (controller_nr == 2) {
/* MMC3 */
omap_mux_init_signal("sdmmc3_clk",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc3_cmd",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc3_dat0",
OMAP_PIN_INPUT_PULLUP);
/*
* For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
* in the board-*.c files
*/
if (mmc_controller->slots[0].caps &
(MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
omap_mux_init_signal("sdmmc3_dat1",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc3_dat2",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc3_dat3",
OMAP_PIN_INPUT_PULLUP);
}
if (mmc_controller->slots[0].caps &
MMC_CAP_8_BIT_DATA) {
omap_mux_init_signal("sdmmc3_dat4.sdmmc3_dat4",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc3_dat5.sdmmc3_dat5",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc3_dat6.sdmmc3_dat6",
OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("sdmmc3_dat7.sdmmc3_dat7",
OMAP_PIN_INPUT_PULLUP);
}
}


Step 3.
In file kernla/arch/arm/mach-omap2/mux34xx.c
Add the pin mux for support MMC3 interface. ( According the schematics and TRM)
static struct omap_mux __initdata omap3_muxmodes[] = {
……..
//MMC3_CLK
_OMAP3_MUXENTRY(ETK_CLK, 12,
"etk_clk", "mcbsp5_clkx", "sdmmc3_clk", "hsusb1_stp",
"gpio_12", "mm1_rxdp", "hsusb1_tll_stp", "hw_dbg0"),
//MMC3_CMD
_OMAP3_MUXENTRY(ETK_CTL, 13,
"etk_ctl", NULL, "sdmmc3_cmd", "hsusb1_clk",
"gpio_13", NULL, "hsusb1_tll_clk", "hw_dbg1"),
//MMC3_DATA0
_OMAP3_MUXENTRY(ETK_D4, 18,
"etk_d4", "mcbsp5_dr", "sdmmc3_data0", "hsusb1_data4",
"gpio_18", NULL, "hsusb1_tll_data4", "hw_dbg6"),
//MMC3_DATA1
_OMAP3_MUXENTRY(ETK_D5, 19,
"etk_d5", "mcbsp5_fsx", "sdmmc3_data1", "hsusb1_data5",
"gpio_19", NULL, "hsusb1_tll_data5", "hw_dbg7"),
//MMC3_DATA2
_OMAP3_MUXENTRY(ETK_D6, 20,
"etk_d6", "mcbsp5_dx", "sdmmc3_data2", "hsusb1_data6",
"gpio_20", NULL, "hsusb1_tll_data6", "hw_dbg8"),
//MMC3_DATA3
_OMAP3_MUXENTRY(ETK_D6, 17,
"etk_d3", "mcbspi3_clk", "sdmmc3_data3", "hsusb1_data7",
"gpio_17", NULL, "hsusb1_tll_data7", "hw_dbg5")
………..
}

Step 4.
In file u-boot/ti/evm/evm.h
Add the mux configuration for that pin at u-boot.
#define MUX_EVM() \
………
/* SDIO Interface to WIFI Module */ \
MUX_VAL(CP(ETK_CLK_ES2), (IEN | PTU | EN | M4)) /*MMC3_CLK*/\
MUX_VAL(CP(ETK_CTL_ES2), (IEN | PTU | EN | M4)) /*MMC3_CMD*/\
MUX_VAL(CP(ETK_D4_ES2), (IEN | PTU | EN | M4))/*MMC3_DATA0*/\
MUX_VAL(CP(ETK_D5_ES2), (IEN | PTU | EN | M4))/*MMC3_DATA1*/\
MUX_VAL(CP(ETK_D6_ES2), (IEN | PTU | EN | M4))/*MMC3_DATA2*/\
MUX_VAL(CP(ETK_D3_ES2), (IEN | PTU | EN | M4))/*MMC3_DATA3*/\
……..
#endif

Porting wg7210(WL1251) with Linux 2.6.37 on AM18


Below is port of wg7210 info for kernel 2.6.37 with Linux on the AM18 platform.

First, your can get patches and nlcp driver ( modifies to wg7210 ) with firmware 4.0.4.32 from my git.

kernel patches ( include firmware for wg7210 ):

$ git clone git://github.com/dickychiang/am18-wg7210-patch.git

compat-wireless-r4-11-wg7210 :

$ git clone git://github.com/dickychiang/compat-wireless-r4-11.git

The driver will support iw tool to configure wireless.

Also the porting of wg7210 need to take care to important the following :

a) wg7210 has inside the eeprom. To fill structure in wl12xx_platform_data of "use_eeprom".

In board-*.c file :


static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {                                                              

    .irq = -1,
    .board_ref_clock = CONFIG_DA850_MISTRAL_WL12XX_REFCLOCK,
    .platform_quirks = WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
    .use_eeprom = 1,
};

If already, in insert wl1251.ko module will be R/W to eeprom and create a network interface. ( Note, check the irq is work well and connected to EVB.)

And then insert wl1251_sdio.ko will be download firmware into chip.

wl1251: chip id 0x7020101 (1251 PG11)
wl1251: firmware booted (Rev 4.0.4.3.5)

b)  Since it the SDIO of CCCR,CIS,FBR is in not corrent. so kernel can not to get right information to match for wg7210. My ideas is give the card information to kernel such as vendor and device id which let kernel to know the sdio device is match to my sdio driver for wg7210.

In drivers/mmc/core/sdio.c :

b-1) Mark the read cccr,cis at mmc_sdio_init_card func.
                                                  
#ifndef CONFIG_WG7210                                                                                  
    err = sdio_read_cccr(card);                                                                        
    if (err)                                                                                                                          
        goto remove;                                                                                   
#endif                                                                                                 
                                                                                
#ifndef CONFIG_WG7210                                                                                  
    err = sdio_read_common_cis(card);                                                                  
    if (err)                                                                                           
        goto remove;                                                                                   
#endif

To fill the card''s maximum speed with clock. ( Default the value is get from cccr register )

#ifdef CONFIG_WG7210
    card->cis.max_dtr = 25000000;
#endif
    mmc_set_clock(host, mmc_sdio_get_max_clock(card));
b-2) Mark the read fbr and set the id's info to structure sdio_func at sdio_init_func.

#ifndef CONFIG_WG7210                                                                                  
    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;                                                   
    }                                                                                                  
#else                                                                                                  
    func->vendor = 0x104c;                                                                             
    func->device = 0x9066;                                                                             
    func->max_blksize = 4096;                                                                          
#endif  

Note, the max block size value is depend on mmc host controller, if not to match wii be failed in send CMD52.


c) Modify the download firmware path in nlcp driver :

In compat-wireless/drivers/net/wireless/wl1251/wl1251.h

#define WL1251_FW_NAME "ti-connectivity/wl1251-fw.bin"
#define WL1251_NVS_NAME "ti-connectivity/wl1251-nvs.bin"


d) If want to debug NLCP driver,do it to following. ( The method can used to wl12xx )

    look at compat-wireless/driver/net/wireless/wl1251/wl1251.h, you can find its.

enum {
    DEBUG_NONE  = 0,
    DEBUG_IRQ   = BIT(0),
    DEBUG_SPI   = BIT(1),
    DEBUG_BOOT  = BIT(2),
    DEBUG_MAILBOX   = BIT(3),
    DEBUG_NETLINK   = BIT(4),
    DEBUG_EVENT = BIT(5),
    DEBUG_TX    = BIT(6),
    DEBUG_RX    = BIT(7),
    DEBUG_SCAN  = BIT(8),
    DEBUG_CRYPT = BIT(9),
    DEBUG_PSM   = BIT(10),
    DEBUG_MAC80211  = BIT(11),
    DEBUG_CMD   = BIT(12),
    DEBUG_ACX   = BIT(13),
    DEBUG_ALL   = ~0,
};

#define DEBUG_LEVEL (DEBUG_NONE)

To modifies the DEBUG_LEVEL for you want to check the driver info. Suppose I wonder to see the BOOT and MAC80211 information :
 DEBUG_BOOT  = BIT(2)             =>    (1 << 2)  =  0x4
 DEBUG_MAC80211  = BIT(11)     =>   (1 << 11) =  0x800

so the answer :

#deinfe DEBUG_LEVEL   0x804

Re-build it now.   And then to entry the file system ( For example with Linux based ) and enable all kernel prints level.
echo 8 > /proc/sys/kernel/printk

Running daemon for print the kernel logs :

cat /proc/kmsg &

Your can see the debug message when insert wl1251.ko ( or wl12xx.ko ) and wl1251_sdio.ko ( or wl12xx_sdio.ko ).