1 电路相关
- 复位芯片方法1
echo ON > /dev/wifi_reset
echo OFF > /dev/wifi_reset
- 复位芯片方法2
echo 71 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio71/direction
echo 0 > /sys/class/gpio/gpio71/value
sleep 2
echo 1 > /sys/class/gpio/gpio71/value
2 编译步骤
内核编译:
- Networking support ->Networking options ->802.1d Ethernet Bridging
- CONFIG_RFKILL=y
文件系统: - 工具需要:bridge-utils,wireless-tools, dhcpd
3 测试步骤
3.1 配置运行的动态库路径:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./:/config/lib/:/customer/lib/:/config/wifi/
export PATH=$PATH:/config/wifi/
3.2 加载驱动:
insmod /config/wifi/llc.ko
insmod /config/wifi/stp.ko
insmod /config/wifi/bridge.ko
/config/wifi/ssw01bInit.sh
3.2.1 初始化wifi芯片
- 芯片 BANK-0xe OFFSET-0x30 写入 0x11
- 芯片 BANK-0x103c OFFSET-0x8 写入 0x0
- 延时一段时间
- 芯片 BANK-0x103c OFFSET-0x8 写入 0x10
# /config/riu_w e 30 11
/config/riu_w 103c 8 00
sleep 0.01
/config/riu_w 103c 8 10BANK:0xE 16bit-offset 0x30
0x0011
# /config/riu_w 103c 8 00
BANK:0x103C 16bit-offset 0x08
0x0001
# sleep 0.01
# /config/riu_w 103c 8 10
BANK:0x103C 16bit-offset 0x08
0x0011
#
3.2.2 建立必要的文件目录
touch /appconfigs/hosts
mkdir -p /var/run/wpa_supplicant
chmod 777 /var/run/wpa_supplicant
mkdir -p /var/run/hostapd
chmod 777 /var/run/hostapd
mkdir -p /appconfigs/misc/wifi/ # 具体不知道干什么用
mkdir -p /var/wifi/misc/ # 保存 dnsmasq一些信息
mkdir -p /var/lib/misc/ # 一些wifi的日志和配置
3.2.3 加载外设WIFI芯片驱动
- 告警信息:[Sstar_log]: wsm_write_mib fail !!! mibId=4132
- 告警信息:[Sstar_log]:apollo wifi : can’t open /data/.mac.info
[Sstar_log]:efuse data is [0x1,0x3b,0x2,0x2,0x2,0x7,0x0,0x0,0x24:0x14:0x7:0x16:0x65:0x61] - 告警信息:[Sstar_log]:apollo wifi : can’t open /Sstar_txpwer_dcxo_cfg.txt
- 告警信息:[Sstar_log]: br0_netdev_open()-1116: dev_get_by_name(br0) failed2![Sstar_log]:br0_netdev_open()-1116: dev_get_by_name(br0) failed2!
# insmod /config/wifi/ssw101b_wifi_HT40_usb.ko
[Sstar_log]:Sstar_usb_module_init 0
[Sstar_log]:Sstar_init_firmware
[Sstar_log]:xxxx minstrel ht init
[Sstar_log]:SVN_VER=14606,DPLL_CLOCK=2,BUILD_TIME=[===USB-ARES_B==
[Sstar_log]:Probe called
[Sstar_log]:CONFIG_USE_DMA_ADDR_BUFFER TX_BUFFER_SIZE 800
[Sstar_log]:CONFIG_USB_AGGR_URB_TX enable cnt tx_dma_addr_buffer_end( (null))tx_dma_addr_buffer( (null)),0
[Sstar_log]:Sstar_usb_urb_malloc CONFIG_USE_DMA_ADDR_BUFFER max_num 4, total 131072
[Sstar_log]:CONFIG_USB_AGGR_URB_TX enable cnt tx_dma_addr_buffer_end(c42c0000)tx_dma_addr_buffer(c42e0000),8
[Sstar_log]:CONFIG_TX_NO_CONFIRM
[Sstar_log]:self->tx_hwChanId 0
[Sstar_log]:Allocated hw_priv @ c2ba50a0
[Sstar_log]:Sstarwifi USB_USE_TASTLET_TXRX enable
[Sstar_log]:Sstar_before_load_firmware++
[Sstar_log]:+++++++++++++++++1.1v++++++++++++++++++
[Sstar_log]:===================~_~====================
[Sstar_log]:Sstar_start_load_firmware++
[Sstar_log]:Sstar_start_load_firmware: used firmware.h=
[Sstar_log]:Sstar_set_firmare:fw_iccm(c96ba000)
[Sstar_log]:Sstar_set_firmare:fw_dccm(c8571000)
[Sstar_log]:Sstar_start_load_firmware: START DOWNLOAD ICCM=========
[Sstar_log]:Sstar_load_firmware_generic: addr 10000: len 20000
[Sstar_log]:Sstar_start_load_firmware: START DOWNLOAD DCCM=========
[Sstar_log]:Sstar_load_firmware_generic: addr 800000: len 8000
[Sstar_log]:Sstar_after_load_firmware++
[Sstar_log]:Sstar_after_load_firmware:0x1610102c=0x4020e
[Sstar_log]:Sstar_after_load_firmware:0x1610102c=0x1020f
[Sstar_log]:Sstar_after_load_firmware:0x16101000=0x8000e08
[Sstar_log]:set_block_size=256
[Sstar_log]:firmwareCap f58f
[Sstar_log]:firmwareCap2 888f
[Sstar_log]:wsm_caps.firmwareCap 888ff58f
[Sstar_log]:apollo wifi WSM init done.Input buffers: 32 x 2048 bytesHardware: 7.2WSM firmware [=MODEM=RF=Ares_AX 2GHZ Dec 24 2019 19:59:25NOTXConfrim], ver: 8677, build: 2690, api: 1060, cap: 0x888FF58F Config[30008] expection 900a5c0, ep0 cmd addr 901be2c NumOfStations[8] NumOfInterfaces[3]
[Sstar_log]:EFUSE(8) [0]
[Sstar_log]:EFUSE(I) [0]
[Sstar_log]:EFUSE(B) [1]
[Sstar_log]:CAPABILITIES_SSTAR_PRIVATE_IE [1]
[Sstar_log]:CAPABILITIES_NVR_IPC [1]
[Sstar_log]:CAPABILITIES_NO_CONFIRM [1]
[Sstar_log]:CAPABILITIES_SDIO_PATCH [0]
[Sstar_log]:CAPABILITIES_NO_BACKOFF [0]
[Sstar_log]:CAPABILITIES_CFO [0]
[Sstar_log]:CAPABILITIES_AGC [1]
[Sstar_log]:CAPABILITIES_TXCAL [1]
[Sstar_log]:CAPABILITIES_MONITOR [0]
[Sstar_log]:CAPABILITIES_CUSTOM [1]
[Sstar_log]:CAPABILITIES_SMARTCONFIG [0]
[Sstar_log]:CAPABILITIES_ETF [1]
[Sstar_log]:CAPABILITIES_LMAC_RATECTL [1]
[Sstar_log]:CAPABILITIES_LMAC_TPC [1]
[Sstar_log]:CAPABILITIES_LMAC_TEMPC [1]
[Sstar_log]:CAPABILITIES_CTS_BUG [1]
[Sstar_log]:CAPABILITIES_USB_RECOVERY_BUG [1]
[Sstar_log]:CAPABILITIES_USE_IPC [1]
[Sstar_log]:CAPABILITIES_OUTER_PA [0]
[Sstar_log]:CAPABILITIES_POWER_CONSUMPTION [0]
[Sstar_log]:CAPABILITIES_RSSI_DECIDE_TXPOWER [0]
[Sstar_log]:CAPABILITIES_RTS_LONG_DURATION [1]
[Sstar_log]:CAPABILITIES_TX_CFO_PPM_CORRECTION[0]
[Sstar_log]:CAPABILITIES_SHARE_CRYSTAL [0]
[Sstar_log]:CAPABILITIES_HW_CHECKSUM [0]
[Sstar_log]:CAPABILITIES_SINGLE_CHANNEL_MULRX [1]
[Sstar_log]:CAPABILITIES_CFO_DCXO_CORRECTION [0]
[Sstar_log]:mdelay wait wsm_startup_done !!
[Sstar_log]:WSM_FIRMWARE_CHECK_ID
[Sstar_log]:wsm_generic_confirm:status(2)
[Sstar_log]:<WARNING> wsm_write_mib fail !!! mibId=4132
[Sstar_log]:apollo wifi : can't open /data/.mac.info
[Sstar_log]:efuse data is [0x1,0x3b,0x2,0x2,0x2,0x7,0x0,0x0,0x24:0x14:0x7:0x16:0x65:0x61]
[Sstar_log]:apollo wifi : can't open /Sstar_txpwer_dcxo_cfg.txt
[Sstar_log]:ELOG_INIT len 64
[Sstar_log]:[Sstar_wtd]:set wtd_probe = 1
usbcore: registered new interface driver Sstar_wlan
[Sstar_log]:[wtd] register.
# [Sstar_log]:br0_netdev_open()-1116: dev_get_by_name(br0) failed2![Sstar_log]:br0_netdev_open()-1116: dev_get_by_name(br0) failed2!
3.2.4 检测对应外设节点
检查 wlan0 是否被建立节点
mdev -s
wlan0=`ifconfig -a | grep wlan0`
trial=0
maxtrycnt=50
while [ -z "$wlan0" ] && [ $trial -le $maxtrycnt ]
do sleep 0.2#echo currect try $trial...trial=$(($trial + 1 ))wlan0=`ifconfig -a | grep wlan0`
done
if [ $trial -le $maxtrycnt ]; thenecho try $trial times
fi
if [ $trial -gt $maxtrycnt ];thenecho wlan0 not foundexit -1
fi
3.2.5 操作日志开关
echo LOG_WARN=OFF > /sys/module/ssw101b_wifi_usb/Sstarfs/Sstar_printk_mask
echo LOG_INIT=OFF > /sys/module/ssw101b_wifi_usb/Sstarfs/Sstar_printk_mask
echo LOG_EXIT=OFF > /sys/module/ssw101b_wifi_usb/Sstarfs/Sstar_printk_mask
echo LOG_SCAN=OFF > /sys/module/ssw101b_wifi_usb/Sstarfs/Sstar_printk_mask
echo LOG_LMAC=OFF > /sys/module/ssw101b_wifi_usb/Sstarfs/Sstar_printk_mask
echo LOG_PM=OFF > /sys/module/ssw101b_wifi_usb/Sstarfs/Sstar_printk_mask
3.3 启动STA模式
# ifconfig wlan0 up
# ifconfig wlan0
- ctrl_interface 需要和工具wpa_cli 保持一致
# cat /appconfigs/wpa_supplicant.conf
ctrl_interface=/tmp/wifi/run/wpa_supplicant
update_config=1
- 后台运行wifi
如果wpa_supplicant.conf已经包含了network信息,则自动连接,如果没有仅进行初始化。可用通过后期wpa_cli 操作连接
# wpa_supplicant -D nl80211 -i wlan0 -c /appconfigs/wpa_supplicant.conf -B &
# Successfully initialized wpa_supplicant
[Sstar_log]:ieee80211_mgd_auth:(94:87:e0:47:64:db),ssid(chxm)
[Sstar_log]:Sstar_set_priv_queue_cap:[0],queue_cap[224]
[Sstar_log]:wlan0: authenticated
[Sstar_log]:ieee80211_start_connecting_work:bssid(94:87:e0:47:64:db)
[Sstar_log]:wlan0: associated
[Sstar_log]:[94:87:e0:47:64:db]:20M channel
[Sstar_log]:ieee80211_wk_connecting: time out
[Sstar_log]:ieee80211_ifa_changed(wlan0):IPv4 enable,end_time(307150)
- 关闭wifi功能
killall wpa_supplicant
killall udhcpc 可以不用,因为其它网口还需要
3.4 wpa_cli 操作剪辑
- 建立连接
# wpa_cli -i wlan0 scan
OK
# wpa_cli -i wlan0 scan_result
bssid / frequency / signal level / flags / ssid
94:87:e0:47:64:db 2447 -40 [WPA2-PSK-CCMP][ESS] chxm
# wpa_cli -i wlan0 add_network
0
# wpa_cli -i wlan0 set_network 0 ssid '"chxm"'
OK
# wpa_cli -i wlan0 set_network 0 psk '"chxmtest123"'
OK
- 保存连接信息
# wpa_cli -i wlan0 save_config
OK
配置文件被修改
# cat /appconfigs/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
update_config=1network={ssid="chxm"psk="chxmtest123"
}
- 选择已有的连接
# wpa_cli -i wlan0 list_network
network id / ssid / bssid / flags
0 chxm any [DISABLED]
# wpa_cli -i wlan0 select_network 0
OK
#
- 查看wifi状态
# wpa_cli -i wlan0 list_network
network id / ssid / bssid / flags
0 chxm any [CURRENT]
# wpa_cli -i wlan0 status
bssid=94:87:e0:47:64:db
ssid=chxm
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
ip_address=192.168.43.139
p2p_device_address=24:14:07:16:65:61
address=24:14:07:16:65:61
#
- 激活连接
# wpa_cli -i wlan0 enable_network 0
OK
- 断开连接
# wpa_cli -i wlan0 disable_network 0
[Sstar_log]:ieee80211_mgd_deauth
[Sstar_log]:wlan0: deauthenticating from 94:87:e0:47:64:db by local choice (reason=3)
[Sstar_log]:Sstar_rate_control_send_low cbss is null
OK