1. 程式人生 > >NXP i.mx6ull iot 設定開機自動連wifi

NXP i.mx6ull iot 設定開機自動連wifi

用米爾MYS-6ULX-IOT單板設定開機自動連wifi,MYS-6ULX-IOT以NXP i.MX6UL/i.MX6ULL處理器,Cortex-A7核心為核心的嵌入式單板機,主頻為528MHz。配備了256MB高速DDR3、256M NAND Flash,集成了乙太網、WIFI、LCD介面、USB OTG、USB Host、TF Card、使用者按鍵、使用者LED、IO擴充套件介面等功能。

官方手冊 4.13 節說了wifi 怎麼配置連線。用的是wpa_supplicant, 命令比較麻煩,寫成指令碼,並把指令碼加到開機自啟動裡面比較好。

如何用NXP i.mx6ull MYS-6ULX-IOT設定開機自動連wifi設定開機自啟wifi 的過程以及過程中遇到的問題 我用onenote 記錄下來了,可以參考下面:

官方手冊 4.13 節說了wifi 怎麼配置連線。用的是wpa_supplicant , 命令比較麻煩,寫成指令碼,並把指令碼加到開機自啟動裡面比較好。編寫前,先按照教程把wifi.conf 檔案生成好。並於要寫的指令碼在同一路徑下。

指令碼編寫: 1 [email protected]:~# touch startwlan0 也可以 touch startwlan0.sh 1 [email protected]:~# vi startwlan0 寫下下面幾行: 1 #! /bin/sh 2 3 echo “wlan0 starting ” 4 5 wpa_supplicant -D wext -B -i wlan0 c wifi.conf 6 7 udhcpc -b -i wlan0 R 可以直接測試一波: 1

[email protected]:~# vi startwlan0 2 [email protected]:~# /startwlan0 3 wlan0 starting … 4 Successfully initialized wpa_supplicant 5 rfkill: Cannot open RFKILL control device 6 R8188EU: Firmware Version 11, SubVersion 1, Signature 0x88e1 7 MAC Address = 88:83:5d:c6:9d:5a 8 IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready 9 ioctl[SIOCSIWAP]: Operation not permitted 10 udhcpc (v1.24.1) started 11 Sending discover… 12 R8188EU: INFO indicate disassoc 13 R8188EU: INFO assoc success 14 IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready 15 Sending discover… 16 Sending select for 10.8.7.24… 17 Lease of 10.8.7.24 obtained, lease time 36000 18 /etc/udhcpc.d/50default: Adding DNS 10.8.2.253 19 /etc/udhcpc.d/50default: Adding DNS 61.132.163.68 20 /etc/udhcpc.d/50default: Adding DNS 120.24.63.146 這就連上了,檢查一下: 1
[email protected]
:~# ifconfig wlan0 2 wlan0 Link encap:Ethernet HWaddr 88:83:5d:c6:9d:5a 3 inet addr:10.8.7.24 Bcast:10.8 7.255 Mask:255.255.254.0 4 inet6 addr: fe80::8a83:5dff:fec6:9d5a/64 Scope:Link 5 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 6 RX packets:470 errors:0 dropped:31 overruns:0 frame:0 7 TX packets:36 errors:0 dropped:1 overruns:0 carrier:0 8 collisions:0 txqueuelen:1000 9 RX bytes:88027 (85.9 KiB) TX bytes:8675 (8.4 KiB)

新增到開機啟動中: 1 [email protected]:~# vi /etc/rc.local

編輯 rc.local 檔案 1 #!/bin/sh e 2 # 3 # rc.local 4 # 5 # This script is executed at the end of each multiuser runlevel. 6 # Make sure that the script will “exit 0” on success or any other 7 # value on error. 8 #

9 # In order to enable or disable this script just change the execution

10 # bits. 11 # 12 # By default this script does nothing. 13 export TSLIB_TSDEVICE=/dev/input/event1 14 ts_calibrate && ts_test & 15 cd /home/root/ 16 ./startwlan0 17 18 exit 0 19 ~ 20 ~ 21 ~

問題!這個就有點像電腦開了之後 插了一個USBwifi 一樣,所以沒插之前啟動服務沒用 : Reboot 後 發現 啟動了這個指令碼,但是網口的啟動在執行這個指令碼後面。 1 Running local boot scripts (/etc/rc.local)wlan0 starting //啟動了指令碼 2 xres = 480, yres = 272 3 Successfully initialized wpa_supplicant 4 rfkill: Cannot open RFKILL control device 5 Could not read interface wlan0 flags: No such device //出錯沒有裝置 6 WEXT: Could not set interface ‘wlan0’ UP 7 wlan0: Failed to initialize driver interface 8 udhcpc: SIOCGIFINDEX: No such device 9 error 10 11 Freescale i.MX Release Distro 4.1.15-2 0.1 mys6ull14x14 /dev/ttymxc0 12 13 mys6ull14x14 login: usb 1-1.2: device no response, device descriptor read/64, error 110 14 usb-storage 1-1.2:1.0: USB Mass Storage device detected 15 scsi host0: usb-storage 1-1.2:1.0 16 Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_D_CUT_1T1R_RomVer(0) 17 EEPROM ID = 0x8129 18 usbcore: registered new interface driver r8188eu //在這注冊的R8188eu 19 scsi 0:0:0:0: Direct-Access General UDisk 5.00 PQ: 0 ANSI: 2 20 sd 0:0:0:0: [sda] 32604160 512-byte logical blocks: (16.6 GB/15.5 GiB) 21 sd 0:0:0:0: [sda] Write Protect is off 22 sd 0:0:0:0: [sda] No Caching mode page found 23 sd 0:0:0:0: [sda] Assuming drive cache: write through 24 sda: 25 sd 0:0:0:0: [sda] Attached SCSI removable disk 26 FAT-fs (sda): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. 27 28 Freescale i.MX Release Distro 4.1.15-2 0.1 mys6ull14x14 /dev/ttymxc0 29 30 mys6ull14x14 login: root 31 [email protected]:~#

問:如何開機啟動 wifi 服務?

發了一封右鍵給官方,原來執行wpa_supplicant 前要先用ifconfig wlan0 up來啟動wlan0裝置後再執行後續操作。 gei到了! 修改: 1 #! /bin/sh 2 3 echo “wlan0 starting ” 4 5 ifconfig wlan0 up 6 7 wpa_supplicant -D wext -B -i wlan0 c wifi.conf 8 9 udhcpc -b -i wlan0 R

然後 reboot : 看到開wlan0的那部分:

1 Starting syslogd/klogd: done
2 * Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon
3   done.
4 Starting Telephony daemon
5 Starting Linux NFC daemon
6 Running local boot scripts (/etc/rc.local)wlan0 starting ...
7 R8188EU: Firmware Version 11, SubVersion 1, Signature 0x88e1
8 xres = 480, yres = 272
9 MAC Address = 88:83:5d:c6:9d:5a

10 IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready 11 Successfully initialized wpa_supplicant 12 rfkill: Cannot open RFKILL control device 13 ioctl[SIOCSIWAP]: Operation not permitted 14 udhcpc (v1.24.1) started 15 Sending discover… 16 R8188EU: INFO indicate disassoc 17 R8188EU: INFO assoc success 18 IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready //跑起來了 19 Sending discover… 20 Sending select for 10.8.7.59… 21 Lease of 10.8.7.59 obtained, lease time 36000

文字首發在NXP論壇米爾I.MX6ULL競賽專案專區,作者論壇ID:wbhb1234。