原文地址:http://www.cnblogs.com/NickQ/p/8973880.html
使开发板上网
-
USB驱动部分
在arch/arm/mach-s3c2440/mach-smdk2440.c中,修改Usb时钟。
#include <mach/regs-clock.h> /* Add 2018/04/25-14:54:18 By Nick, for usb_s3c2440_init() */
#include <plat/udc.h> /* Add 2018/04/25-14:54:26 By Nick to support USB device gadget, 2017.5.4 */
#include <linux/delay.h>
/* USB device UDC support add by 2018/04/25-14:54:57 By Nick */
static struct s3c2410_udc_mach_info smdk2440_udc_cfg __initdata = {
.pullup_pin = S3C2410_GPG(9),
};
/* Add by 2018/04/25-14:55:19 By Nick, fix device descriptor read/64, error -62 bug, value refer to datasheet P255 */
int usb_s3c2440_init(void)
{
/* Input Frequency is 12.0000MHz, and MDEV=0x38 PDIV=2 SDIV=2, so output frequency 48.00MHz */
unsigned long upllvalue = (0x38<<12)|(0x02<<4)|(0x02);
while (upllvalue != __raw_readl(S3C2410_UPLLCON))
{
__raw_writel(upllvalue, S3C2410_UPLLCON);
mdelay(1);
}
return 0;
}
调用初始化函数
//在smdk2440_map_io函数中调用usb_s3c2440_init(),修改USB时钟
static void __init smdk2440_map_io(void)
{
s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
s3c24xx_init_clocks(12000000);
s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
usb_s3c2440_init();
}
-
配置内核,使能USB和无线网卡(RT3070)驱动
[*] Networking support --->
-*- Wireless --->
<*> cfg80211 - wireless configuration API
[ ] nl80211 testmode command
[ ] enable developer warnings
[ ] cfg80211 regulatory debugging
[*] enable powersave by default
[ ] cfg80211 DebugFS entries
[*] cfg80211 wireless extensions compatibility
[*] Wireless extensions sysfs files
{*} Common routines for IEEE802.11 drivers
[ ] lib80211 debugging messages
<*> Generic IEEE 802.11 Networking Stack (mac80211)
Default rate control algorithm (Minstrel) --->
[ ] Enable mac80211 mesh networking (pre-802.11s) support
[ ] Export mac80211 internals in DebugFS
[ ] Select mac80211 debugging features --->
Device Drivers --->
Generic Driver Options --->
(/sbin/hotplug) path to uevent helper
[ ] Maintain a devtmpfs filesystem to mount at /dev
[ ] Select only drivers that don't need compile-time external firmware
[ ] Prevent firmware from being built
-*- Userspace firmware loading support
[*] Include in-kernel firmware blobs in kernel binary
() External firmware blobs to build into the kernel binary
[ ] Driver Core verbose debug messages
[ ] Managed device resources verbose debug messages
[*] Network device support --->
[*] Wireless LAN --->
<*> Ralink driver support --->
< > Ralink rt2500 (USB) support
< > Ralink rt2501/rt73 (USB) support
<*> Ralink rt27xx/rt28xx/rt30xx (USB) support
[ ] rt2800usb - Include support for rt33xx devices
[ ] rt2800usb - Include support for rt35xx devices (EXPERIMENTAL)
[ ] rt2800usb - Include support for rt53xx devices (EXPERIMENTAL)
[ ] rt2800usb - Include support for unknown (USB) devices
[*] Ralink debug output
-
Wireless tools移植
tar zxvf wireless_tools.29.tar.gz
cd wireless_tools.29
修改Makefile
## Compiler to use (modify this for cross compile).
CC = /opt/xtools/arm920t/bin/arm-linux-gcc
## Other tools you need to modify for cross compile (static lib only).
AR = /opt/xtools/arm920t/bin/arm-linux-ar
RANLIB = /opt/xtools/arm920t/bin/arm-linux-ranlib
使用make编译.
将生成的命令工具:ifrename、iwevent、wgetid、iwspy、iwlist、iwconfig、iwpriv,libiw.so.29拷贝到开发板的/bin下,并分别赋予权限chmod 777 iw* libiw.so.29.
-
制作openssl库
tar zxvf openssl-1.0.0s.tar.gz
mkdir install
修改Makefile
- 修改路径
INSTALL_PREFIX=
INSTALLTOP=/home/nick/s3c2440/3rdparty/openssl-1.0.0s/install
OPENSSLDIR=/home/nick/s3c2440/3rdparty/openssl-1.0.0s/install
- 修改编译选项
CC= /opt/xtools/arm920t/bin/arm-linux-cc
CFLAG= -O
DEPFLAG= -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_STORE
PEX_LIBS=
EX_LIBS=
EXE_EXT=
ARFLAGS=
AR= /opt/xtools/arm920t/bin/arm-linux-ar $(ARFLAGS) r
RANLIB= /opt/xtools/arm920t/bin/arm-linux-ranlib
- 使用sudo make && sudo make install 编译安装
拷贝libcrypto.a; libssl.a到开发板的/lib下
在下一步wpa_supplicant中需要使用这个库,因此install将会被引用。
-
wpa_supplicant移植
tar zxvf wpa_supplicant-0.7.3.tar.gz
cd ./wpa_supplicant-0.7.3/wpa_supplicant/
cp defconfig .config
修改.config
CC=/opt/xtools/arm920t/bin/arm-linux-gcc -L /home/nick/s3c2440/3rdparty/openssl-1.0.0s/install/lib
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
#CFLAGS += -Os
CFLAGS += -I/home/nick/s3c2440/3rdparty/openssl-1.0.0s/install/include
#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
LIBS += -L /home/nick/s3c2440/3rdparty/openssl-1.0.0s/install/lib
使用make编译
将wpa_cli,wpa_supplicant,wpa_passphrase拷贝到开发板的/bin目录下。并给予权限 chmod 777:wpa_cli,wpa_supplicant,wpa_passphrase
-
开发板配置以及操作
在/etc目录下创建wpa_supplicant.conf配置文件
cd /etc
wpa_passphrase ssid psk >> wpa_supplicant.conf
ssid 是WIFI的用户名
psk 是WIFI的密码
例如:wpa_passphrase 16402_1 1640216402 >> wpa_supplicant.conf
cat ./wpa_supplicant.conf
network={
ssid="16402_1"
#psk="1640216402"
psk=136a6b18bd0d21eb12d6bc591fa652d628cbb438e8f29fcfeb8d763c0bf15ec2
}
[nick@NickQ_fl2440 ~]#
修改wpa_supplicant.conf,加入加密方式等配置
cat wpa_supplicant.conf
network={
ssid="16402_1"
key_mgmt=WPA-PSK
proto=WPA2
pairwise=TKIP CCMP
group=TKIP CCMP
psk="1640216402"
}
key_mgmt=WPA-PSK 表示 采用WPA-PSK共享密钥的认证方式
proto=WPA2 表示 WPA2加密方式
pairwise = TKIP CCMP 和 group =TKIP CCMP 表示 自动匹配加密算法CCMP或TKIP;
启动RT3070并配置RT3070无线网卡参数
wpa_supplicant -B -d -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
其中:
-d :增加调试信息
-B:后台守护进程
-c:指定配置文件
-Dwext:wext为驱动名称
-iwlan0 :wlan0为网络接口名称
iwconfig 查看连接状态,已连接
[nick@NickQ_fl2440 ~]# iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
wlan0 IEEE 802.11bgn ESSID:"16402_1"
Mode:Managed Frequency:2.437 GHz Access Point: 14:75:90:7C:18:AC
Bit Rate=6.5 Mb/s Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
Link Quality=51/70 Signal level=-59 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:1 Missed beacon:0
ifconfig 查看网络状态,发现无IP地址
[nick@NickQ_fl2440 ~]# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:A1:B0:40:6F:1E
inet6 addr: fe80::2a1:b0ff:fe40:6f1e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:600 (600.0 B) TX bytes:876 (876.0 B)
配置网络IP,子网掩码,网关
配置网络IP,子网掩码:ifconfig wlan0 192.168.168.100 netmask 255.255.255.0
配置默认网关:route add default gw 192.168.168.1
配置DNS: echo "nameserver 8.8.8.8" > /etc/resolv.conf
Ping测试
[nick@NickQ_fl2440 ~]# ping baidu.com
PING baidu.com (220.181.57.216): 56 data bytes
64 bytes from 220.181.57.216: seq=0 ttl=55 time=25.000 ms
64 bytes from 220.181.57.216: seq=1 ttl=55 time=65.000 ms
64 bytes from 220.181.57.216: seq=2 ttl=55 time=65.000 ms
-
开机自启动
cd /etc/init.d/
vim S20_conf_wifi
#!/bin/sh
ifconfig wlan0 up
wpa_supplicant -B -d -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
ifconfig wlan0 192.168.168.100 netmask 255.255.255.0
route add default gw 192.168.168.1