https://community.freescale.com/thread/268362
(1)wifi based on BCM4329 module should be connected to sdio interface on i.mx51.
(2)Compile wifi driver from Broadcom and get a .ko file(such as dhd.ko).
(3)Open nvram.txt and modify crystal (for example, you use 38.4MHz on hardware,then xtalfreq=38400)
(4)copy dhd.ko to /opt/nfsroot/system/lib/modules
(5)copy sdio-bcm4329-dhd.bin(firmware) and nvram.txt to /opt/nfsroot/system/lib/modules
(6)enter ~/android22/kernel_imx/drivers/mmc/core and find sdio.c file
search whether there is the following function, if not , please search it on website(google)
int sdio_reset_comm(struct mmc_card *card)
{
}
{
}
EXPORT_SYMBOL(sido_reset_comm);
(7)configure linux kernel
a. choose Device driver-->Network driver support-->Wireless LAN
[*]Wireless Lan
[*]IEEE802.11 For Host AP
[*]Support downloading firmware images with host AP driver.
[*] Support for non-volatile firmware download
b.choose Networking support-->Wireless
[*] old wireless static regulatory definitions
[*] wireless extensions sysfs files
(8) load driver
#/system/bin/insmod /system/lib/modules/dhd.ko "firmware_path=/system/etc/wifi/sdio-bcm4329-dhd.bin
nvram_path=/system/etc/wifi/nvram.txt"
nvram_path=/system/etc/wifi/nvram.txt"
The following will display :
/#DHD: dongle ram size is set to 294912(orig 294912)
Firmware version = wl0: Aug 11 2010 13:21:15 version 4.218.243.1
eth1: Broadcom Dongle Host Driver mac=00:26:37:a4:f7:e7
Enter wl_control_wl_start
Exited wl_control_wl_start
Firmware version = wl0: Aug 11 2010 13:21:15 version 4.218.243.1
eth1: Broadcom Dongle Host Driver mac=00:26:37:a4:f7:e7
Enter wl_control_wl_start
Exited wl_control_wl_start
<-------How to debug wifi on linux command line -------------------->
customer can use "wireless-tools" to debug wifi network. this tool can be downloaded from internet. after compliling, some tools can be got :
frename iwconfig iwevent iwgetid iwlist iwpriv iwspy
**Use "iwconfig" to set AP ( router)
#iwconfig eth1 mode Managed
#iwconfig eth1 key 1234567890
#iwconfig eth1 key open
#iwconfig eth1 essid TP-LINK_432F1A
#iwconfig eth1 key 1234567890
#iwconfig eth1 key open
#iwconfig eth1 essid TP-LINK_432F1A
**Get DHCP Address
#/system/bin/dhcpcd eth1
**Search AP
#iwlist eth1 scan
Cell 01 - Address: 00:23:CD:43:2F:1A
ESSID:"TP-LINK_432F1A"
Cell 02 - Address: 00:23:CD:5D:56:66
ESSID:"TP-LINK_789"
ESSID:"TP-LINK_432F1A"
Cell 02 - Address: 00:23:CD:5D:56:66
ESSID:"TP-LINK_789"
******Customer can also use "wpa_supplicant" to test BCM4329"
A. Configure wpa_supplicant.conf file
Open /opt/nfsroot/system/etc/wifi/wpa_supplicant.conf and add the following lines:
ctrl_interface=DIR=/data/misc/wifi/wpa_supplicant GROUP=wifi
ap_scan=1
update_config=1
B. Run wpa_supplicant service by back
#/system/bin/wpa_supplicant -B -Dwext -ieth1 -c/data/misc/wifi/wpa_supplicant.conf
C. Run wpa_cli to connect AP
# wpa_cli –i eth1
>add_network
0
> set_network 0 ssid "TP-LINK_432F1A"
OK
> set_network 0 wep_key2 "1234567890"
OK
> enable_network 0
OK
>add_network
0
> set_network 0 ssid "TP-LINK_432F1A"
OK
> set_network 0 wep_key2 "1234567890"
OK
> enable_network 0
OK
>q
****************************For android2.2 based on i.mx51******************************
(1) Adjust init.rc file
At position "prepare for wifi", to add:
(1)在prepare for wifi 处添加目录并修改权限
setprop wifi.interface eth1
mkdir /data/misc/wifi/sockets 0777 wifi wifi
mkdir /data/misc/dhcp 0777 dhcp dhcp
mkdir /data/misc/wifi 0777 wifi wifi
mkdir /system/etc/wifi 0777 wifi wifi
mkdir /data/system/wpa_supplicant 0771 wifi wifi
mkdir /data/misc/wifi/wpa_supplicant 0771 wifi wifi
chmod 0777 /data/misc
chmod 0777 /data/misc/wifi
chmod 0777 /data/misc/wifi/wpa_supplicant.conf
chmod 0771 /system/etc/wifi
chmod 0777 /system/etc/wifi/wpa_supplicant.conf
chmod 0777 /data/system/wpa_supplicant
chmod 0777 /data/misc/wifi/wpa_supplicant
chmod 0777 /system/etc/dhcpcd
chmod 0777 /system/etc/dhcpcd/dhcpcd-hooks
chown wifi wifi data/system/wpa_supplicant
chown wifi wifi /system/etc/wifi/wpa_supplicant.conf
chown dhcp dhcp /data/misc/dhcp
chown wifi wifi /data/misc/wifi/wpa_supplicant
chown dhcp dhcp /system/etc/dhcpcd
chown dhcp dhcp /system/etc/dhcpcd/dhcpcd-hooks
setprop wifi.interface eth1
mkdir /data/misc/wifi/sockets 0777 wifi wifi
mkdir /data/misc/dhcp 0777 dhcp dhcp
mkdir /data/misc/wifi 0777 wifi wifi
mkdir /system/etc/wifi 0777 wifi wifi
mkdir /data/system/wpa_supplicant 0771 wifi wifi
mkdir /data/misc/wifi/wpa_supplicant 0771 wifi wifi
chmod 0777 /data/misc
chmod 0777 /data/misc/wifi
chmod 0777 /data/misc/wifi/wpa_supplicant.conf
chmod 0771 /system/etc/wifi
chmod 0777 /system/etc/wifi/wpa_supplicant.conf
chmod 0777 /data/system/wpa_supplicant
chmod 0777 /data/misc/wifi/wpa_supplicant
chmod 0777 /system/etc/dhcpcd
chmod 0777 /system/etc/dhcpcd/dhcpcd-hooks
chown wifi wifi data/system/wpa_supplicant
chown wifi wifi /system/etc/wifi/wpa_supplicant.conf
chown dhcp dhcp /data/misc/dhcp
chown wifi wifi /data/misc/wifi/wpa_supplicant
chown dhcp dhcp /system/etc/dhcpcd
chown dhcp dhcp /system/etc/dhcpcd/dhcpcd-hooks
(2)Modify wpa_supplicant and DHCP service
service wpa_supplicant /system/bin/logwrapper /system/bin/wpa_supplicant -d -B -Dwext -ieth1 -c/data/misc/wifi/wpa_supplicant.conf
user root
group wifi inet
socket wpa_eth1 dgram 777 wifi wifi
disable
oneshot
group wifi inet
socket wpa_eth1 dgram 777 wifi wifi
disable
oneshot
service dhcpcd /system/bin/logwrapper /system/bin/dhcpcd -d -B eth1
user root
group system dhcp wifi
disabled
oneshot
user root
group system dhcp wifi
disabled
oneshot
(3)modify HAL for wifi .
Open android/hardware/libhardware_legacy/wifi/wifi.c and add:
#ifndef WIFI_DRIVER_MODULE_PATH
#define WIFI_DRIVER_MODULE_PATH "/system/lib/modules/dhd.ko"
#endif
#ifndef WIFI_DRIVER_MODULE_NAME
#define WIFI_DRIVER_MODULE_PATH "/system/lib/modules/dhd.ko"
#endif
#ifndef WIFI_DRIVER_MODULE_NAME
#define WIFI_DRIVER_MODULE_NAME "dhd"
#endif
#ifndef WIFI_DRIVER_MODULE_ARG
#define WIFI_DRIVER_MODULE_ARG "firmware_path=/system/etc/wifi/sdio-bcm4329-dhd.bin
nvram_path=/system/etc/wifi/nvram.txt"
#endif
#ifndef WIFI_FIRMWARE_LOADER
#define WIFI_FIRMWARE_LOADER ""
#endif
#define WIFI_TEST_INTERFACE "eth1"
#define WIFI_DRIVER_LOADER_DELAY 5000000
#endif
#ifndef WIFI_DRIVER_MODULE_ARG
#define WIFI_DRIVER_MODULE_ARG "firmware_path=/system/etc/wifi/sdio-bcm4329-dhd.bin
nvram_path=/system/etc/wifi/nvram.txt"
#endif
#ifndef WIFI_FIRMWARE_LOADER
#define WIFI_FIRMWARE_LOADER ""
#endif
#define WIFI_TEST_INTERFACE "eth1"
#define WIFI_DRIVER_LOADER_DELAY 5000000
static const char IFACE_DIR[] = "/mywifi";/*这里填一个不存在的文件目录*/
static const char DRIVER_MODULE_NAME[] = WIFI_DRIVER_MODULE_NAME;
static const char DRIVER_MODULE_TAG[] = WIFI_DRIVER_MODULE_NAME " ";
static const char DRIVER_MODULE_PATH[] = WIFI_DRIVER_MODULE_PATH;
static const char DRIVER_MODULE_ARG[] = WIFI_DRIVER_MODULE_ARG;
static const char FIRMWARE_LOADER[] = WIFI_FIRMWARE_LOADER;
static const char DRIVER_PROP_NAME[] = "wlan.driver.status";
static const char SUPPLICANT_NAME[] = "wpa_supplicant";
static const char SUPP_PROP_NAME[] = "init.svc.wpa_supplicant";
static const char SUPP_CONFIG_TEMPLATE[]= "/system/etc/wifi/wpa_supplicant.conf";
static const char SUPP_CONFIG_FILE[] = "/data/misc/wifi/wpa_supplicant.conf";
static const char MODULE_FILE[] = "/proc/modules";
static const char DRIVER_MODULE_NAME[] = WIFI_DRIVER_MODULE_NAME;
static const char DRIVER_MODULE_TAG[] = WIFI_DRIVER_MODULE_NAME " ";
static const char DRIVER_MODULE_PATH[] = WIFI_DRIVER_MODULE_PATH;
static const char DRIVER_MODULE_ARG[] = WIFI_DRIVER_MODULE_ARG;
static const char FIRMWARE_LOADER[] = WIFI_FIRMWARE_LOADER;
static const char DRIVER_PROP_NAME[] = "wlan.driver.status";
static const char SUPPLICANT_NAME[] = "wpa_supplicant";
static const char SUPP_PROP_NAME[] = "init.svc.wpa_supplicant";
static const char SUPP_CONFIG_TEMPLATE[]= "/system/etc/wifi/wpa_supplicant.conf";
static const char SUPP_CONFIG_FILE[] = "/data/misc/wifi/wpa_supplicant.conf";
static const char MODULE_FILE[] = "/proc/modules";
(4) modify android/device/fsl/imx51_bbg/BoardConfig.mk file
BOARD_WPA_SUPPLICANT_DRIVER := WEXT
HAVE_CUSTOM_WIFI_DRIVER_2 :=false
WIFI_DRIVER_MODULE_PATH := /system/lib/modules/dhd.ko
WIFI_DRIVER_MODULE_NAME :=”dhd”
WIFI_DRIVER_MODULE_ARG :=”firmware_path=/system/etc/wifi/ sdio-bcm4329-dhd.bin nvram_path=/system/etc/wifi/nvram.txt”
HAVE_CUSTOM_WIFI_DRIVER_2 :=false
WIFI_DRIVER_MODULE_PATH := /system/lib/modules/dhd.ko
WIFI_DRIVER_MODULE_NAME :=”dhd”
WIFI_DRIVER_MODULE_ARG :=”firmware_path=/system/etc/wifi/ sdio-bcm4329-dhd.bin nvram_path=/system/etc/wifi/nvram.txt”
(5)modify frameworks/base/wifi/java/android/net/wifi/WifiStateTracker.java file
mInterfaceName = SystemProperties.get("wifi.interface", "tiwlan0");
>>mInterfaceName = SystemProperties.get("wifi.interface", "eth1");
(6)modify android/build/target/board/generic/system.prop
add : wifi.interfae=eth1
(7)modify android/external/wpa_supplicant/wpa_supplicant.conf :
ctrl_interface=eth1
update_config=1
ap_scan=1
(8) configure AP and delete password .
(9) compile android source code.
(10) That is ok.
Maybe it seems very complex , acturally it is not difficult.
==============
search whether there is the following function, if not , please search it on website(google)
int sdio_reset_comm(struct mmc_card *card)
==>
- Diff rendering mode:
- inline
- side by side
1219 | 1219 | ||
1220 | 1220 | return err; | |
1221 | 1221 | } | |
1222 | |||
1223 | int sdio_reset_comm(struct mmc_card *card) | ||
1224 | { | ||
1225 | struct mmc_host *host = card->host; | ||
1226 | u32 ocr; | ||
1227 | int err; | ||
1228 | |||
1229 | printk("%s():\n", __func__); | ||
1230 | mmc_go_idle(host); | ||
1231 | |||
1232 | mmc_set_clock(host, host->f_min); | ||
1233 | |||
1234 | err = mmc_send_io_op_cond(host, 0, &ocr); | ||
1235 | if (err) | ||
1236 | goto err; | ||
1237 | |||
1238 | host->ocr = mmc_select_voltage(host, ocr); | ||
1239 | if (!host->ocr) { | ||
1240 | err = -EINVAL; | ||
1241 | goto err; | ||
1242 | } | ||
1243 | |||
1244 | err = mmc_send_io_op_cond(host, host->ocr, &ocr); | ||
1245 | if (err) | ||
1246 | goto err; | ||
1247 | |||
1248 | if (mmc_host_is_spi(host)) { | ||
1249 | err = mmc_spi_set_crc(host, use_spi_crc); | ||
1250 | if (err) | ||
1251 | goto err; | ||
1252 | } | ||
1253 | |||
1254 | if (!mmc_host_is_spi(host)) { | ||
1255 | err = mmc_send_relative_addr(host, &card->rca); | ||
1256 | if (err) | ||
1257 | goto err; | ||
1258 | mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL); | ||
1259 | } | ||
1260 | if (!mmc_host_is_spi(host)) { | ||
1261 | err = mmc_select_card(card); | ||
1262 | if (err) | ||
1263 | goto err; | ||
1264 | } | ||
1265 | |||
1266 | mmc_set_clock(host, card->cis.max_dtr); | ||
1267 | err = sdio_enable_wide(card); | ||
1268 | if (err) | ||
1269 | goto err; | ||
1270 | |||
1271 | return 0; | ||
1272 | err: | ||
1273 | printk("%s: Error resetting SDIO communications (%d)\n", | ||
1274 | mmc_hostname(host), err); | ||
1275 | return err; | ||
1276 | } | ||
1277 | EXPORT_SYMBOL(sdio_reset_comm); |
沒有留言:
張貼留言