STA MODE
Previously, the module driver has been loaded with /config/wifi/ssw01bInit.sh, and the wlan0 network card already exists.Now, we pass Use the wpa_supplicant tool (in the /config/wifi directory) to connect WiFi hotspots.
Modify the appconfigs/wpa_supplicant.conf file,Fill in the wifi hotspot information。
# vi /appconfigs/wpa_supplicant.conf
You can see if you can search for WiFi before you link it.
# /config/wifi/iwlist wlan0 scan
Now try to connect:
# /config/wifi/wpa_supplicant -D nl80211 -i wlan0 -c /appconfigs/wpa_supplicant.conf -B &
Prompt: there are no relevant library files. These libraries are located in the /config/WiFi/ directory. Let’s configure LD_LIBRARY_PATH:
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/config/wifi
# /config/wifi/wpa_supplicant -D nl80211 -i wlan0 -c /appconfigs/wpa_supplicant.conf -B &
Connected but not assigned to IP ,because there is no DHCP service.
Let’s manually set up an IP and test whether we can communicate.
# ifconfig wlan0 192.168.1.134
# ping 192.168.1.166
Next, set up DNS and gateway for it, and then test whether it can surf the Internet:
# route add default gw 192.168.1.1
# echo nameserver 114.114.114.114 > /etc/resolv.conf
# ping www.baidu.com
OK, you can surf the Internet now.In order to enable it to automatically obtain IP, DNS and gateway when connecting to the hotspot, we need to add DHCP service。Of course, this service can be obtained from builderoot:
# cd buildroot-2020.05/
# ARCH=arm make menuconfig
Save the builderoot configuration:
# cp .config ./configs/ssd20x_defconfig -f
Recompile builderoot:
# make BR2_JLEVEL=4
After compiling, you can see that the DHCP service has been added:
# ls output/target/etc/init.d
The next step is to repackage and update rootfs.tar.gz as before.But a little troublesome is that the previous rootfs.tar.gz contains the files we added / modified (USB flash disk / SD card is automatically mounted).
You need to decide whether to add the new / modified files based on the rootfs.tar just compiled by buildfoot, or copy the service (files) from buildfoot based on rootfs.tar.gz?
Considering that some other services may be added in the future, and the new files will not change much, we choose the first method to add our new / modified files on the basis of rootfs.tar.
First, we need to put the newly added files in one place (here I put them in project/image/rootfs_ add_Files directory), and then copy in rootfs.mk:
# cd ..
# mkdir project/image/rootfs_add_files
# cd project/image/rootfs
# tar -xvf rootfs.tar.gz
# cp rootfs/sdcard/ rootfs/udisk/ ../rootfs_add_files/ -rf
# mkdir ../rootfs_add_files/etc/
# mkdir ../rootfs_add_files/etc/init.d
# cp rootfs/etc/hotplug/ ../rootfs_add_files/etc/ -r
# cp rootfs/etc/init.d/S10mdev ../rootfs_add_files/etc/init.d
# vi ../configs/i2m/rootfs.mk
Next, repackage the rootfs.tar generated by builderoot and replace rootfs.tar.gz:
# rm rootfs -rf
# mv rootfs.tar.gz rootfs.tar.gz_bk
# cp ../../../buildroot-2020.05/output/images/rootfs.tar ./
# mkdir rootfs
# tar -xvf ./rootfs.tar -C ./rootfs/
# tar -cvf rootfs.tar.gz ./rootfs
Recompile firmware:
# cd ../../../
# ./Release_to_customer.sh -f nand -p ssd201 -o 2D06
libstdc++.so.6.0.25-gdb.py,However, this file may be useful (it seems inappropriate to delete it directly). Therefore, we only need to screen it :
# vi project/image/configs/i2m/rootfs.mk
At the same time, add /config/WiFi to LD_LIBRARY_PATH:
# vi project/image/configs/i2m/rootfs.mk
Recompile firmware:
# ./Release_to_customer.sh -f nand -p ssd201 -o 2D06
There is no error this time. Update the firmware for the board. After the system starts, you can see that the DHCP service has been started:
# ps | grep dhcp
Next, start WiFi connection:
# /config/wifi/ssw01bInit.sh
# ifconfig wlan0 up
# vi /appconfigs/wpa_supplicant.conf
# /config/wifi/wpa_supplicant -D nl80211 -i wlan0 -c /appconfigs/wpa_supplicant.conf -B &
# ifconfig wlan0
# route
# cat /etc/resolv.conf
# ping www.baidu.com
You can see that the DHCP service is working normally.