一 ubuntu 12.04移植mw150us驱动
参考:
1)https://blog.csdn.net/wangdapao12138/article/details/82559422
2)https://www.cnblogs.com/zfyouxi/p/5279940.html
3)https://github.com/kuba-moo/mt7601u/issues/64#issuecomment-352250127
4)https://forum.ubuntu.org.cn/viewtopic.php?p=3211381
问题:
1)根据参考1)编译mt7601u的源码时提示
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
原因:没有编译内核
make oldconfig
make prepare
make scripts
2)加载驱动时提示:insmod: error inserting 'hello.o' :-l invalid module format错误
网上说是内核版本不匹配导致
3) 错误: 将‘kuid_t’赋值给‘int’时类型不兼容
原因:内核在3.x以上后移除以下定义
typedef uid_t kuid_t;
typedef gid_t kgid_t;
只剩下如下定义
typedef struct {
uid_t val;
} kuid_t;
typedef struct {
gid_t val;
} kgid_t;
所以需要将用到kgid_t、kuid_t的位置修改kgid_t.val、kuid_t.val的结构体的使用
4)nfs经常掉线
mount -t nfs -o nolock -o tcp 192.168.0.200:/home/ros/ok6410/debian_arm /mnt
5)insmod 网卡驱动后,使用ifconfig -a可以看到新增的网卡驱动,但是没法使用,
使用ifconfig myWlan0 up显示ifconfig: SIOCSIFFLAGS: Operation not permitted
使用dmesg | tail -50
命令显示:
BcnBase[3] = 0xc600, pAd->BeaconOffset[3]=0xc600
BcnBase[4] = 0xc800, pAd->BeaconOffset[4]=0xc800
BcnBase[5] = 0xca00, pAd->BeaconOffset[5]=0xca00
BcnBase[6] = 0xcc00, pAd->BeaconOffset[6]=0xcc00
BcnBase[7] = 0xce00, pAd->BeaconOffset[7]=0xce00
BcnBase[8] = 0xd000, pAd->BeaconOffset[8]=0xd000
BcnBase[9] = 0xd200, pAd->BeaconOffset[9]=0xd200
BcnBase[10] = 0xd400, pAd->BeaconOffset[10]=0xd400
BcnBase[11] = 0xd600, pAd->BeaconOffset[11]=0xd600
BcnBase[12] = 0xd800, pAd->BeaconOffset[12]=0xd800
BcnBase[13] = 0xda00, pAd->BeaconOffset[13]=0xda00
BcnBase[14] = 0xdc00, pAd->BeaconOffset[14]=0xdc00
BcnBase[15] = 0xde00, pAd->BeaconOffset[15]=0xde00
NICInitMT7601MacRegisters
BBP version = 69
NICInitMT7601BbpRegisters
--->Disable TSF synchronization
NICInitializeAsic
NICInitializeAdapter
RtmpOSFileOpen(): Error 2 opening /etc/Wireless/RT2870STA/RT2870STA.dat
Open file "/etc/Wireless/RT2870STA/RT2870STA.dat" failed!
1. Phy Mode = 6
ERROR!!! RTMPReadParametersHook failed, Status[=0x00000001]
==> MlmeHalt
--->Disable TSF synchronization
MlmeHalt
RTMP_AllTimerListRelease: Cancel timer obj d08beb44!
RTMP_AllTimerListRelease: Cancel timer obj d08beb8c!
RTMP_AllTimerListRelease: Cancel timer obj d08bebd4!
RTMP_AllTimerListRelease: Cancel timer obj d08beafc!
RTMP_AllTimerListRelease: Cancel timer obj d08bea24!
RTMP_AllTimerListRelease: Cancel timer obj d08bea6c!
RTMP_AllTimerListRelease: Cancel timer obj d0853bfc!
RTMP_AllTimerListRelease: Cancel timer obj d0843050!
RTMP_AllTimerListRelease: Cancel timer obj d084309c!
RTMP_AllTimerListRelease: Cancel timer obj d0853ce4!
RTMP_AllTimerListRelease: Cancel timer obj d0853b6c!
RTMP_AllTimerListRelease: Cancel timer obj d0853c9c!
--->RTUSBCancelPendingBulkInIRP
Bulk In Failed. Status=-2, BIIdx=0x0, BIRIdx=0x0, actual_length= 0x0
CmdThread : CMDTHREAD_RESET_BULK_IN === >
unlink cmd rsp urb
-RTUSBCancelPendingBulkInIRP
-MlmeThread
CMDTHREAD_RESET_BULK_IN: Cannot do bulk in because flags(0x1080042) on !
CmdThread : CMDTHREAD_RESET_BULK_IN <===
-RTUSBCmdThread
-RtmpTimerQThread
!!! rt28xx init fail !!!
rt28xx_open return fail!
原因:没有/etc/Wireless/RT2870STA/RT2870STA.dat文件
移植步骤归纳(ubuntu 12.04 x32):
1)插上mw150us无线网卡后,在ubuntu查询网卡ID与厂商:
ros@ros-virtual-machine:~$ lsusb
Bus 001 Device 002: ID 148f:7601 Ralink Technology, Corp.
根据上面命令得知mw150us的ID为148f:7601,厂商为Ralink,在百度上搜索Ralink 7601发现刚好有Ralink
MT7601U类似的信息,所有直接下载MT7601U的源码进行尝试编译安装(后面证实确实是这款芯片),
而且在https://www.mediatek.com/products/broadbandWifi/mt7601u上有MT7601U的源码。
2)解压源码,
打开include/rtmp_def.h 文件修改网卡名称,这里修改为testWlan:
#ifdef ANDROID_SUPPORT
1601 #define INF_MAIN_DEV_NAME "wlan"
1602 #define INF_MBSSID_DEV_NAME "wlan"
1603 #else
1604 #define INF_MAIN_DEV_NAME "testWlan"
1605 #define INF_MBSSID_DEV_NAME "testWlan"
1606 #endif /* ANDROID_SUPPORT */
修改Makefile文件:
修改平台为SMDK,
#PLATFORM = PC
PLATFORM = SMDK
修改内核源码路径(这里是/home/ros/robot-linux/linux-3.0.1)和交叉编译器:
ifeq ($(PLATFORM),SMDK)
LINUX_SRC = /home/ros/robot-linux/linux-3.0.1
CROSS_COMPILE = arm-linux-
endif
3)make clean
make -j 4
完成后os/linux目录下生成了mt7601Usta.ko
4)将网卡驱动源码目录下的 RT2870STA.dat文件和生成的mt7601Usta.ko拷贝到开发板上;
5)将 RT2870STA.dat文件拷贝到开发板的/etc/Wireless/RT2870STA/目录下
mkdir -p /etc/Wireless/RT2870STA/
6)修改开发板上/etc/wpa_supplicant.conf文件:
network={
ssid=热点名称
key_mgmt=WPA-PSK
psk=热点密码
}
7)insmod mt7601Usta.ko
8)ifconfig -a,可以看到
testWlan0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
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)
9)ifconfig testWlan0 up开启网卡
10)连接无线网络:wpa_supplicant -B -c /etc/wpa_supplicant.conf -i testWlan0
11)查看连接状态:wpa_cli -i testWlan0 status
12)配置网卡ip地址,这里直接使用动态分配:udhcpc -i testWlan0