最近一段时间移植了ralink 2070的驱动到Android上面,网上虽然有ralink的移植文章,但是我按照步骤移植,还是出现了一些问题,比如识别不到网卡,搜不到网络等问题,所以我把移植的大概步骤记录下来,用于以后查询,下面就是大概的移植步骤
1 在ralink官网下载驱动2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO源码,
需要在rtusb_dev_id.c的数组里面rtusb_dev_id[]里面增加{USB_DEVICE(0x148F,0x2070)},不然会造成加载驱动的时候识别不到设备,
因为USB驱动识别是根据idVendor和idProduct来识别设备的,2070的设备号为idVendor=148f, idProduct=2070。
进入根目录修改makefile,选择CHIPSET = 3070,PLATFORM = 5VT,设置交叉编译环境
ifeq ($(PLATFORM),5VT)
LINUX_SRC = /home/Ubuntu/tcc8902/android/kernel
CROSS_COMPILE = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-
endif
需要修改/os/linux/config.mk
HAS_WPA_SUPPLICANT=y
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
EXTRA_CFLAGS :
-D__LINUX_ARM_ARCH__=6
-march=armv6
-mtune=arm1176jzf-s
还需要去掉-mabi=apcs-gnu选项,不然会造成加载驱动死机重启,网上的一篇移植文章有提到。
2 编译好rt3070sta.ko,将其放到/system/lib/modules/目录下面,还有就是需要将官方提供的RT2870STA.dat拷贝到/etc/Wireless/RT2870STA/供驱动使用
3 由于tcc8900默认的wifi模块是atheros,所以我还修改了wifi_atheros.c的int wifi_load_driver()函数
int wifi_load_driver()
{
char driver_status[PROPERTY_VALUE_MAX];
int count = 100; /* wait at most 20 seconds for completion */
if (check_driver_loaded()) {
return 0;
}
if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0)
return -1;
if (strcmp(FIRMWARE_LOADER,"") == 0) {
usleep(WIFI_DRIVER_LOADER_DELAY);
property_set(DRIVER_PROP_NAME, "ok");
}
else {
property_set("ctl.start", FIRMWARE_LOADER);
}
sched_yield();
while (count-- > 0) {
if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
if (strcmp(driver_status, "ok") == 0)
return 0;
else if (strcmp(DRIVER_PROP_NAME, "failed") == 0) {
wifi_unload_driver();
LOGE("DRIVER_PROP_NAME failed");
//property_set(DRIVER_PROP_NAME, "ok");
return -1;
}
}
usleep(200000);
}
property_set(DRIVER_PROP_NAME, "timeout");
wifi_unload_driver();
return -1;
}
这里有一个问题需要注意,就是static const char IFACE_DIR[]= "/data/system/wpa_supplicant";这里的路径一定要和wpa_supplicant.conf里面的
ctrl_interface=DIR=/data/system/wpa_supplicant相同,不然会造成"/data/system/wpa_supplicant/ra0": No such file or directory这个错误,这个问题困扰我了很久,
权限问题也会引起这个问题。
4 需要更改init.rc文件,里面需要更改权限问题,
chmod 0777 /system/etc/wifi/wpa_supplicant.conf
chown wifi wifi /system/etc/wifi/wpa_supplicant.conf
mkdir /data/misc/wifi/wapi_certificate 0777 wifi wifi
mkdir /data/misc/dhcp 0777 dhcp dhcp
chown dhcp dhcp /data/misc/dhcp
mkdir /data/misc/wifi/sockets 0777 wifi wifi
mkdir /data/misc/wifi/wpa_supplicant 0777 wifi wifi
mkdir /data/misc/wifi/hostapd 0777 wifi wifi
mkdir /data/misc/wifi 0777 wifi wifi
setprop wifi.interface ra0
setprop wlan.driver.script "wifi_sta_up.sh"
setprop wlan.driver.path "/system/wifi"
chmod 0777 /data/misc/wifi
chmod 0777 /data/misc/wifi/wpa_supplicant.conf
chown wifi wifi /data/misc/wifi
chown wifi wifi /data/misc/wifi/wpa_supplicant.conf
chown wifi wifi /system/etc/wifi
mkdir /data/system/wpa_supplicant 0777 wifi wifi
chmod 0777 /data/system/wpa_supplicant
chown wifi wifi /data/system/wpa_supplicant