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
- libertas: Marvell Libertas 8385/8686/8688 SDIO 802.11b/g card
- firmware: 9.70.3p24 ( download from )
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:
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 Name |
Flag Hex value |
Description(*) |
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 (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 .
Retrieved from ""
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, 工作一段时间后不正常
这个有可能是蓝牙模块需要进行初始化,因为它们是共用天线,有时候不起蓝牙模块对应的 40M 时钟就不起来;