The realization of WiFi function under Linux

Source: Internet
Author: User

One, embedded Linux four-piece set configuration

1, the basis of network card selection:

A. network card can not be randomly selected, otherwise it will not. The network card is based onthekernel menuconfig, device drivers, network device support, Wireless LAN A bunch of drives,however, it's not over yet ;

B.buildroot, Menuconfig, target packet, hardware handling, * * * firmwares, Linux-firmware--WI Fi firmwares , a bunch of driven bin.

# These network cards are very lewd, on the official web placed ten years ago firmware, but to these software giants issued the latest driver, but also not open source, DTH DTH.

# Next is to turn on some features

2. Open kernel rfkill function

Menuconfig-Networking Support-RF switch subsystem support

3. Turn on kernel and buildroot Driver Support

A, that is the first step of the two places, and then:

b,Networking Support, Networking options

<*> Packet Socket

[*] netlink:mmapped IO

[*] IP:DHCP Support

[*] IP:BOOTP Support

[*] Ip:rarp Support

[*] Network packet filtering (replaces IPChains)// Add, rear sub-option optional, configure config_netfilter

4.buildroot Package setup

Network applications, target packet, Menuconfig, BuildRoot

Choose hostapd,iw,wireless tools,wpa_supplicant(Pay attention to select all)

5. But it's not over yet.

BuildRoot, Busybox-menuconfig, networking utilities, UDHCPD, UDHCPC

Well, you can get out of your misery now, telnetd .

# This time, should be able to successfully start the network card, need to verify /sys/class/net/wlan0 inside There is no phy80211 This thing, if not, Description The driver installation failed.

# If the open source drive is found online, and you do not need to open the AP, then even if there is no phy80211 can also access the Internet, see attached a

# If your network card is USB , and compare the water, then the network card will sometimes crash, this time you how to do, it will not again bird you, this time, uh, pull out, and then inserted = =.

ii. application Configuration (client article)

1,ifconfig wlan0 up

2, Situation one: the AP to connect does not have a password

IW dev wlan0 Connect "Guest hi-t"

Udhcpc-i Wlan0

# then you can use ping .

# after use,the Guest signal is good, the packet loss rate is only 10% up and down,udhcpc looking for IP The speed is also very fast.

3.case Two: The AP to be connected uses WPA Encryption

need to use wpa_supplicant

A, create a file /etc/wpa_supplicant.conf, if it is in the buildroot put this package up, then should have this file;

b, edit file:/etc/wpa_supplicant.conf:

Ctrl_interface=/var/run/wpa_

Ap_scan=1// must have this sentence, which is arranged by the Director to drop

network={

Ssid= "Zhd-1" # this is The name of the AP

Psk= "123456789" # This is the AP 's password

}

Save exit.

C,wpa_supplicant-d nl80211-i wlan0-c/etc/wpa_supplicant

-D indicates the driver; -I represents the network card ;-C represents the configuration file

If you see The debug output of the ctrl-event-connected proves that the configuration is right.

If you see pre-shared key maybe incorrect andcontinue to appear, the password may be wrong.

If you see other information, it is possible that the configuration file is incomplete, even the driver itself is not complete.

D,ctrl-event-connected After a period of time, if there is no output, prove that the connection is stable, you can proceed to the next step:

wpa_supplicant-d nl80211-i wlan0-c/etc/wpa_supplicant-b, let wpa_supplicant reside in the background, control network card

in client mode;

E,udhcpc-i wlan0, get IP

F, after use,wpa_cli-i wlan0 terminate, exit wpa_supplicant, and stop Wlan0

# Use zhd-1 test with password wifi, please be patient, do not casually ^c , please wait. (Ping 's packet loss rate is above 40% ...) )

Third, application configuration ( AP article)

1.sh:iw list

A. find supported interface modes, find an AP,lucky, go Next;

B. No AP exist, OH shit!   and fuck too! You doomed, breake a window and just jump off, goodbye and never say hi ~ ~ ~

2, the establishment of /etc/hostapd.conf, the contents are as follows:

Interface=wlan0 # The Nic used

driver=nl80211 # The drive used

SSID=HOSTAPD # Hot name

Channel=6 # also known as band,WiFi has a total of Five channels, of which 1,6 and One is the best channel

Hw_mode=g # can be a,b,g

Ignore_broadcast_ssid=0 # Broadcast SSID

Auth_algs=1 # 1=WPA2,2=wep

wpa=2 # 1=WPA1, 2=wpa2, 3=both

wpa_passphrase=12345678 # Password

WPA_KEY_MGMT=WPA-PSK # Encryption Method

Wpa_pairwise=tkip # 802.11g encryption Algorithm

RSN_PAIRWISE=CCMP # 802.11i encryption Algorithm

3,hostapd-d/etc/hostapd.conf

-D means debug mode, so will come out a large piece of information, carefully check to see if there is a file not found error, generally due to configuration errors caused by, Sometimes it can be the driving reason. This time with mobile phone should be able to see there is a hot spot called HOSTAPD ...

4,Next, configuration udhcpd, configuration file samples can be buildroot/output/build/busybox***/examples/udhcpd/ found in udhcpd.conf, use the cat UDHCPD | grep ^\#-v command to view the default configuration

5,then, in fact, this east is built on the basis of the wired network, and to be used as a router to the Internet, and we only need to connect the communication is OK , so there are a lot of things is not necessary, the core configuration, only the following several:

# determine The range of IP

Start 192.168.0.20

End 192.168.0.25

# devices selected for UDHCPD

Interface Wlan0

Option Subnet 255.255.255.0 # Subnet Mask

Option Router 192.168.0.1 # Gateway (this is the native)

Option Lease 86400 # lease time, in fact , is the lifetime of the IP address, in seconds,86400 is a day

set well after, save in /etc/udhcpd.conf;

6,hostapd/etc/hostapd.conf-b

Ifconfig wlan0 192.168.0.1 netmask 255.255.255.0 # Note, be sure to match udhcpd.conf strictly

Touch/var/lib/misc/udhcpd.leases

Udhcpd-s/etc/udhcpd.conf

7, use mobile phone to find hostapd hotspot, connection, after the connection, check the phone IP;

8, Development Board:ping-i wlan0 mobile phone IP, if there is a response, it succeeded.

attached one, open source-driven application configuration (client only )

# Now the driver does not support iwconfig, Configure any new WLAN with Iwconfig Drivers will be error -

1,ifconfig wlan0 up

2,iwconfig wlan0 Scan # get A list of nearby APs

3,iwconfig wlan0 Essid "zhd-1" key "123456789"

# Impression: The script is very important, to add to the system more and more things, have to learn to write a script, after the buildroot , but also to use the script to rootfs in a lot of files, modify a pile of things, if done manually, this has to wait until se years ah ...

The realization of WiFi function under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.