我的树莓派板子使用的是Arch Linux arm系统,一开始使用的是ubuntu core,后面觉得ubuntu玩着也没啥意思,所以将系统换成了Arch。
1、 更新arch(已是最新的略过)
pacman -Syu
2、 安装用于编译驱动的头文件(已安装的略过)
pacman -S linux-raspberrypi-headers 4.1.15-5
3、 安装编译器、vim、make(已安装的略过)
pacman -S gcc vim make
4、 在Ralink官网下载下载360wifi2的Linux驱动程序DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2。
5、 修改common/rtusb_dev_id.c文件,在
{USB_DEVICE(0x148f,0x7601)}, /* MT 6370 */
下面加一行
{USB_DEVICE(0x148f,0x760b)}, /* 360 Wifi */
6、 按照 README_STA_usb 中的说明 make 和 make install 。其中会遇到两个错误
第一处:
sta_cfg.c:5766:85: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]
snprintf(extra, size, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
^
sta/sta_cfg.c:5766:95: error: macro "__TIME__" might prevent reproducible builds [-Werror=date-time]
snprintf(extra, size, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
网上有大神说这个错误是因为编译选项开启了-Werror,可以这样解决:
修改/lib/modules/`uname -r`/build/Makefile
找到KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)
在前面加#注释掉继续make -j4(树莓派2有四核 所以加上 -j4)
出现第二处错误:
/work/src/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.c:1121:20: error: incompatible types when assigning to type ‘int’ from type ‘kuid_t’
pOSFSInfo->fsuid = current_fsuid();
^
/work/src/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/../../os/linux/rt_linux.c:1122:20: error: incompatible types when assigning to type ‘int’ from type ‘kgid_t’
pOSFSInfo->fsgid = current_fsgid();
把rt_linux.c里面报错的那里:
current_fsuid() 跟 current_fsgid()改成:
current_fsuid().val
current_fsgid().val
再make直到完成
7、 安装驱动
insmod os/linux/mt7601Usta.ko
至此驱动已经安装完成了,下面就要进行连接网络了。
先安装wireless_tools,
运行 iwconfig ,查看是否多了一个“ra0”的网卡,说明驱动已经安装成功了。
ra0 Ralink STA lo no wireless extensions. eth0 no wireless extensions.
下面就是要连接到无线网络上了。Arch预装了netctl,可以直接用这个工具来完成。大家可以查看Arch的wiki详细了解一下netctl这个工具:https://wiki.archlinux.org/index.php/Netctl_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
如果无线网络没有隐藏的话,可以直接用wifi-menu才创建Profile。由于我的网络是隐藏的,只好自己手动创建了,其实也很简单的。
cp /etc/netctl/examples/wireless-wpa /etc/netctl/ra0 vim /etc/netctl/ra0 Description='A simple WPA encrypted wireless connection' Interface=ra0 Connection=wireless Security=wpa IP=dhcp ESSID='MyNetwork' # Prepend hexadecimal keys with \" # If your key starts with ", write it as '""
把ESSID和Key设置好,如果是隐藏网络就把Hidden前面的#号去掉。然后保存退出。
运行 netctl start ra0
[root@alarmpi DPO_MT7601U_LinuxSTA_3.0.0.4_20130913]# netctl start wlan0
Job for [email protected] failed because the control process exited with error code. See "systemctl status [email protected]" and "journalctl -xe" for details.
出现错误
运行journalctl -xe
里面有如下一段
-- Unit [email protected] has begun starting up.
Jan 23 10:00:56 alarmpi network[2152]: Starting network profile 'ra0'...
Jan 23 10:00:56 alarmpi network[2152]: You need to install 'wpa_supplicant'
Jan 23 10:00:56 alarmpi network[2152]: The WPA supplicant did not start for interface 'wlan0'
Jan 23 10:00:56 alarmpi network[2152]: Failed to bring the network up for profile 'wlan0'
Jan 23 10:00:56 alarmpi systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE
Jan 23 10:00:56 alarmpi systemd[1]: Failed to start Networking for netctl profile wlan0.
-- Subject: Unit [email protected] has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit [email protected] has failed.
--
再运行ifconfig就可以看到ra0的信息了