Marvell 88w8686 SDIO wifi

http://yk8900.blog.163.com/blog/static/123183544201099115355124/     

             How to setup Marvell 88w8686 SDIO wifi

Overview of How-To

This How-To is meant to be a starting point for people to learn setup the wifi on IGEP v2 devices as quickly and easily as possible.

Feedback and Contributing

At any point, if you see a mistake you can contribute to this How-To.

Setup basics

SDIO card should be showed after the image is downloaded to the board.

mmc1: new SDIO card at address 0001

The firmware binaries sd8686_helper.bin and sd8686.bin should be in /lib/firmware directory.

To make the SDIO WIFI module work load the libertas_sdio module

# modprobe libertas_sdio

libertas_sdio: Libertas SDIO driver
libertas_sdio: Copyright Pierre Ossman
libertas_sdio mmc1:0001:1: firmware: requesting sd8686_helper.bin
libertas_sdio mmc1:0001:1: firmware: requesting sd8686.bin
libertas: 00:13:e0:c3:0c:3c, fw 9.70.3p24, cap 0x00000303
libertas: unidentified region code; using the default (USA)
libertas: PREP_CMD: command 0x00a3 failed: 2
libertas: PREP_CMD: command 0x00a3 failed: 2
libertas: eth1: Marvell WLAN 802.11 adapter

Now you can connect this wifi module to an AP. First of all, you'll check if your devices is detected.

# iwconfig

eth1 IEEE 802.11b/g ESSID:""
Mode:Managed Frequency:2.412 GHz Access Point: Not-Associated
Bit Rate:0 kb/s Tx-Power=18 dBm
Retry short limit:8 RTS thr=2347 B Fragment thr=2346 B
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

Next, you will set up the interface

# ifconfig eth1 up

eth1 Link encap:Ethernet HWaddr 00:13:E0:C3:0C:3C
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)

and you can scan for an AP

# iwlist eth1 scan

Cell 04 - Address: 00:18:84:81:46:E2
ESSID:"MyPlace"
Mode:Managed
Frequency:2.427 GHz (Channel 4)
Quality=100/100 Signal level=-39 dBm Noise level=-96 dBm
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s
11 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s

Now, is time to associate to your AP

# iwconfig eth1 txpower auto essid MyPlace channel 4

eth1 IEEE 802.11b/g ESSID:"MyPlace"
Mode:Managed Frequency:2.427 GHz Access Point: 00:18:84:81:46:E2
Bit Rate:0 kb/s Tx-Power=13 dBm
Retry short limit:8 RTS thr=2347 B Fragment thr=2346 B
Encryption key:off
Power Management:off
Link Quality=97/100 Signal level=-43 dBm Noise level=-94 dBm
Rx invalid nwid:0 Rx invalid crypt:3109 Rx invalid frag:0
Tx excessive retries:13 Invalid misc:3315 Missed beacon:0

and get and ip address

# udhcpc -i eth1
udhcpc (v1.9.1) started
Sending discover...
Sending select for 192.168.10.216...
Lease of 192.168.10.216 obtained, lease time 43200
adding dns 192.168.10.1

Last, you can test the network interface.

# ping -c 1 192.168.10.1

PING 192.168.10.1 (192.168.10.1): 56 data bytes
64 bytes from 192.168.10.1: seq=0 ttl=64 time=16.327 ms

--- 192.168.10.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 16.327/16.327/16.327 ms

How to debug the libertas driver

From: http://wiki.laptop.org/go/Libertas_Debug

To enable debug on the wireless (libertas) driver you may write to the libertas_debug '/sys' file:

echo LBS_DEBUG_FLAGS > /sys/module/libertas/parameters/libertas_debug

You can calculate the value for LBS_DEBUG_FLAGS using the table bellow (just add up the values for the flags you want to activate).

Debug Flag NameFlag Hex valueDescription(*)
LBS_DEB_ENTER 0x00000001 function entrance
LBS_DEB_LEAVE 0x00000002 function exit
LBS_DEB_MAIN 0x00000004 main libertas library code
LBS_DEB_NET 0x00000008 interaction with network subsystem
LBS_DEB_MESH 0x00000010 wireless mesh network
LBS_DEB_WEXT 0x00000020 interaction with wireless extensions
LBS_DEB_IOCTL 0x00000040 misc IOCTLs
LBS_DEB_SCAN 0x00000080 scanning for APs
LBS_DEB_ASSOC 0x00000100 associating ton an AP
LBS_DEB_JOIN 0x00000200 joining an IBSS?
LBS_DEB_11D 0x00000400 802.11d country settings
LBS_DEB_DEBUGFS 0x00000800 interaction with the debugfs subsystem
LBS_DEB_ETHTOOL 0x00001000 interaction with ethtool subsystem
LBS_DEB_HOST 0x00002000 communication between host and wlan chip
LBS_DEB_CMD 0x00004000 command and response processing
LBS_DEB_RX 0x00008000 packet reception
LBS_DEB_TX 0x00010000 packet transmission
LBS_DEB_USB 0x00020000 interaction with USB subsystem
LBS_DEB_CS 0x00040000 interaction with card services subsystem
LBS_DEB_FW 0x00080000 firmware downloading
LBS_DEB_THREAD 0x00100000 main libertas worker thread
LBS_DEB_HEX 0x00200000 turn on detailed hex dumps
LBS_DEB_SDIO 0x00400000 interaction with SDIO subsystem
(*) Description taken from lbsdebug.c (by Holger Schurig)


Example:
To activate scanning (LBS_DEB_SCAN), associating (LBS_DEB_ASSOC), command (LBS_DEB_CMD) and host (LBS_DEB_HOST):

echo 0x6180 > /sys/module/libertas/parameters/libertas_debug

The output will be post to the kernel ring buffer. You can display it with the dmesg command:

dmesg

You can also use the lbsdebug tool, from Holger Shurig, git tree available here.

1. 前言

   硬件平臺: imx27+sd8686

       軟件平臺: linux

       內核: 2.6.19.2

2. 移植思想

1, WIFI 模塊本身和 cpu 之間的接口;

       我們的模塊和 cpu 之間的接口是 sdio 的,也就是說必須要先保證 SDIO 本身是工作的,與SD卡,MMC屬於同類型。 主要用到這幾個GPIO引腳SD0...SD3,SD2_CMD,SD2_CLK,以及復位引腳PB24.

2, WIFI 模塊本身的上電時序;

       模塊都有它自己的規律,所以必須要根據 spec 瞭解它本身的上電過程,嚴格遵守;

3, 以太網接口的創建;

       我們的 WIFI 模塊本身是建立在 SDIO 口之上的,而對上都是提供以太網接口的,所以必須要保證這個接口以及創建;

4, 特殊處理;

       不同的模塊都有它特別的地方,比如我們用的是 8686  compo 也就是說它和藍牙共用天線,所以需要在初始化的時候做特殊的處理,發送特殊的命令,才能工作;

3. 移植過程

1, sdio 本身是通過 gpio 口模擬的,所以需要對 gpio 口進行配置 

       static mfp_cfg_t littleton_mmc3_pins[] = {

       GPIO7_2_MMC3_DAT0,

       GPIO8_2_MMC3_DAT1,

       GPIO9_2_MMC3_DAT2,

       GPIO10_2_MMC3_DAT3,

       GPIO103_MMC3_CLK,

       GPIO105_MMC3_CMD,

       };

  2, wifi 模塊本身的初始化 

#define MFP_WIFI_V18_ENABLE     (GPIO26_GPIO)

#define MFP_WLAN_RESETN                  (GPIO99_GPIO)

#define WIFI_WAKEUP_HOST          (GPIO104_GPIO) /*error must be changed*/

#define WLAN_ENABLE_PIN          26

#define WLAN_RESET_PIN            99

 

#define M200_B

#ifdef M200_B

#define BT_RESET_PIN                 EXT1_GPIO(1)

#define BT_RESET_GPIO           (GPIO1_2_GPIO)

#else

#define BT_RESET_GPIO                  (GPIO6_2_GPIO)

#define BT_RESET_PIN                 EXT1_GPIO(6)

#endif

 

static mfp_cfg_t lin2008_wifibt_pins[] = {

MFP_WIFI_V18_ENABLE,

MFP_WLAN_RESETN,

WIFI_WAKEUP_HOST,/*wakeup host*/

};

static mfp_cfg_t lin2008_wifibt_pins2[] = {

MFP_WIFI_V18_ENABLE,

};

static int wifibt_power_status;

int lin2008_poweron_wifibt_board(void)

{

       if (!wifibt_power_status) {

              mxc_mfp_config(ARRAY_AND_SIZE(lin2008_wifibt_pins));

                               

              gpio_direction_output(WLAN_ENABLE_PIN, 1);

              gpio_direction_output(WLAN_RESET_PIN, 1);

                  gpio_direction_output(BT_RESET_PIN,1);

              mdelay(10);

                  gpio_direction_output(BT_RESET_PIN, 0);

                  gpio_direction_output(WLAN_RESET_PIN, 0);

 

       // bt need > 5 ms to reset

                  mdelay(5);

                  gpio_direction_output(BT_RESET_PIN, 1);

                  gpio_direction_output(WLAN_RESET_PIN, 1);

 

              wifibt_power_status++;

              return 0;

       }

       wifibt_power_status++;

       return 1;

}

 

 

 

int lin2008_poweroff_wifibt_board(void)

{

       wifibt_power_status--;

       if (!wifibt_power_status) {

              mxc_mfp_config(ARRAY_AND_SIZE(lin2008_wifibt_pins2));

              gpio_direction_output(WLAN_ENABLE_PIN, 0);

              return 0;

       }

       return 1;

}

3, 以太網接口的創建

       這裏在 android 平臺上要做特殊的處理,也就是 firmware 的位置要放好,否則加載 firmware 始終不成功,那麼以太網接口就不會被創建了;

       需要把 helper_sd.bin 放在 /lib/firmware/mrvl 下面(若沒有,則創建一個);

        sd8686.bin 放在 /lib/firmware/mrvl 下面(同上);

4, 特殊的處理

       對於 8686 模塊需要做特殊的處理,在註冊完以太網接口以後,需要添加下面這段話 :

       {

     #define BCA_CFG_NUM_OF_MODES          4

     #define BCA_CFG_SINGLE_ANT_WITH_COEX      0

     #define BCA_CFG_DUAL_ANT_WITH_COEX    1

     #define BCA_CFG_SINGLE_ANT_FOR_BT_ONLY    2

     #define BCA_CFG_MRVL_DEFAULT          3

     #define BCA_CONFIG BCA_CFG_SINGLE_ANT_WITH_COEX

     static u32 BCACfgTbl[BCA_CFG_NUM_OF_MODES][3] = {

       //0xA5F0,     0xA58C, 0xA5A0

       { 0xa027181c, 0x40214, 0xd24d}, //Mode 0: Single ANT with COEX enable

       { 0xa027181c, 0x40211, 0xd24d}, //Mode 1: Dual ANT with COEX enable

       { 0xa027181c, 0x40222, 0xd21c}, //Mode 2: single ANT for BT only

       { 0xa027801d, 0x18000, 0xd21c}, //Mode 3: Marvell default

     };

    

     wlan_offset_value    RegBuffer;    

    

     RegBuffer.offset = (0xA5F0);

     RegBuffer.value = BCACfgTbl[BCA_CONFIG][0];

    wlan_prepare_cmd(priv,

                     HostCmd_CMD_MAC_REG_ACCESS,

                     HostCmd_ACT_GEN_SET,

                     HostCmd_OPTION_WAITFORRSP,

                     0,&RegBuffer);

     RegBuffer.offset =(0xA58C);

     RegBuffer.value = BCACfgTbl[BCA_CONFIG][1];

     wlan_prepare_cmd(priv,

                     HostCmd_CMD_MAC_REG_ACCESS,

                     HostCmd_ACT_GEN_SET,

                     HostCmd_OPTION_WAITFORRSP,

                     0,&RegBuffer);

     RegBuffer.offset = (0xA5A0);

     RegBuffer.value = BCACfgTbl[BCA_CONFIG][2];

     wlan_prepare_cmd(priv,

                     HostCmd_CMD_MAC_REG_ACCESS,

                     HostCmd_ACT_GEN_SET,

                     HostCmd_OPTION_WAITFORRSP,

                     0,&RegBuffer);

}

基本上這樣就可以工作了;

4.              其它問題

              Sdio 口默認是用的 3.2V 這裏需要修改相關的地方強制設成是 1.8V ,否則 SDIO 接口將無法工作;

              Linux平臺上需要移植一些上層軟件才能驗證,比如 iwconfig  iwlist 等。

       測試步驟:

                ifconfig eth0 up

              iwlist eth0 scanning

              如果能掃描到 AP 那麼證明基本已經 OK 了;

               iwconfig eth0

              iwlist eth0 freq

               可以查看設備的相關信息,查看各項是否正常。

              現在,就可以 ping  IP 地址了;

5. 常見問題

1, WIFI 驅動註冊 sdio 驅動的時候出錯,也就是 probe 函數未被調用?

       需要檢查 sdio 設備本身是否被檢測到,內核是通過發送特定的命令來檢測是 sdio  SD 卡還是 mmc的,

        mmc_rescan 函數裏面可以看到 sdio 設備的加載過程,有可能就是你的電壓設置不對;

2, 以太網接口一直出不來或者說 firmware 加載失敗?

       這裏需要確保 firmware 是否正確被加載,很可能是它找不到對應的 firmware ,可以通過添加打印信息看看,它的路徑到底是在什麼地方,對於 wifi 來說 helper_sd.bin 需要放在 /lib/firmware/ 下面,而 sd8686.bin需要放在 /lib/firmware/mrvl 下面;

3, 一切正常,但是調用 iwlist eth0 scanning 的時候,掃描不到任何結果,出現NO scan results?

       這時候需要做特殊的處理,比如共存代碼的設置,是否正常等,通常可以判斷有沒有中斷上來,以此區分到底是模塊和 cpu 的連接問題還是模塊本身的設置問題;

/sbin/insmod sdio.ko
/sbin/insmod sd8686.ko
/sbin/ifconfig eth1 up
/bin/iwpriv eth1 setregioncode 0x30
/bin/iwlist eth1 scan
/bin/iwconfig eth1 mode managed
/bin/iwconfig eth1 key 1213141516171819101a1b1c1d
/bin/iwconfig eth1 key on
/bin/iwconfig eth1 ap 00:73:07:14:DA:67
/sbin/ifconfig eth1 192.168.1.26

4, 工作一段時間後不正常

       這個有可能是藍牙模塊需要進行初始化,因爲它們是共用天線,有時候不起藍牙模塊對應的 40M 時鐘就不起來;

本人蔘照:http://blog.chinaunix.net/u2/67984/showart_2113942.html 此博客而移植成功的。


Android移植之WIFI

1. 前言

   硬件平臺: marvel 310

       軟件平臺: maemo4

       內核: 2.6.28 (經過 marvel 的移植)

2. 移植思想

1,  WIFI 模塊本身和 cpu 之間的接口;

       我們的模塊和 cpu 之間的接口是 sdio 的,也就是說必須要先保證 SDIO 本身是工作的;

2,  WIFI 模塊本身的上電時序;

       模塊都有它自己的規律,所以必須要根據 spec 瞭解它本身的上電過程,嚴格遵守;

3,  以太網接口的創建;

       我們的 WIFI 模塊本身是建立在 SDIO 口之上的,而對上都是提供以太網接口的,所以必須要保證這個接口以及創建;

4,  特殊處理;

       不同的模塊都有它特別的地方,比如我們用的是 8686  compo 也就是說它和藍牙共用天線,所以需要在初始化的時候做特殊的處理,發送特殊的命令,才能工作;

3. 移植過程

1,  sdio 本身是通過 gpio 口模擬的,所以需要對 gpio 口進行配置 

       static mfp_cfg_t littleton_mmc3_pins[] = {

       GPIO7_2_MMC3_DAT0,

       GPIO8_2_MMC3_DAT1,

       GPIO9_2_MMC3_DAT2,

       GPIO10_2_MMC3_DAT3,

       GPIO103_MMC3_CLK,

       GPIO105_MMC3_CMD,

       };

       void pxa3xx_enable_mmc3_pins(void)

{

       pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mmc3_pins));

}

        littleton_init ()函數裏面添加下面這一行:

       pxa3xx_enable_mmc3_pins();

2,  wifi 模塊本身的初始化 

#define MFP_WIFI_V18_ENABLE     (GPIO26_GPIO)

#define MFP_WLAN_RESETN                  (GPIO99_GPIO)

#define WIFI_WAKEUP_HOST          (GPIO104_GPIO) /*error must be changed*/

#define WLAN_ENABLE_PIN          26

#define WLAN_RESET_PIN            99

 

#define M200_B

#ifdef M200_B

#define BT_RESET_PIN                 EXT1_GPIO(1)

#define BT_RESET_GPIO             (GPIO1_2_GPIO)

#else

#define BT_RESET_GPIO                  (GPIO6_2_GPIO)

#define BT_RESET_PIN                 EXT1_GPIO(6)

#endif

 

static  mfp_cfg_t lin2008_wifibt_pins[] = {

MFP_WIFI_V18_ENABLE,

MFP_WLAN_RESETN,

WIFI_WAKEUP_HOST,/*wakeup host*/

};

static  mfp_cfg_t lin2008_wifibt_pins2[] = {

MFP_WIFI_V18_ENABLE,

};

static int wifibt_power_status;

int lin2008_poweron_wifibt_board(void)

{

       if (!wifibt_power_status) {

              pxa3xx_mfp_config(ARRAY_AND_SIZE(lin2008_wifibt_pins));

                               

              gpio_direction_output(WLAN_ENABLE_PIN, 1);

              gpio_direction_output(WLAN_RESET_PIN, 1);

                  gpio_direction_output(BT_RESET_PIN,1);

              mdelay(1);

                  gpio_direction_output(BT_RESET_PIN, 0);

                  gpio_direction_output(WLAN_RESET_PIN, 0);

 

       // bt need > 5 ms to reset

                  mdelay(5);

                  gpio_direction_output(BT_RESET_PIN, 1);

                  gpio_direction_output(WLAN_RESET_PIN, 1);

 

              wifibt_power_status++;

              return 0;

       }

       wifibt_power_status++;

       return 1;

}

 

 

 

int lin2008_poweroff_wifibt_board(void)

{

       wifibt_power_status--;

       if (!wifibt_power_status) {

              pxa3xx_mfp_config(ARRAY_AND_SIZE(lin2008_wifibt_pins2));

              gpio_direction_output(WLAN_ENABLE_PIN, 0);

              return 0;

       }

       return 1;

}

3, 以太網接口的創建

       這裏在 android 平臺上要做特殊的處理,也就是 firmware 的位置要放好,否則加載 firmware 始終不成功,那麼以太網接口就不會被創建了;

       需要把 helper_sd.bin 放在 /etc/firmware/ 下面;

        sd8686.bin 放在 /etc/firmware/mrvl 下面;

4, 特殊的處理

       對於 8686 模塊需要做特殊的處理,在註冊完以太網接口以後,需要添加下面這段話 :

       {

     #define BCA_CFG_NUM_OF_MODES          4

     #define BCA_CFG_SINGLE_ANT_WITH_COEX      0

     #define BCA_CFG_DUAL_ANT_WITH_COEX    1

     #define BCA_CFG_SINGLE_ANT_FOR_BT_ONLY    2

     #define BCA_CFG_MRVL_DEFAULT          3

 

     #define BCA_CONFIG BCA_CFG_SINGLE_ANT_WITH_COEX

     static u32 BCACfgTbl[BCA_CFG_NUM_OF_MODES][3] = {

       //0xA5F0,     0xA58C,  0xA5A0

       { 0xa027181c, 0x40214, 0xd24d}, //Mode 0: Single ANT with COEX enable

       { 0xa027181c, 0x40211, 0xd24d}, //Mode 1: Dual ANT with COEX enable

       { 0xa027181c, 0x40222, 0xd21c}, //Mode 2: single ANT for BT only

       { 0xa027801d, 0x18000, 0xd21c}, //Mode 3: Marvell default

     };

    

     wlan_offset_value    RegBuffer;    

    

     RegBuffer.offset = (0xA5F0);

     RegBuffer.value  = BCACfgTbl[BCA_CONFIG][0];

      wlan_prepare_cmd(priv,

                     HostCmd_CMD_MAC_REG_ACCESS,

                     HostCmd_ACT_GEN_SET,

                     HostCmd_OPTION_WAITFORRSP,

                     0,&RegBuffer);

 

     RegBuffer.offset =(0xA58C);

     RegBuffer.value  = BCACfgTbl[BCA_CONFIG][1];

     wlan_prepare_cmd(priv,

                     HostCmd_CMD_MAC_REG_ACCESS,

                     HostCmd_ACT_GEN_SET,

                     HostCmd_OPTION_WAITFORRSP,

                     0,&RegBuffer);

 

 

     RegBuffer.offset = (0xA5A0);

     RegBuffer.value  = BCACfgTbl[BCA_CONFIG][2];

     wlan_prepare_cmd(priv,

                     HostCmd_CMD_MAC_REG_ACCESS,

                     HostCmd_ACT_GEN_SET,

                     HostCmd_OPTION_WAITFORRSP,

                     0,&RegBuffer);

}

基本上這樣就可以工作了;

4.              其它問題

              Sdio 口默認是用的 3.2V 這裏需要修改相關的地方強制設成是 1.8V ,否則 SDIO 接口將無法工作;

              Android 平臺上需要移植一些上層軟件才能驗證,比如 iwconfig  iwlist  wpa_supplicant 等。

       測試步驟:

              iwlist mlan0 scan

              如果能掃描到 AP 那麼證明基本已經 OK 了;

              wpa_supplicant -Dwext –imlan0 -c/etc/wpa.conf &

              dhcpcd mlan0 

              這樣的話,就可以 ping  IP 地址了;

5. 常見問題

1,  WIFI 驅動註冊 sdio 驅動的時候出錯,也就是 probe 函數未被調用?

       需要檢查 sdio 設備本身是否被檢測到,內核是通過發送特定的命令來檢測是 sdio 還是 SD 卡還是mmc 的,

        mmc_rescan 函數裏面可以看到 sdio 設備的加載過程,有可能就是你的電壓設置不對;

2,  以太網接口一直出不來或者說 firmware 加載失敗?

       這裏需要確保 firmware 是否正確被加載,很可能是它找不到對應的 firmware ,可以通過添加打印信息看看,它的路徑到底是在什麼地方,對於 wifi 來說 helper_sd.bin 需要放在 /etc/firmware/ 下面,而sd8686.bin 需要放在 /etc/firmware/mrvl 下面;

3,  一切正常,但是調用 iwlist mlan0 scan 的時候,掃描不到任何結果?

       這時候需要做特殊的處理,比如共存代碼的設置,是否正常等,通常可以判斷有沒有中斷上來,以此區分到底是模塊和 cpu 的連接問題還是模塊本身的設置問題;

4,  工作一段時間後不正常

       這個有可能是藍牙模

發佈了84 篇原創文章 · 獲贊 2 · 訪問量 23萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章