Original address: http://www.cnblogs.com/NickQ/p/8973880.html
Bring the development board online
USB driver part
In arch/arm/mach-s3c2440/mach-smdk2440.c, modify the Usb clock.
#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;
}
call the initialization function
//在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();
}
Configure the kernel, enable USB and wireless network card (RT3070) drivers
[*] 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 port
tar zxvf wireless_tools.29.tar.gz cd wireless_tools.29
Modify 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
Use make to compile.
Copy the generated command tools: ifrename, iwevent, wgetid, iwspy, iwlist, iwconfig, iwpriv, libiw.so.29 to /bin of the development board, and grant permissions chmod 777 iw* libiw.so respectively. 29.make openssl library
tar zxvf openssl-1.0.0s.tar.gz mkdir install
Modify Makefile
modify path
INSTALL_PREFIX= INSTALLTOP=/home/nick/s3c2440/3rdparty/openssl-1.0.0s/install OPENSSLDIR=/home/nick/s3c2440/3rdparty/openssl-1.0.0s/install
Modify compile options
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
Use sudo make && sudo make install to compile and install
Copy libcrypto.a; libssl.a to /lib on the development board
In the next step wpa_supplicant needs to use this library, so install will be referenced.
wpa_supplicant porting
tar zxvf wpa_supplicant-0.7.3.tar.gz cd ./wpa_supplicant-0.7.3/wpa_supplicant/ cp defconfig .config
Modify.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
Compile with make
Copy wpa_cli, wpa_supplicant, and wpa_passphrase to the /bin directory of the development board. and give permissions chmod 777: wpa_cli, wpa_supplicant, wpa_passphraseDevelopment board configuration and operation
Create the wpa_supplicant.conf configuration file in the /etc directory
cd /etc wpa_passphrase ssid psk >> wpa_supplicant.conf
ssid is the WIFI username
psk is the WIFI password
For example: wpa_passphrase 16402_1 1640216402 >> wpa_supplicant.conf
cat ./wpa_supplicant.conf network={ ssid="16402_1" #psk="1640216402" psk=136a6b18bd0d21eb12d6bc591fa652d628cbb438e8f29fcfeb8d763c0bf15ec2 } [nick@NickQ_fl2440 ~]#
Modify wpa_supplicant.conf, add encryption methods and other configurations
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 means the authentication method using the WPA-PSK shared key
proto=WPA2 means the WPA2 encryption method
pairwise = TKIP CCMP and group = TKIP CCMP means automatically matching the encryption algorithm CCMP or TKIP;
Start RT3070 and configure RT3070 wireless network card parameters
wpa_supplicant -B -d -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
Among them:
-d: add debugging information
-B: background daemon
-c: specify the configuration file
-Dwext: wext is the driver name
-iwlan0: wlan0 is the network interface name
iwconfig View connection status, connected
[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 Check the network status and find that there is no IP address
[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)
Configure network IP, subnet mask, gateway
配置网络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 test
[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
Auto-start
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