买了树莓派2,正好原来有 360wifi2 ,不幸的是树莓派2不能直接支持,需要自己编译相关驱动,在网上搜索了不少教程,发现大多数是针对树莓派1的,就算有些是树莓派2的,也写得不是很清楚,所以就把整个编译过程记录下来,希望能对有相同需求的朋友增加一点帮助,因为有些细节对于新手很容易出错,所以本文尽量详细,不厌其烦,不做省略,把所有的操作步骤都记录下来,如果显示内容太多,但大多是些不必要知道的信息,就用 …… 表示。
写在最前面需要注意的事项:Linux软件版本很重要,往往同样一个项目,内核版本升级或者gcc版本升级都可能导致编译不通过,或者就算编译通过了运行起来也不稳定。
所以,所有打算参考本文进行操作的朋友,请务必保证你的程序、编译器、系统版本跟本文的一致!
系统版本:
pi@raspberrypi /opt/github/mt7601u-ap $ uname -r
4.1.6-v7+
pi
@raspberrypi /opt/github/mt7601u-ap $ uname -a
Linux raspberrypi 4.1.6-v7+ #810 SMP PREEMPT Tue Aug 18 15:32:12 BST 2015 armv7l GNU/Linux
内核编译版本:
pi
@raspberrypi /opt/github/mt7601u-ap $ cat /proc/version
Linux version 4.1.6-v7+ ([email protected]) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #810 SMP PREEMPT Tue Aug 18 15:32:12 BST 2015
pi
@raspberrypi /opt/github/mt7601u-ap $
编译器版本:
[email protected] /opt/github/mt7601u-ap $ gcc --version
gcc (Raspbian 4.8.4-1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[email protected] /opt/github/mt7601u-ap $
驱动版本:
[email protected] /opt/github/mt7601u-ap $ git remote -v
origin
https://github.com/eywalink/mt7601u (fetch)
origin
https://github.com/eywalink/mt7601u (push)
[email protected] /opt/github/mt7601u-ap $
(这个版本据使用者说可以支持ap,不过我还没来得及试验)
整个编译过程分两部分:
第一部分是操作系统更新,包括更新树莓派固件,下载Linux内核源码,建立内核模块库目录的符号链接;
第二部分是下载360wifi2的Linux驱动代码,我下载的驱动文件已经添加对360wifi2(MT7601)的支持,不需要大家手动添加了,到时候直接编译就行。最后再以内核模块的形式对已经编译好的无线网卡驱动模块进行安装。
正如某位同学所说,因为 MT7601 比较便宜,所以有不少设备商使用了它,比如小度wifi,小米wifi,腾讯wifi什么的,对这些网卡的支持也已经加入驱动代码, 具体修改的地方如下:
在下载了的驱动源码包里的文件 src/common/rtusb_dev_id.c 里面,加入如下内容:
在 {USB_DEVICE(0x148f,0×7601)}, /* MT 6370 */ 下面加入以下内容:
{USB_DEVICE(0x148f,0x760b)}, /* 360 Wifi */
{USB_DEVICE(0x2955,0x1001)}, /* baidu Wifi */
{USB_DEVICE(0x2a5f,0x1000)}, /* Tencent WIFI */
{USB_DEVICE(0×2955,0×0001)}, /* XiaoDu Wifi */
{USB_DEVICE(0x2717,0x4106)}, /* Xiaomi Wifi */
下面开始正式的编译过程:
第一部分:
1、首先是更新 rpi 固件,执行 rpi-update,记录如下:
我最初参照此文(
http://www.7forz.com/2470/)编译过一次,内核用 gcc-4.6 编译,无线网卡驱动用 gcc-4.8 编译,虽然可以正常上网,但是使用一段时间后有可能随机出现 oop 死机,错误信息如下:
[email protected] /opt/github $
Message from [email protected] at Aug 20 12:56:15 ... "raspberrypi" 12:56 20-Aug-15
kernel:[50382.924472] Internal error: Oops: 8000000d [#1] PREEMPT SMP ARM
因为我用树莓派2做服务器的一个目标就是追求稳定可靠,当然不能接受随机性死机,所以这个问题必须解决。
(补充:写到最后才发现出错的原因可能有两个:一个是我的gcc版本是 4.8.2,而要求版本是 4.8.3 以上;一个是使用了 ARMv6 的 Module.symvers 文件,应该使用对应于ARMv7 的Module7.symvers)
最初决定参照此文(
http://www.freemindworld.com/blog/2015/150312_complie_kernel_module_for_raspberry_pi_2.shtml),自己手动安装,把内核和网卡驱动模块重新全部在 gcc-4.8 下编译一遍。
查看一下当前的 gcc
执行记录如下:
[email protected] ~ $ ls -al /usr/bin/gcc*
lrwxrwxrwx 1 root root 16 Aug 19 14:23 /usr/bin/gcc -> /usr/bin/gcc-4.6
-rwxr-xr-x 1 root root 277796 Jan 15 2013 /usr/bin/gcc-4.6
-rwxr-xr-x 1 root root 616708 Sep 6 2014 /usr/bin/gcc-4.8
-rwxr-xr-x 1 root root 24640 Sep 6 2014 /usr/bin/gcc-ar-4.8
-rwxr-xr-x 1 root root 24592 Sep 6 2014 /usr/bin/gcc-nm-4.8
-rwxr-xr-x 1 root root 24596 Sep 6 2014 /usr/bin/gcc-ranlib-4.8
[email protected] ~ $ sudo rm /usr/bin/gcc
[email protected] ~ $ sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc
[email protected] ~ $
更新内核模块,使用以下命令:
sudo
apt
-
get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo rpi-update
执行记录如下:
[email protected] ~ $ sudo apt-get update
Get:1
http://mirrordirector.raspbian.org wheezy Release.gpg [490 B]
Get:2
http://mirrordirector.raspbian.org wheezy Release [14.4 kB]
Hit
http://archive.raspberrypi.org wheezy Release.gpg
Hit
http://raspberrypi.collabora.com wheezy Release.gpg
Get:3
http://mirrordirector.raspbian.org wheezy/main armhf Packages [6,905 kB]
Hit
http://archive.raspberrypi.org wheezy Release
Hit
http://raspberrypi.collabora.com wheezy Release
Hit
http://archive.raspberrypi.org wheezy/main armhf Packages
Hit
http://raspberrypi.collabora.com wheezy/rpi armhf Packages
Ign
http://archive.raspberrypi.org wheezy/main Translation-en_GB
Ign
http://raspberrypi.collabora.com wheezy/rpi Translation-en_GB
Ign
http://archive.raspberrypi.org wheezy/main Translation-en
Ign
http://raspberrypi.collabora.com wheezy/rpi Translation-en
Get:4
http://mirrordirector.raspbian.org wheezy/contrib armhf Packages [23.6 kB]
Get:5
http://mirrordirector.raspbian.org wheezy/non-free armhf Packages [49.3 kB]
Get:6
http://mirrordirector.raspbian.org wheezy/rpi armhf Packages [592 B]
Ign
http://mirrordirector.raspbian.org wheezy/contrib Translation-en_GB
Ign
http://mirrordirector.raspbian.org wheezy/contrib Translation-en
Ign
http://mirrordirector.raspbian.org wheezy/main Translation-en_GB
Ign
http://mirrordirector.raspbian.org wheezy/main Translation-en
Ign
http://mirrordirector.raspbian.org wheezy/non-free Translation-en_GB
Ign
http://mirrordirector.raspbian.org wheezy/non-free Translation-en
Ign
http://mirrordirector.raspbian.org wheezy/rpi Translation-en_GB
Ign
http://mirrordirector.raspbian.org wheezy/rpi Translation-en
Fetched 6,993 kB in 4min 7s (28.2 kB/s)
Reading package lists... Done
[email protected] ~ $
[email protected] ~ $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common
5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,135 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1
http://mirrordirector.raspbian.org/raspbian/ wheezy/main apache2 armhf 2.2.22-13+deb7u6 [1,440 B]
Get:2
http://mirrordirector.raspbian.org/raspbian/ wheezy/main apache2-mpm-prefork armhf 2.2.22-13+deb7u6 [2,342 B]
Get:3
http://mirrordirector.raspbian.org/raspbian/ wheezy/main apache2.2-common armhf 2.2.22-13+deb7u6 [292 kB]
Get:4
http://mirrordirector.raspbian.org/raspbian/ wheezy/main apache2.2-bin armhf 2.2.22-13+deb7u6 [676 kB]
Get:5
http://mirrordirector.raspbian.org/raspbian/ wheezy/main apache2-utils armhf 2.2.22-13+deb7u6 [163 kB]
Fetched 1,135 kB in 2s (432 kB/s)
(Reading database ... 112842 files and directories currently installed.)
Preparing to replace apache2 2.2.22-13+deb7u5 (using .../apache2_2.2.22-13+deb7u6_armhf.deb) ...
Unpacking replacement apache2 ...
Preparing to replace apache2-mpm-prefork 2.2.22-13+deb7u5 (using .../apache2-mpm-prefork_2.2.22-13+deb7u6_armhf.deb) ...
[....] Stopping web server: apache2apache2: Could not reliably determine the server‘s fully qualified domain name, using 127.0.1.1 for ServerName
. ok
Unpacking replacement apache2-mpm-prefork ...
Preparing to replace apache2.2-common 2.2.22-13+deb7u5 (using .../apache2.2-common_2.2.22-13+deb7u6_armhf.deb) ...
Unpacking replacement apache2.2-common ...
Preparing to replace apache2.2-bin 2.2.22-13+deb7u5 (using .../apache2.2-bin_2.2.22-13+deb7u6_armhf.deb) ...
Unpacking replacement apache2.2-bin ...
Preparing to replace apache2-utils 2.2.22-13+deb7u5 (using .../apache2-utils_2.2.22-13+deb7u6_armhf.deb) ...
Unpacking replacement apache2-utils ...
Processing triggers for man-db ...
Setting up apache2.2-bin (2.2.22-13+deb7u6) ...
Setting up apache2-utils (2.2.22-13+deb7u6) ...
Setting up apache2.2-common (2.2.22-13+deb7u6) ...
insserv: warning: current start runlevel(s) (empty) of script `apache2‘ overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `apache2‘ overrides LSB defaults (0 1 6).
Setting up apache2-mpm-prefork (2.2.22-13+deb7u6) ...
Setting up apache2 (2.2.22-13+deb7u6) ...
[email protected] ~ $
[email protected] ~ $ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
[email protected] ~ $
[email protected] ~ $ sudo rpi-update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Performing self-update
*** Relaunching after update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
#############################################################
WARNING: This update bumps to rpi-4.1.y linux tree
Be aware there could be compatibility issues with some drivers
Discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=113753
##############################################################
Would you like to proceed? (y/N)
*** Downloading specific firmware revision (this will take a few minutes)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 168 0 168 0 0 159 0 --:--:-- 0:00:01 --:--:-- 210
100 47.1M 100 47.1M 0 0 77546 0 0:10:37 0:10:37 --:--:-- 83607
*** Updating firmware
*** Updating kernel modules
*** depmod 4.1.6+
*** depmod 4.1.6-v7+
*** Updating VideoCore libraries
*** Using HardFP libraries
*** Updating SDK
*** Running ldconfig
*** Storing current firmware revision
*** Deleting downloaded files
*** Syncing changes to disk
*** If no errors appeared, your firmware was successfully updated to 7efa19016e080f6e1a0df2995bdee03176f3810d
*** A reboot is needed to activate the new firmware
[email protected] ~ $
最后提示这时需要重启来激活新固件
重启前后使用如下命令检查当前系统内核版本号:
uname -a
uname -r
执行记录如下:
重启前查询:
[email protected] ~ $ uname -a
Linux raspberrypi 4.1.5-v7+ #809 SMP PREEMPT Thu Aug 13 00:50:56 BST 2015 armv7l GNU/Linux
[email protected] ~ $ uname -r
4.1.5-v7+
[email protected] ~ $
重启后查询:
[email protected] /opt/software $ uname -a
Linux raspberrypi 4.1.6-v7+ #810 SMP PREEMPT Tue Aug 18 15:32:12 BST 2015 armv7l GNU/Linux
[email protected] /opt/software $ uname -r
4.1.6-v7+
[email protected] /opt/software $
发现我们的固件版本号已经从原来的 4.1.5 更新到了最新的 4.1.6
接着使用如下命令取得对应版本的内核代码,这个操作执行起来要花点时间,耐心等待吧。
sudo wget https://github.com/raspberrypi/linux/archive/rpi-4.1.y.tar.gz
执行记录如下:
[email protected] /opt/software $ sudo wget
https://github.com/raspberrypi/linux/archive/rpi-4.1.y.tar.gz
--2015-08-21 11:49:15--
https://github.com/raspberrypi/linux/archive/rpi-4.1.y.tar.gz
Resolving
github.com (
github.com)... 192.30.252.128
Connecting to
github.com (github.com)|192.30.252.128|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location:
https://codeload.github.com/raspberrypi/linux/tar.gz/rpi-4.1.y [following]
--2015-08-21 11:49:21--
https://codeload.github.com/raspberrypi/linux/tar.gz/rpi-4.1.y
Resolving
codeload.github.com (
codeload.github.com)... 192.30.252.144
Connecting to
codeload.github.com (codeload.github.com)|192.30.252.144|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: `rpi-4.1.y.tar.gz‘
[ <=> ] 128,360,666 26.8K/s in 34m 51s
2015-08-21 12:24:16 (60.0 KB/s) - `rpi-4.1.y.tar.gz‘ saved [128360666]
[email protected] /opt/software $
用如下命令解压:
sudo tar xvfz ./rpi-4.1.v.tar.gz
执行记录如下:
[email protected] /opt/software $ sudo tar xvfz ./rpi-4.1.y.tar.gz
linux-rpi-4.1.y/
linux-rpi-4.1.y/.gitignore
linux-rpi-4.1.y/.mailmap
linux-rpi-4.1.y/COPYING
linux-rpi-4.1.y/CREDITS
linux-rpi-4.1.y/Documentation/
linux-rpi-4.1.y/Documentation/00-INDEX
linux-rpi-4.1.y/Documentation/ABI/
linux-rpi-4.1.y/Documentation/ABI/README
…...
linux-rpi-4.1.y/virt/kvm/eventfd.c
linux-rpi-4.1.y/virt/kvm/irqchip.c
linux-rpi-4.1.y/virt/kvm/kvm_main.c
linux-rpi-4.1.y/virt/kvm/vfio.c
linux-rpi-4.1.y/virt/kvm/vfio.h
[email protected] /opt/software $
接着执行如下命令,先切换到 root(后续的命令就不需要再加 sudo 了,提示符也由 $ 变为 #),然后移动目录到 /usr/src
sudo su
mv ./linux-rpi-/ /usr/src/
记录如下:
[email protected] /opt/software $ sudo su
[email protected]:/opt/software# mv ./linux-rpi-4.1.y/ /usr/src
[email protected]:/opt/software#
执行如下命令,建立软连接(注意,这里必须是全部路径,而且不可以缺少 “/”,否则会在 /lib/下新建一个名为 的目录,这个地方容易被疏忽,编译时会导致无法找到而出错)
ln -s /usr/src/linux-rpi-4.1.y/ /lib/modules/4.1.6-v7+/build
记录如下:
[email protected]:/opt/software# ln -s /usr/src/linux-rpi-4.1.y/ /lib/modules/4.1.6-v7+/build
[email protected]:/opt/software#
进入该 build 目录,执行如下命令清除一下编译环境:
make mrproper
执行记录如下:
[email protected]:/opt/software# cd /lib/modules/4.1.6-v7+/build
[email protected]:/lib/modules/4.1.6-v7+/build# ls
arch CREDITS drivers include Kbuild lib mm REPORTING-BUGS security usr
block crypto firmware init Kconfig MAINTAINERS net samples sound virt
COPYING Documentation fs ipc kernel Makefile README scripts tools
[email protected]:/lib/modules/4.1.6-v7+/build# make mrproper
[email protected]:/lib/modules/4.1.6-v7+/build#
执行如下命令,在 /proc 目录下生成 config.gz 文件,这个命令在树莓派1是不需要执行的,但是树莓派2必须执行:
modprobe configs
执行记录如下:
[email protected]:/lib/modules/4.1.6-v7+/build# modprobe configs
[email protected]:/lib/modules/4.1.6-v7+/build# ls /proc
1 174 2452 2730 29 319 4041 47 58 cgroups execdomains kmsg partitions timer_list
10 18 2461 2731 2934 32 4059 48 59 cmdline fb kpagecount sched_debug timer_stats
11 19 2476 2732 3 33 4109 49 5975 config.gz filesystems kpageflags self tty
1118 2 25 2733 30 330 4162 5 6045 consoles fs loadavg slabinfo uptime
12 20 2506 2734 3079 35 4178 50 6051 cpu interrupts locks softirqs vc-cma
14 22 2567 2735 31 36 4197 52 7 cpuinfo iomem meminfo stat version
15 2208 26 2736 3137 37 43 53 8 crypto ioports misc swaps vmallocinfo
1581 2243 2647 2738 3142 378 44 54 9 devices irq modules sys vmstat
16 23 2649 28 3143 3861 445 55 asound device-tree kallsyms mounts sysrq-trigger zoneinfo
1601 2398 2675 2866 317 4039 45 56 buddyinfo diskstats keys net sysvipc
1643 24 27 2894 3189 4040 46 57 bus driver key-users pagetypeinfo thread-self
[email protected]:/lib/modules/4.1.6-v7+/build#
接着执行如下命令,把 config.gz 导出到 /build 目录下,名为 .config
gzip -dc /proc/config.gz > .config
执行记录如下:
[email protected]:/lib/modules/4.1.6-v7+/build# gzip -dc /proc/config.gz > .config
[email protected]:/lib/modules/4.1.6-v7+/build# ls -a
. block CREDITS drivers .gitignore ipc kernel MAINTAINERS net samples sound virt
.. .config crypto firmware include Kbuild lib Makefile README scripts tools
arch COPYING Documentation fs init Kconfig .mailmap mm REPORTING-BUGS security usr
[email protected]:/lib/modules/4.1.6-v7+/build#
执行如下命令,开始模块编译准备:
make modules_prepare
执行记录如下:
[email protected]:/lib/modules/4.1.6-v7+/build# make modules_prepare
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
…...
Generating include/generated/mach-types.h
CC kernel/bounds.s
CHK include/generated/bounds.h
UPD include/generated/bounds.h
CC arch/arm/kernel/asm-offsets.s
arch/arm/kernel/asm-offsets.c:54:2: error: #error Your compiler is too buggy; it is known to miscompile kernels
#error Your compiler is too buggy; it is known to miscompile kernels
^
arch/arm/kernel/asm-offsets.c:55:2: error: #error and result in filesystem corruption and oopses.
#error and result in filesystem corruption and oopses.
^
Kbuild:61: recipe for target ‘arch/arm/kernel/asm-offsets.s‘ failed
make[1]: *** [arch/arm/kernel/asm-offsets.s] Error 1
Makefile:990: recipe for target ‘prepare0‘ failed
make: *** [prepare0] Error 2
[email protected]:/lib/modules/4.1.6-v7+/build#
非常不幸地出现这个错误:#error Your compiler is too buggy; it is known to miscompile kernels,根据后面的报错提示,应该是 /proc/version 是 gcc-4.8.3,而我当前安装的是 gcc-4.8.2,所以改变手动安装策略,干脆使用 dpi-source 来自动安装
回到 /opt/software 目录,下载 rpi-source,增加执行权限,执行
[email protected]:/opt/software# wget
https://raw.githubusercontent.com/lifanxi/rpi-source/master/rpi-source
--2015-08-21 13:48:50--
https://raw.githubusercontent.com/lifanxi/rpi-source/master/rpi-source
Resolving
raw.githubusercontent.com (
raw.githubusercontent.com)... 103.245.222.133
Connecting to
raw.githubusercontent.com (raw.githubusercontent.com)|103.245.222.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11825 (12K) [text/plain]
Saving to: `rpi-source‘
100%[==============================================================================================>] 11,825 --.-K/s in 0s
2015-08-21 13:48:53 (28.5 MB/s) - `rpi-source‘ saved [11825/11825]
[email protected]:/opt/software#
[email protected]:/opt/software# chmod a+x rpi-source
[email protected]:/opt/software#
[email protected]:/opt/software# ./rpi-source
*** Updating rpi-source
--2015-08-21 13:53:04--
https://raw.githubusercontent.com/lifanxi/rpi-source/master/rpi-source
Resolving
raw.githubusercontent.com (
raw.githubusercontent.com)... 103.245.222.133
Connecting to
raw.githubusercontent.com (raw.githubusercontent.com)|103.245.222.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11825 (12K) [text/plain]
Saving to: `./rpi-source‘
100%[==============================================================================================>] 11,825 --.-K/s in 0.001s
2015-08-21 13:53:07 (21.7 MB/s) - `./rpi-source‘ saved [11825/11825]
*** Set update tag: 94cef917c80502c6638b777f7d5b83467f9da2de
*** Restarting rpi-source
ERROR:
gcc version check: mismatch between gcc (4.8.2) and /proc/version (4.1.6)
Skip this check with --skip-gcc
Help:
https://github.com/notro/rpi-source/wiki
[email protected]:/opt/software#
结果再次报错,检查一下:
[email protected]:/opt/software# cat /proc/version
Linux version 4.1.6-v7+ ([email protected]) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #810 SMP PREEMPT Tue Aug 18 15:32:12 BST 2015
[email protected]:/opt/software# gcc --version
gcc (Raspbian 4.8.2-21~rpi3rpi1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[email protected]:/opt/software#
很明显,这个脚本比较错了,在 /proc/version 下取版本号把 Linux 的版本号给取了,而没有取 gcc 的版本号,看了下 gthub 上已经有人提这个bug了,作者也改了,但是很明显,修改无效。
不过先看看我的 gcc 版本,打开这篇文档(
https://github.com/notro/rpi-source/wiki),发现要把 gcc 版本升到 4.8.3,但是我目前的 gcc 版本是 4.8.2,官方源最新版本就是 4.8.2,于是按照该文的提示,做了如下操作:
增加目前处于测试状态的更新源 jessie,打开文件
sudo nano /etc/apt/sources.list.d/jessie.list,
增加一句
deb
http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
保存退出
再次更新:
sudo apt-get update
执行记录如下
[email protected] /opt/software $ sudo nano /etc/apt/sources.list.d/jessie.list
[email protected] /opt/software $ sudo apt-get update
Get:1
http://mirrordirector.raspbian.org wheezy Release.gpg [490 B]
Hit
http://raspberrypi.collabora.com wheezy Release.gpg
Hit
http://archive.raspberrypi.org wheezy Release.gpg
Get:2
http://mirrordirector.raspbian.org jessie Release.gpg [490 B]
Hit
http://raspberrypi.collabora.com wheezy Release
Get:3
http://mirrordirector.raspbian.org wheezy Release [14.4 kB]
Hit
http://archive.raspberrypi.org wheezy Release
Hit
http://raspberrypi.collabora.com wheezy/rpi armhf Packages
Hit
http://archive.raspberrypi.org wheezy/main armhf Packages
Get:4
http://mirrordirector.raspbian.org jessie Release [14.4 kB]
Get:5
http://mirrordirector.raspbian.org wheezy/main armhf Packages [6,905 kB]
Ign
http://raspberrypi.collabora.com wheezy/rpi Translation-en_GB
Ign
http://raspberrypi.collabora.com wheezy/rpi Translation-en
Ign
http://archive.raspberrypi.org wheezy/main Translation-en_GB
Ign
http://archive.raspberrypi.org wheezy/main Translation-en
Get:6
http://mirrordirector.raspbian.org wheezy/contrib armhf Packages [23.6 kB]
Get:7
http://mirrordirector.raspbian.org wheezy/non-free armhf Packages [49.3 kB]
Get:8
http://mirrordirector.raspbian.org wheezy/rpi armhf Packages [592 B]
Get:9
http://mirrordirector.raspbian.org jessie/main armhf Packages [8,961 kB]
Get:10
http://mirrordirector.raspbian.org jessie/contrib armhf Packages [37.4 kB]
Get:11
http://mirrordirector.raspbian.org jessie/non-free armhf Packages [70.2 kB]
Get:12
http://mirrordirector.raspbian.org jessie/rpi armhf Packages [1,356 B]
Ign
http://mirrordirector.raspbian.org wheezy/contrib Translation-en_GB
Ign
http://mirrordirector.raspbian.org wheezy/contrib Translation-en
Ign
http://mirrordirector.raspbian.org wheezy/main Translation-en_GB
Ign
http://mirrordirector.raspbian.org wheezy/main Translation-en
Ign
http://mirrordirector.raspbian.org wheezy/non-free Translation-en_GB
Ign
http://mirrordirector.raspbian.org wheezy/non-free Translation-en
Ign
http://mirrordirector.raspbian.org wheezy/rpi Translation-en_GB
Ign
http://mirrordirector.raspbian.org wheezy/rpi Translation-en
Ign
http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB
Ign
http://mirrordirector.raspbian.org jessie/contrib Translation-en
Ign
http://mirrordirector.raspbian.org jessie/main Translation-en_GB
Ign
http://mirrordirector.raspbian.org jessie/main Translation-en
Ign
http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB
Ign
http://mirrordirector.raspbian.org jessie/non-free Translation-en
Ign
http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB
Ign
http://mirrordirector.raspbian.org jessie/rpi Translation-en
Fetched 16.1 MB in 9min 23s (28.6 kB/s)
Reading package lists... Done
[email protected] /opt/software $
然后执行:
sudo apt-get install -y gcc-4.8 g++-4.8
执行记录如下:
[email protected] /opt/software $ sudo apt-get install -y gcc-4.8 g++-4.8
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libgssglue1
Use ‘apt-get autoremove‘ to remove it.
The following extra packages will be installed:
binutils cpp-4.8 gcc-4.7-base gcc-4.8-base gcc-4.9-base libasan0 libatomic1 libc-bin libc-dev-bin libc6 libc6-dev libgcc-4.8-dev
libgcc1 libgfortran3 libgomp1 libgssapi-krb5-2 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 libmpfr4 libnih-dbus1 libnih1
libstdc++-4.8-dev libstdc++6 libtirpc1 locales nfs-common
Suggested packages:
binutils-doc gcc-4.8-locales gcc-4.8-doc libstdc++6-4.8-dbg libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan0-dbg
libtsan0-dbg libquadmath-dbg glibc-doc krb5-doc krb5-user libstdc++-4.8-doc open-iscsi watchdog
The following NEW packages will be installed:
gcc-4.9-base
…...
Setting up libgcc-4.8-dev:armhf (4.8.4-1) ...
Setting up gcc-4.8 (4.8.4-1) ...
Setting up libstdc++-4.8-dev:armhf (4.8.4-1) ...
Setting up g++-4.8 (4.8.4-1) ...
Setting up libgfortran3:armhf (4.9.2-10) ...
Processing triggers for libc-bin ...
[email protected] /opt/software $
接下来执行这几条命令:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
执行记录如下:
[email protected] /opt/software $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
update-alternatives: using /usr/bin/gcc-4.6 to provide /usr/bin/gcc (gcc) in auto mode
[email protected] /opt/software $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
update-alternatives: using /usr/bin/gcc-4.8 to provide /usr/bin/gcc (gcc) in auto mode
[email protected] /opt/software $ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
update-alternatives: using /usr/bin/g++-4.6 to provide /usr/bin/g++ (g++) in auto mode
[email protected] /opt/software $ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
update-alternatives: using /usr/bin/g++-4.8 to provide /usr/bin/g++ (g++) in auto mode
[email protected] /opt/software $
检查下当前的版本,变成了 4.8.4
[email protected] /opt/software $ gcc --version
gcc (Raspbian 4.8.4-1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[email protected] /opt/software $
如果想切换版本,执行这条命令:
sudo update-alternatives --config gcc
执行记录如下:
[email protected] /opt/software $ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gcc-4.8 50 auto mode
1 /usr/bin/gcc-4.6 20 manual mode
2 /usr/bin/gcc-4.8 50 manual mode
Press enter to keep the current choice[*], or type selection number:
[email protected] /opt/software $
切换回root,重新下载最新的 rpi-source 再次执行
执行记录如下:
[email protected]:/opt/software# sudo wget
https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
--2015-08-21 14:53:12--
https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source
Resolving
raw.githubusercontent.com (
raw.githubusercontent.com)... 103.245.222.133
Connecting to
raw.githubusercontent.com (raw.githubusercontent.com)|103.245.222.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12424 (12K) [text/plain]
Saving to: `/usr/bin/rpi-source‘
100%[==============================================================================================>] 12,424 --.-K/s in 0s
2015-08-21 14:53:15 (29.2 MB/s) - `/usr/bin/rpi-source‘ saved [12424/12424]
[email protected]:/opt/software#
结果版本仍然不匹配
[email protected]:/opt/software# ./rpi-source
*** Updating rpi-source
--2015-08-21 14:54:49--
https://raw.githubusercontent.com/lifanxi/rpi-source/master/rpi-source
Resolving
raw.githubusercontent.com (
raw.githubusercontent.com)... 103.245.222.133
Connecting to
raw.githubusercontent.com (raw.githubusercontent.com)|103.245.222.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11825 (12K) [text/plain]
Saving to: `./rpi-source‘
100%[==============================================================================================>] 11,825 --.-K/s in 0s
2015-08-21 14:54:54 (27.3 MB/s) - `./rpi-source‘ saved [11825/11825]
*** Set update tag: 94cef917c80502c6638b777f7d5b83467f9da2de
*** Restarting rpi-source
ERROR:
gcc version check: mismatch between gcc (4.8.4) and /proc/version (4.1.6)
Skip this check with --skip-gcc
Help:
https://github.com/notro/rpi-source/wiki
[email protected]:/opt/software#
显然,版本比较的错误还是会影响编译,不过我对脚本不是很熟悉,不太会修改,于是再次换回原来的手工操作,因为已经把 gcc 的版本升级了,理论上可以编译通过,事实果然如此,
执行记录如下:
[email protected]:/lib/modules/4.1.6-v7+/build# make mrproper
CLEAN .
CLEAN .tmp_versions
CLEAN scripts/basic
CLEAN scripts/dtc
CLEAN scripts/genksyms
CLEAN scripts/kconfig
CLEAN scripts/mod
CLEAN scripts
CLEAN include/config include/generated arch/arm/include/generated
CLEAN .config
[email protected]:/lib/modules/4.1.6-v7+/build# gzip -dc /proc/config.gz > .config
[email protected]:/lib/modules/4.1.6-v7+/build# make modules_prepare
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config/kernel.release
UPD include/config/kernel.release
WRAP arch/arm/include/generated/asm/bitsperlong.h
WRAP arch/arm/include/generated/asm/cputime.h
WRAP arch/arm/include/generated/asm/current.h
WRAP arch/arm/include/generated/asm/emergency-restart.h
WRAP arch/arm/include/generated/asm/errno.h
WRAP arch/arm/include/generated/asm/exec.h
WRAP arch/arm/include/generated/asm/ioctl.h
WRAP arch/arm/include/generated/asm/ipcbuf.h
WRAP arch/arm/include/generated/asm/irq_regs.h
WRAP arch/arm/include/generated/asm/kdebug.h
WRAP arch/arm/include/generated/asm/local.h
WRAP arch/arm/include/generated/asm/local64.h
WRAP arch/arm/include/generated/asm/mcs_spinlock.h
WRAP arch/arm/include/generated/asm/msgbuf.h
WRAP arch/arm/include/generated/asm/param.h
WRAP arch/arm/include/generated/asm/parport.h
WRAP arch/arm/include/generated/asm/poll.h
WRAP arch/arm/include/generated/asm/preempt.h
WRAP arch/arm/include/generated/asm/resource.h
WRAP arch/arm/include/generated/asm/rwsem.h
WRAP arch/arm/include/generated/asm/scatterlist.h
WRAP arch/arm/include/generated/asm/seccomp.h
WRAP arch/arm/include/generated/asm/sections.h
WRAP arch/arm/include/generated/asm/segment.h
WRAP arch/arm/include/generated/asm/sembuf.h
WRAP arch/arm/include/generated/asm/serial.h
WRAP arch/arm/include/generated/asm/shmbuf.h
WRAP arch/arm/include/generated/asm/siginfo.h
WRAP arch/arm/include/generated/asm/simd.h
WRAP arch/arm/include/generated/asm/sizes.h
WRAP arch/arm/include/generated/asm/socket.h
WRAP arch/arm/include/generated/asm/sockios.h
WRAP arch/arm/include/generated/asm/termbits.h
WRAP arch/arm/include/generated/asm/termios.h
WRAP arch/arm/include/generated/asm/timex.h
WRAP arch/arm/include/generated/asm/trace_clock.h
WRAP arch/arm/include/generated/asm/unaligned.h
CHK include/generated/uapi/linux/version.h
UPD include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
UPD include/generated/utsrelease.h
HOSTCC scripts/basic/bin2c
Generating include/generated/mach-types.h
CC kernel/bounds.s
CHK include/generated/bounds.h
UPD include/generated/bounds.h
CC arch/arm/kernel/asm-offsets.s
CHK include/generated/asm-offsets.h
UPD include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
HOSTCC scripts/dtc/dtc.o
HOSTCC scripts/dtc/flattree.o
HOSTCC scripts/dtc/fstree.o
HOSTCC scripts/dtc/data.o
HOSTCC scripts/dtc/livetree.o
HOSTCC scripts/dtc/treesource.o
HOSTCC scripts/dtc/srcpos.o
HOSTCC scripts/dtc/checks.o
HOSTCC scripts/dtc/util.o
SHIPPED scripts/dtc/dtc-lexer.lex.c
SHIPPED scripts/dtc/dtc-parser.tab.h
HOSTCC scripts/dtc/dtc-lexer.lex.o
SHIPPED scripts/dtc/dtc-parser.tab.c
HOSTCC scripts/dtc/dtc-parser.tab.o
HOSTLD scripts/dtc/dtc
HOSTCC scripts/genksyms/genksyms.o
SHIPPED scripts/genksyms/parse.tab.c
HOSTCC scripts/genksyms/parse.tab.o
SHIPPED scripts/genksyms/lex.lex.c
SHIPPED scripts/genksyms/keywords.hash.c
SHIPPED scripts/genksyms/parse.tab.h
HOSTCC scripts/genksyms/lex.lex.o
HOSTLD scripts/genksyms/genksyms
CC scripts/mod/empty.o
HOSTCC scripts/mod/mk_elfconfig
MKELF scripts/mod/elfconfig.h
HOSTCC scripts/mod/modpost.o
CC scripts/mod/devicetable-offsets.s
GEN scripts/mod/devicetable-offsets.h
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/mod/sumversion.o
HOSTLD scripts/mod/modpost
HOSTCC scripts/kallsyms
HOSTCC scripts/pnmtologo
HOSTCC scripts/conmakehash
HOSTCC scripts/recordmcount
HOSTCC scripts/sortextable
[email protected]:/lib/modules/4.1.6-v7+/build#
接下来取得模块符号,这里对于树莓派1和树莓派2是有区别的,因为1使用的是ARMv6,2使用的是ARMv7,它们对应的文件分别是:
树莓派1:
https://github.com/raspberrypi/firmware/blob/master/extra/Module.symvers
树莓派2:
https://github.com/raspberrypi/firmware/blob/master/extra/Module7.symvers
不过取回来之后需要改名为 Module.symvers 保存在 build 目录下
执行记录如下:
[email protected]:/lib/modules/4.1.6-v7+/build# wget
https://github.com/raspberrypi/firmware/raw/master/extra/Module7.symvers
--2015-08-21 15:21:23--
https://github.com/raspberrypi/firmware/raw/master/extra/Module7.symvers
Resolving
github.com (
github.com)... 192.30.252.130
Connecting to
github.com (github.com)|192.30.252.130|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location:
https://raw.githubusercontent.com/raspberrypi/firmware/master/extra/Module7.symvers [following]
--2015-08-21 15:21:28--
https://raw.githubusercontent.com/raspberrypi/firmware/master/extra/Module7.symvers
Resolving
raw.githubusercontent.com (
raw.githubusercontent.com)... 103.245.222.133
Connecting to
raw.githubusercontent.com (raw.githubusercontent.com)|103.245.222.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 586627 (573K) [text/plain]
Saving to: `Module7.symvers‘
100%[==============================================================================================>] 586,627 316K/s in 1.8s
2015-08-21 15:21:34 (316 KB/s) - `Module7.symvers‘ saved [586627/586627]
[email protected]:/lib/modules/4.1.6-v7+/build# mv ./Module7.symvers ./Module.symvers
[email protected]:/lib/modules/4.1.6-v7+/build#
好了,到目前为止,终于千辛万苦地完成了第一阶段的工作,也就是无线模块编译的准备工作。
第二部分:
接下来要开始正式编译无线模块了,这次我选择了一个据说能支持 AP 功能的驱动,虽然是1年前的
git clone
https://github.com/eywalink/mt7601u mt7601u-ap
进入该目录,查看一下,发现有一个 build.sh 的脚本,看看内容:
[email protected]:/opt/github/mt7601u-ap# ls
build.sh doc HISTORY LICENSE Makefile Makefile.inc
miwifi_work.sh
README.md
unload.sh
config.mk etc
info.sh
load.sh Makefile.clean
miwifi_build.sh README src
[email protected]:/opt/github/mt7601u-ap# cat ./build.sh
#!/bin/sh
cp -v /lib/modules/$(uname -r)/build/Module.symvers src/os/linux
make clean && make all
rm -rvf src/os/linux/Module.symvers
modprobe --dump-modversions src/os/linux/mtnet7601Usta.ko
modprobe --dump-modversions src/os/linux/mtutil7601Usta.ko
modprobe --dump-modversions src/os/linux/mt7601Usta.ko
[email protected]:/opt/github/mt7601u-ap#
很好,直接运行 build.sh 貌似就可以了,
执行记录如下:
[email protected]:/opt/github/mt7601u-ap# ./build.sh
`/lib/modules/4.1.6-v7+/build/Module.symvers‘ -> `src/os/linux/Module.symvers‘
make -C src/ clean
make[1]: Entering directory ‘/opt/github/mt7601u-ap/src‘
cp -f os/linux/Makefile.clean os/linux/Makefile
make -C os/linux clean
make[2]: Entering directory ‘/opt/github/mt7601u-ap/src/os/linux‘
rm -f ../../common/*.o
rm -f ../../common/.*.cmd .*.flags .*.d
rm -f ../../os/linux/*.o *.ko *.mod.o *.mod.c
…...
CC [M] /opt/github/mt7601u-ap/src/os/linux/../../os/linux/rt_main_dev.o
CC [M] /opt/github/mt7601u-ap/src/os/linux/../../common/rtusb_dev_id.o
CC [M] /opt/github/mt7601u-ap/src/os/linux/../../os/linux/usb_main_dev.o
LD [M] /opt/github/mt7601u-ap/src/os/linux/rtnet7601Uap.o
Building modules, stage 2.
MODPOST 1 modules
CC /opt/github/mt7601u-ap/src/os/linux/rtnet7601Uap.mod.o
LD [M] /opt/github/mt7601u-ap/src/os/linux/rtnet7601Uap.ko
make[2]: Leaving directory ‘/usr/src/linux-rpi-4.1.y‘
make[1]: Leaving directory ‘/opt/github/mt7601u-ap/src‘
removed `src/os/linux/Module.symvers‘
FATAL: Module src/os/linux/mtnet7601Usta.ko not found.
FATAL: Module src/os/linux/mtutil7601Usta.ko not found.
FATAL: Module src/os/linux/mt7601Usta.ko not found.
[email protected]:/opt/github/mt7601u-ap# ls
build.sh doc HISTORY LICENSE Makefile Makefile.inc
miwifi_work.sh
README.md
unload.sh
config.mk etc
info.sh
load.sh Makefile.clean
miwifi_build.sh README src
[email protected]:/opt/github/mt7601u-ap#
非常不幸又出错,就没有消停过一次。。。
好吧,看看是咋回事,原来要用这个脚本 miwifi_build.sh
[email protected]:/opt/github/mt7601u-ap# ./miwifi_build.sh
`/lib/modules/4.1.6-v7+/build/Module.symvers‘ -> `src/os/linux/Module.symvers‘
make -C src/ clean
make[1]: Entering directory ‘/opt/github/mt7601u-ap/src‘
cp -f os/linux/Makefile.clean os/linux/Makefile
make -C os/linux clean
make[2]: Entering directory ‘/opt/github/mt7601u-ap/src/os/linux‘
rm -f ../../common/*.o
rm -f ../../common/.*.cmd .*.flags .*.d
rm -f ../../os/linux/*.o *.ko *.mod.o *.mod.c
…..
CC [M] /opt/github/mt7601u-ap/src/os/linux/../../os/linux/rt_main_dev.o
CC [M] /opt/github/mt7601u-ap/src/os/linux/../../common/rtusb_dev_id.o
CC [M] /opt/github/mt7601u-ap/src/os/linux/../../os/linux/usb_main_dev.o
LD [M] /opt/github/mt7601u-ap/src/os/linux/rtnet7601Uap.o
Building modules, stage 2.
MODPOST 1 modules
CC /opt/github/mt7601u-ap/src/os/linux/rtnet7601Uap.mod.o
LD [M] /opt/github/mt7601u-ap/src/os/linux/rtnet7601Uap.ko
make[2]: Leaving directory ‘/usr/src/linux-rpi-4.1.y‘
make[1]: Leaving directory ‘/opt/github/mt7601u-ap/src‘
make -C src/ install
make[1]: Entering directory ‘/opt/github/mt7601u-ap/src‘
make -C /opt/github/mt7601u-ap/src/os/linux -f Makefile.6 install
make[2]: Entering directory ‘/opt/github/mt7601u-ap/src/os/linux‘
mkdir -pv /etc/Wireless/RT2870AP
mkdir: created directory `/etc/Wireless/RT2870AP‘
cp -v /opt/github/mt7601u-ap/src/../etc/Wireless/RT2870AP/RT2870AP.dat /etc/Wireless/RT2870AP/.
`/opt/github/mt7601u-ap/src/../etc/Wireless/RT2870AP/RT2870AP.dat‘ -> `/etc/Wireless/RT2870AP/./RT2870AP.dat‘
install -d /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
install -m 644 -c mt7601Uap.ko /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
/sbin/depmod -a 4.1.6-v7+
make[2]: Leaving directory ‘/opt/github/mt7601u-ap/src/os/linux‘
make -C /opt/github/mt7601u-ap/src/os/linux -f Makefile.6.util install
make[2]: Entering directory ‘/opt/github/mt7601u-ap/src/os/linux‘
install -d /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
install -m 644 -c rtutil7601Uap.ko /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
/sbin/depmod -a 4.1.6-v7+
make[2]: Leaving directory ‘/opt/github/mt7601u-ap/src/os/linux‘
make -C /opt/github/mt7601u-ap/src/os/linux -f Makefile.6.netif install
make[2]: Entering directory ‘/opt/github/mt7601u-ap/src/os/linux‘
install -d /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
install -m 644 -c rtnet7601Uap.ko /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
/sbin/depmod -a 4.1.6-v7+
make[2]: Leaving directory ‘/opt/github/mt7601u-ap/src/os/linux‘
make[1]: Leaving directory ‘/opt/github/mt7601u-ap/src‘
removed `src/os/linux/Module.symvers‘
[email protected]:/opt/github/mt7601u-ap#
千辛万苦,终于成功编译出来并且安装好了,真不容易
执行 ifconfig 查看一下:
执行记录如下:
[email protected]:/opt/github/mt7601u-ap# ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:be:64:81
inet addr:192.168.99.209 Bcast:192.168.99.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:206521 errors:0 dropped:1 overruns:0 frame:0
TX packets:172373 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:165311832 (157.6 MiB) TX bytes:25304656 (24.1 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:63 errors:0 dropped:0 overruns:0 frame:0
TX packets:63 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:11000 (10.7 KiB) TX bytes:11000 (10.7 KiB)
wlan0 Link encap:Ethernet HWaddr 00:36:76:56:bd:4f
UP 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)
[email protected]:/opt/github/mt7601u-ap#
看来暂时是 OK 了
先进入目录 /opt/github/mt7601u-ap/src/os/linux/ 查看一下我们编译出来的驱动是什么样子
执行记录如下:
[email protected] /opt/github/mt7601u-ap/src/os/linux $ ls -al *.ko
-rw-r--r-- 1 root root 1373192 Aug 21 15:56 mt7601Uap.ko
-rw-r--r-- 1 root root 27516 Aug 21 15:56 rtnet7601Uap.ko
-rw-r--r-- 1 root root 109552 Aug 21 15:52 rtutil7601Uap.ko
[email protected] /opt/github/mt7601u-ap/src/os/linux $
再用 wicd-curses 看看
执行记录如下:
Wired Networks
> 0 wired-default vvv
Wireless Networks
C STR ESSID ENCRYPT BSSID MODE CHNL
100% 360WiFi-2 WPA2 EE:EE:EE:EE:EE:EE Master 1
58% FAST_632AO WPA2 EE:EE:EE:EE:EE:EE Master 1
44% TP-LINK-LTC WPA2 EE:EE:EE:EE:EE:EE Master 6
41% QWE-SG2 WPA2 EE:EE:EE:EE:EE:EE Master 11
41% D-Link_DIR-600M WPA2 EE:EE:EE:EE:EE:EE Master 1
41% HiWiFi_26812A WPA2 EE:EE:EE:EE:EE:EE Master 4
41% D-Link_DIR-613 WPA2 EE:EE:EE:EE:EE:EE Master 11
38% FAST_43QWE2 WPA2 EE:EE:EE:EE:EE:EE Master 1
35% 3621101 WPA EE:EE:EE:EE:EE:EE Master 6
35% Tenda_1AB23F WPA EE:EE:EE:EE:EE:EE Master 8
32% ZXM999 WPA2 EE:EE:EE:EE:EE:EE Master 6
32% TP-cheX WPA2 EE:EE:EE:EE:EE:EE Master 6
看来目前为止是可以正常搜索到wifi信号了。
如果希望手动安装/卸载我们编译出来的驱动,可以在本目录(/opt/github/mt7601u-ap/src/)下执行:
sudo su
make install
make uninstall
执行记录如下:
手动安装
[email protected]:/opt/github/mt7601u-ap# make install
make -C src/ install
make[1]: Entering directory ‘/opt/github/mt7601u-ap/src‘
make -C /opt/github/mt7601u-ap/src/os/linux -f Makefile.6 install
make[2]: Entering directory ‘/opt/github/mt7601u-ap/src/os/linux‘
mkdir -pv /etc/Wireless/RT2870AP
cp -v /opt/github/mt7601u-ap/src/../etc/Wireless/RT2870AP/RT2870AP.dat /etc/Wireless/RT2870AP/.
`/opt/github/mt7601u-ap/src/../etc/Wireless/RT2870AP/RT2870AP.dat‘ -> `/etc/Wireless/RT2870AP/./RT2870AP.dat‘
install -d /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
install -m 644 -c mt7601Uap.ko /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
/sbin/depmod -a 4.1.6-v7+
make[2]: Leaving directory ‘/opt/github/mt7601u-ap/src/os/linux‘
make -C /opt/github/mt7601u-ap/src/os/linux -f Makefile.6.util install
make[2]: Entering directory ‘/opt/github/mt7601u-ap/src/os/linux‘
install -d /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
install -m 644 -c rtutil7601Uap.ko /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
/sbin/depmod -a 4.1.6-v7+
make[2]: Leaving directory ‘/opt/github/mt7601u-ap/src/os/linux‘
make -C /opt/github/mt7601u-ap/src/os/linux -f Makefile.6.netif install
make[2]: Entering directory ‘/opt/github/mt7601u-ap/src/os/linux‘
install -d /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
install -m 644 -c rtnet7601Uap.ko /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/
/sbin/depmod -a 4.1.6-v7+
make[2]: Leaving directory ‘/opt/github/mt7601u-ap/src/os/linux‘
make[1]: Leaving directory ‘/opt/github/mt7601u-ap/src‘
手动卸载
[email protected]:/opt/github/mt7601u-ap# make uninstall
make -C src/ uninstall
make[1]: Entering directory ‘/opt/github/mt7601u-ap/src‘
make -C /opt/github/mt7601u-ap/src/os/linux -f Makefile.6 uninstall
make[2]: Entering directory ‘/opt/github/mt7601u-ap/src/os/linux‘
rm -rvf /etc/Wireless/RT2870AP
removed `/etc/Wireless/RT2870AP/RT2870AP.dat‘
removed directory: `/etc/Wireless/RT2870AP‘
rm -rvf /lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/mt7601Uap.ko
removed `/lib/modules/4.1.6-v7+/kernel/drivers/net/wireless/mt7601Uap.ko‘
/sbin/depmod -a 4.1.6-v7+
make[2]: Leaving directory ‘/opt/github/mt7601u-ap/src/os/linux‘
make[1]: Leaving directory ‘/opt/github/mt7601u-ap/src‘
[email protected]:/opt/github/mt7601u-ap#
至于 AP 的设置,我还没有弄,要试验的话打算参照这篇文档:[【L】小米随身WiFi,Linux下AP热点驱动(开源)] (
http://blog.csdn.net/sumang_87/article/details/38168877)
再编译一个看起来不支持 ap 版本的 (不过好像也支持)
CC [M] /opt/github/mt7601-new/src/os/linux/../../mac/ral_omac.o
CC [M] /opt/github/mt7601-new/src/os/linux/../../os/linux/rt_usb_util.o
CC [M] /opt/github/mt7601-new/src/os/linux/../../os/linux/usb_main_dev.o
CC [M] /opt/github/mt7601-new/src/os/linux/../../common/rtusb_dev_id.o
CC [M] /opt/github/mt7601-new/src/os/linux/../../common/frq_cal.o
LD [M] /opt/github/mt7601-new/src/os/linux/mt7601Usta.o
Building modules, stage 2.
MODPOST 1 modules
CC /opt/github/mt7601-new/src/os/linux/mt7601Usta.mod.o
LD [M] /opt/github/mt7601-new/src/os/linux/mt7601Usta.ko
make[1]: Leaving directory ‘/usr/src/linux-rpi-4.1.y‘
cp -f /opt/github/mt7601-new/src/os/linux/mt7601Usta.ko /tftpboot 2>/dev/null || :
[email protected]:/opt/github/mt7601-new/src#
手动安装/卸载的方法同上。
以上就是今天花费大半天时间的工作记录,应该也是目前最新的关于树莓派2下编译360wifi2的教程,希望能对正在折腾树莓派2的朋友有所帮助。
本文最新版本地址:http://my.oschina.net/freeblues/blog/495623