wifi模块硬件接法

wifi模块接开发板的X27

开发板上其他硬件设置: R19 需要接一个0欧电阻,

JP4--2+3, JP3--打开, JP7--1+2,  JP8–1+2

硬件详细说明可参考开发板硬件手册L-830e_3中的17.4.16 Wi-Fi/Bluetooth Connector(X27)章节说明.

软件设置

ftp://ftp.phytec.cn/AM335x/BSP-Yocto-AM335x-PD19.1.1/machines.txt

从machines列表中,开发板带wifi软件设置的MACHINE为phycore-am335x-7,

使用wifi模块时,开发板需要选择这个machine的镜像.

kernel log

[    8.064802] bus: 'sdio': add driver wl1271_sdio
[    8.064844] bus: 'sdio': driver_probe_device: matched device mmc1:0001:1 with driver wl1271_sdio
[    8.238271] bus: 'sdio': really_probe: probing driver wl1271_sdio with device mmc1:0001:1
[    8.238329] wl1271_sdio mmc1:0001:1: no default pinctrl state
[    8.238497] wl1271_sdio: probe of mmc1:0001:1 rejects match -19
[    8.238533] bus: 'sdio': driver_probe_device: matched device mmc1:0001:2 with driver wl1271_sdio
[    8.238543] bus: 'sdio': really_probe: probing driver wl1271_sdio with device mmc1:0001:2
[    8.238567] wl1271_sdio mmc1:0001:2: no pinctrl handle
[    8.238923] Registering platform device 'wl12xx.0.auto'. Parent at mmc1:0001:2
[    8.238935] device: 'wl12xx.0.auto': device_add
[    8.238954] bus: 'platform': add device wl12xx.0.auto
[    8.239024] PM: Adding info for platform:wl12xx.0.auto
[    8.239252] driver: 'wl1271_sdio': driver_bound: bound to device 'mmc1:0001:2'
[    8.239325] bus: 'sdio': really_probe: bound device mmc1:0001:2 to driver wl1271_sdio
[   10.158451] bus: 'platform': add driver wl12xx_driver
[   10.158734] bus: 'platform': driver_probe_device: matched device wl12xx.0.auto with driver wl12xx_driver
[   10.326144] bus: 'platform': really_probe: probing driver wl12xx_driver with device wl12xx.0.auto
[   10.326205] wl12xx_driver wl12xx.0.auto: no default pinctrl state
[   10.343829] driver: 'wl12xx_driver': driver_bound: bound to device 'wl12xx.0.auto'
[   10.343959] bus: 'platform': really_probe: bound device wl12xx.0.auto to driver wl12xx_driver
[   10.344651] firmware_class: __allocate_fw_buf: fw-ti-connectivity/wl127x-nvs.bin buf=db828d00
[   10.351064] wl12xx_driver wl12xx.0.auto: loading /lib/firmware/updates/4.14.78-bsp-yocto-am335x-pd19.1.0/ti-connectivity/wl127x-nvs.bin failed with error -2
[   10.351107] wl12xx_driver wl12xx.0.auto: loading /lib/firmware/updates/ti-connectivity/wl127x-nvs.bin failed with error -2
[   10.351160] wl12xx_driver wl12xx.0.auto: loading /lib/firmware/4.14.78-bsp-yocto-am335x-pd19.1.0/ti-connectivity/wl127x-nvs.bin failed with error -2
[   10.356460] wl12xx_driver wl12xx.0.auto: direct-loading ti-connectivity/wl127x-nvs.bin
[   10.356504] firmware_class: fw_set_page_data: fw-ti-connectivity/wl127x-nvs.bin buf=db828d00 data=e13e2000 size=912
[   10.797493] wlcore: WARNING Detected unconfigured mac address in nvs, derive from fuse instead.
[   10.810439] wlcore: WARNING Your device performance is not optimized.
[   10.818734] wlcore: WARNING Please use the calibrator tool to configure your device.
[   10.828387] wlcore: WARNING Fuse mac address is zero. using random mac
[   10.885833] device: 'wlan0': device_add
[   10.886055] PM: Adding info for No Bus:wlan0
[   10.900499] wlcore: loaded
[   10.914161] firmware_class: __fw_free_buf: fw-ti-connectivity/wl127x-nvs.bin buf=db828d00 data=e13e2000 size=912
[   11.433825] firmware_class: __allocate_fw_buf: fw-ti-connectivity/wl127x-fw-5-sr.bin buf=dd547e80
[   11.433906] wl12xx_driver wl12xx.0.auto: loading /lib/firmware/updates/4.14.78-bsp-yocto-am335x-pd19.1.0/ti-connectivity/wl127x-fw-5-sr.bin failed with error -2
[   11.433924] wl12xx_driver wl12xx.0.auto: loading /lib/firmware/updates/ti-connectivity/wl127x-fw-5-sr.bin failed with error -2
[   11.433943] wl12xx_driver wl12xx.0.auto: loading /lib/firmware/4.14.78-bsp-yocto-am335x-pd19.1.0/ti-connectivity/wl127x-fw-5-sr.bin failed with error -2
[   11.452341] wl12xx_driver wl12xx.0.auto: direct-loading ti-connectivity/wl127x-fw-5-sr.bin
[   11.452393] firmware_class: fw_set_page_data: fw-ti-connectivity/wl127x-fw-5-sr.bin buf=dd547e80 data=e148a000 size=364044
[   11.453900] firmware_class: __fw_free_buf: fw-ti-connectivity/wl127x-fw-5-sr.bin buf=dd547e80 data=e148a000 size=364044
[   11.587648] wlcore: firmware booted (Rev 6.3.10.0.142)
[   11.607942] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready

linux配置wlan网络

使用ip link能找到wifi接口信息

root@phycore-am335x-7:~# ip link
5: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether 08:00:28:95:1b:fe brd ff:ff:ff:ff:ff:ff

扫描wifi网络

root@phycore-am335x-7:~# iw wlan0 scan | grep SSID

在/etc/wpa_supplicant.conf文件中配置wifi网络信息

country=CN
network={
    ssid="<SSID>"
    proto=WPA2
    psk="<KEY>"
}

配置好wifi信息后, 可用以下命令连接到wifi网络

root@phycore-am335x-7:~# wpa_supplicant -Dnl80211 -c/etc/wpa_supplicant.conf -iwlan0 &


wlan_log
root@phycore-am335x-7:~# wpa_supplicant -Dnl80211 -c/etc/wpa_supplicant.conf -iwlan0 &
[1] 204
root@phycore-am335x-7:~# Successfully initialized wpa_supplicant
rfkill: Cannot open RFKILL control device
wlan0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=CN
wlan0: SME: Trying to authenticate with 80:8f:1d[ 2735.061475] wlan0: authenticate with 80:8f:1d:0f:33:02
:0f:33:02 (SSID='PHYTECCN' freq=2412 MHz)
[ 2735.115718] wlan0: send auth to 80:8f:1d:0f:33:02 (try 1/3)
[ 2735.125308] wlan0: authenticated
wlan0: Trying to associate with 80:8f:1d:0f:33:02 (SSID='PHYTECC[ 2735.133482] wlan0: associate with 80:8f:1d:0f:33:02 (try 1/3)
N' freq=2412 MHz)
[ 2735.149762] wlan0: RX AssocResp from 80:8f:1d:0f:33:02 (capab=0x1031 status=0 aid=1)
[ 2735.176981] wlan0: associated
wlan0: Associated with 80:8f:1d:0f:33:02
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: WPA: Key negotiation completed with 80:8f[ 2735.396384] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
:1d:0f:33:02 [PTK=CCMP GTK=TKIP]
wlan0: CTRL-EVENT-CONNECTED - Connection to 80:8f:1d:0f:33:02 completed [id=0 id_str=]
[ 2735.442409] wlcore: Association completed.
wlan0: CTRL-EVENT-REGDOM-CHANGE init=COUNTRY_IE type=COUNTRY alpha2=CN

root@phycore-am335x-7:~# [ 2742.467562] wlan0: disassociated from 80:8f:1d:0f:33:02 (Reason: 3=DEAUTH_LEAVING)
iwlan0: CTRL-EVENT-DISCONNECTED bssid=80:8f:1d:0f:33:02 reason=3
wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
wlan0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=CN
wlan0: SME: Trying to authenticate with 80:8f:1d[ 2742.738105] wlan0: authenticate with 80:8f:1d:0f:39:20
:0f:39:20 (SSID='PHYTECCN' freq=2472 MHz)
p[ 2742.784316] wlan0: send auth to 80:8f:1d:0f:39:20 (try 1/3)
[ 2742.793065] wlan0: authenticated
wlan0: Trying to associate with 80:8f:1d:0f:39:20 (SSID='PHYTECCN' freq=2472 MHz)
[ 2742.803330] wlan0: associate with 80:8f:1d:0f:39:20 (try 1/3)
[ 2742.816354] wlan0: RX AssocResp from 80:8f:1d:0f:39:20 (capab=0x1431 status=0 aid=2)
[ 2742.831019] wlan0: associated
wlan0: Associated with 80:8f:1d:0f:39:20
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: WPA: Key negotiation completed with 80:8f:1d:0f:39:20 [PTK=CCMP GTK=TKIP]
wlan0: CTRL-EVENT-CONNECTED - Connection to 80:8f:1d:0f:39:20 completed [id=0 id_str=]
[ 2742.918905] wlcore: Association completed.

linux 开机自启动wlan服务

进入linux能查到以下wifi接口信息

root@phycore-am335x-7:~# ifconfig 
wlan0     Link encap:Ethernet  HWaddr 08:00:28:95:1B:FE  
          inet6 addr: fe80::a00:28ff:fe95:1bfe/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:40 errors:0 dropped:0 overruns:0 frame:0
          TX packets:45 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5870 (5.7 KiB)  TX bytes:5777 (5.6 KiB)

wifi接口为wlan0, 新建wlan配置文件wpa_supplicant-wlan0.conf, 存放在/etc/wpa_supplicant目录下

root@phycore-am335x-7:~# mkdir /etc/wpa_supplicant
root@phycore-am335x-7:~# cd /etc/wpa_supplicant
root@phycore-am335x-7:/etc/wpa_supplicant# vi wpa_supplicant-wlan0.conf

配置文件内容如下:

country=CN
network={
    ssid="<SSID>"
    proto=WPA2
    psk="<KEY>"
}

配置wlan0接口动态IP使能:/lib/systemd/network/20-wlan0.network

/lib/systemd/network/20-wlan0.network
[Match]
Name=wlan0
 
[Network]
DHCP=yes

开启wlan连接:

root@phycore-am335x-7:~# systemctl enable wpa_supplicant@wlan0.service
Created symlink from /etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service to /lib/systemd/system/wpa_supplicant@.service.
root@phycore-am335x-7:~# systemctl start wpa_supplicant@wlan0.service

在wifi连接设置成系统服务后, 当wifi信号断开后可以自动重新连接.

  • No labels