搭建编译环境及编译驱动
The first method.
I use this to compile various modules I use. No need to compile the full linux source, just need to configure it to compile additional modules, takes less than 5 minutes. A full kernel compile can take around 10hrs on a Pi.
create directory for source files in my home directory (/home/pi)
mkdir src
go to source file directory
cd src
download linux source - --depth will restict the amount downloaded as you don't need the whole repository
git clone --depth 500 https://github.com/raspberrypi/linux.git
download firmware source - restrict the amount downloaded with --depth
git clone --depth 20 https://github.com/raspberrypi/firmware.git
set up some symbolic links needed by compile
sudo ln -s /home/pi/src/linux /lib/modules/$(uname -r)/build sudo ln -s /home/pi/src/linux/arch/arm /home/pi/src/linux/arch/armv6l
enter linux directory
cd linux
set up linux source to 3.12.22+ #690 (git checkout commit-id)
for a different version change the commit-id
for 3.12.22+ #691 use commit-id 1981ddebd4
git checkout 99df631ec3
enter firmware directory and set for 3.12.22+ #690 (git checkout commit-id)
for 3.12.22+ #691 use commit-id 462f3e3f47
cd ../firmware git checkout 5bb0317210
go back to linux source directory
cd ../linux
set up linux to compile your module - make mrproper: init sourc
-
make bcmrpi_defconfig: set up .config file
-
make modules_prepare: compile to set up for module
-
cp ../firmware/extra/Module.symvers . - copy file Module.symvers from firmware to linux directory
-
NOTE: period (full stop) after Module.symvers
make mrproper && make bcmrpi_defconfig && make modules_prepare && cp ../firmware/extra/Module.symvers .
now go to your DPO_MT7601U_LinuxSTA_3.0.0.4_20130913
download source directory wherever it is
cd ../DPO_MT7601U_LinuxSTA_3.0.0.4_20130913
init module source and compile it
make clean && make
and hopefully it will compile without errors.
For other versions of linux to find the necessary commit-id's go to https://github.com/raspberrypi/firmware/commits/master and look though the list of firmware commits for one close to your version. Then select browse code (<>
) and look at firmware/extra/uname-string
to check linux version 3.12.xx+
and build number, #123
. When you find the right version and build look at firmware/extra/git_hash
for the linux source commit-id. The full commit-id is a 40 character value but you should only need to use the first 7-10 character to set the right source version.
I've had some problems with modules compiled using the default gcc version (4.6) and have updated mine to gcc-4.7 currently. Also to get a different Realtek driver I use to compile I had to make a few changes.
Reference: http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=82811#p587254
The second method.
- Downloaded v3.0.0.4 driver from Mediatek
- Compiled and installed driver (I had errors during compilation but was able to sort it out.)
- ra0 appeared in ifconfig, updated /etc/network/interfaces to include ra0 (copied format of wlan0)
- Installed wicd-curses, updated Preference to use ra0 as wireless network.
- Wifi signals were detected. Selected desired wifi AP. Input settings for the AP.
- Connect!
I downloaded and compiled sources mt7601 v3.0.0.4 from MediaTek http://www.mediatek.com/en/downloads/mt7601u-usb/. It works fine!
I have uploaded binaries compiled for version 3.10.37+. I have uploaded the full folder compiled here.
tar -vxzf mt7601u_3.0.0.4.tar.gz sudo make install sudo insmod /lib/modules/3.10.37+/kernel/drivers/net/wireless/mt7601Usta.ko sudo reboot
The kernel version must be 3.10.27+ #667
. If you don't have it, you can upgrade/downgrade
executing the commands:
sudo rpi-update bb7abd7d34e758fc97546620128bf67a45016a5f sudo reboot
Reference: http://www.raspberrypi.org/forums/viewtopic.php?t=49864&p=541423#p541423
配置运行网卡
1.make ra0 appear as wlan0
sudo vi /etc/udev/rules.d/95-ralink.rules
-
configure interfaces
sudo vi /etc/network/interfaces
with the following:
auto lo iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf #wireless-power off iface default inet dhcp up iwpriv $IFACE set Debug=0
3.Set up wpa_supplicant.conf
sudo vi /etc/wpa_supplicant/wpa_supplicant.conf
with:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev ap_scan=1 #update_config=1 network={ ssid="MYPI" psk="ABABABABAB" # Protocol type can be: RSN (for WP2) and WPA (for WPA1) proto=RSN # Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise) key_mgmt=WPA-PSK # Pairwise can be CCMP or TKIP (for WPA2 or WPA1) pairwise=CCMP #Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SH$ auth_alg=OPEN }
-
Edit RT2870STA.dat
sudo vi /etc/Wireless/RT2870STA/RT2870STA.dat
Ensure you have the following entries:
SSID=MYPI AuthMode=WPAPSK EncrypType=AES WPAPSK=ABABABABAB
The third method
查看USB设备类型
寻找USB无线网卡是否已经被系统识别。
pi@raspberrypi ~ $ lsusb Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter 《=========
USB无线网卡已经被正常识别
查看内核模块
是否支持你的无线网卡
pi@raspberrypi ~ $ lsmod Module Size Used by snd_bcm2835 15846 0 snd_pcm 77560 1 snd_bcm2835 snd_seq 53329 0 snd_timer 19998 2 snd_pcm,snd_seq snd_seq_device 6438 1 snd_seq snd 58447 5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device snd_page_alloc 5145 1 snd_pcm leds_gpio 2235 0 led_class 3562 1 leds_gpio 8192cu 489381 0 《========
无线网卡对应的内核模块已经自动加载了。
查看无线设备配置
pi@raspberrypi ~ $ iwconfig wlan0 unassociated Nickname:”<WIFI@REALTEK>” Mode:Managed Frequency=2.412 GHz Access Point: Not-Associated Sensitivity:0/0 Retry:off RTS thr:off Fragment thr:off Power Management:off Link Quality:0 Signal level:0 Noise level:0 Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:0 Missed beacon:0 lo no wireless extensions. eth0 no wireless extensions.
配置网络界面设置
sudo vi /etc/network/interfaces ===== auto lo iface lo inet loopback iface eth0 inet dhcp auto wlan0 allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp
如果你不想设置为Dhcp动态IP,也可以设置静态IP,则文件内容如下:
auto lo iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 iface wlan0 inet manual address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
其它配置
auto lo iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 iface wlan0 inet static wpa-ssid 你要连接的wifi-ssid wpa-psk 你的wpa连接密码 address 192.168.1.106 # 设定的静态IP地址 netmask 255.255.255.0 # 网络掩码 gateway 192.168.1.1 # 网关 network 192.168.1.1 # 网络地址 #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp
配置无线网卡设置文件
sudo vi /etc/wpa_supplicant/wpa_supplicant.conf 注意主要修改IFI接入点名称和WIFI接入密码。 network={ ssid="WIFI接入点名称 proto=RSN key_mgmt=WPA-PSK pairwise=CCMP TKIP group=CCMP TKIP psk="WIFI接入密码" }
重启树莓派
sudo reboot
Reference: http://www.2fz1.com/?cat=91
参考资料:
http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=82811
https://github.com/raspberrypi/firmware/commits/master
利用360wifi实现树莓派无线上网 http://my.oschina.net/u/1045794/blog/206453 未实验
在Linux下使用360随身WiFi 2
http://www.freemindworld.com/blog/2013/131010_360_wifi_in_linux.shtml
小米随身WiFi,Linux下AP热点驱动 http://blog.csdn.net/sumang_87/article/details/38168877
在Raspberry上使用小度WIFI http://www.cnblogs.com/hamwolf/archive/2013/11/07/3412231.html
其它
ls文件大小
ls -l --block-size=M