树莓派使用360wifi2实现无线上网

来源:互联网 发布:java爬虫代码视频教程 编辑:程序博客网 时间:2024/06/05 13:25

我的树莓派板子使用的是Arch Linux arm系统,一开始使用的是ubuntu core,后面觉得ubuntu玩着也没啥意思,所以将系统换成了Arch

1、 更新arch(已是最新的略过)

pacman -Syu

2、 安装用于编译驱动的头文件(已安装的略过)

pacman -S linux-raspberrypi-headers 4.1.15-5

3、 安装编译器、vimmake(已安装的略过)

pacman -S gcc vim make

4、 Ralink官网下载下载360wifi2Linux驱动程序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中的说明makemake 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,可以直接用这个工具来完成。大家可以查看Archwiki详细了解一下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/ra0vim /etc/netctl/ra0Description='A simple WPA encryptedwireless connection'Interface=ra0Connection=wirelessSecurity=wpaIP=dhcpESSID='MyNetwork'# Prepend hexadecimal keys with \"# If your key starts with ", write itas '""<key>"'# See also: the section on special quotingrules in netctl.profile(5)Key='WirelessKey'# Uncomment this if your ssid is hidden#Hidden=yes

ESSIDKey设置好,如果是隐藏网络就把Hidden前面的#号去掉。然后保存退出。

运行 netctl start ra0

[root@alarmpi DPO_MT7601U_LinuxSTA_3.0.0.4_20130913]# netctl start wlan0
Job for netctl@wlan0.service failed because the control process exited with error code. See "systemctl status netctl@wlan0.service" and "journalctl -xe" for details.

出现错误

运行journalctl -xe

里面有如下一段

-- Unit netctl@wlan0.service 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]: netctl@wlan0.service: 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 netctl@wlan0.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit netctl@wlan0.service has failed.
-- 

安装wpa_supplicant 后继续执行  netctl start ra0

再运行ifconfig就可以看到ra0的信息了


0 0