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 root@mys6ull14x14:~# touch startwlan0
也可以 touch startwlan0.sh
1 root@mys6ull14x14:~# 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 root@mys6ull14x14:~# vi startwlan0
2 root@mys6ull14x14:~# /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 root@mys6ull14x14:~# 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 root@mys6ull14x14:~# 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 root@mys6ull14x14:~#

问:如何开机启动 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。

猜你喜欢

转载自blog.csdn.net/m0_37358682/article/details/82692497