6. CV184x RTL8189FS WiFi FlowDescription¶
This documentDescriptionin cv1842 etc. CV184x Platform RTL8189FS SDIO WiFi afterkernelandDevice TreeConfiguration ( 《Configuration Description》Chapter )、Build Path,withand STA(wpa_supplicant)and AP(hostapd)User spaceToolsofPackageandBoard-levelUseFlow。
6.1. Build and Artifacts¶
Execute build_osdrv (or etc. Commands)after, Generate 8189fs.ko。Copyto rootfs ofPath osdrv of INSTALL_DIR ,for example:
install/soc_cv1842hp_wevb_0014a_emmc/rootfs/system/ko/3rd/8189fs.ko
willon Pathunderof 8189fs.ko Copyto canAccessContents(If /mnt/sd/)。Ifalreadyin menuconfig in Install the wireless driver ko,Image can alreadyInclude Module, No need to Copy。
6.2. Board-Level Wi-Fi Connection Flow¶
6.2.1. Prepare wpa_supplicant, hostapd, and Libraries (Development Host)¶
Description:wpa_supplicant and hostapd , hostap BuildafterofInstallTree;SDK in Contentsis ramdisk/rootfs/public/wifi/musl_arm/ (and packages_arch=musl_arm )。No need to under hostapd Install ,and wpa ,from ContentsCopy can。
If rootfs on Tools,in onPackage PleaseNote:FAT of SD not ,needCopy of so, Copy File 。
cd /path/to/your/sdk # ReplaceisActual SDK Contents
W=ramdisk/rootfs/public/wifi/musl_arm
rm -rf wifi_tools
mkdir -p wifi_tools
# STA
cp $W/usr/sbin/wpa_supplicant $W/usr/sbin/wpa_cli $W/usr/sbin/wpa_passphrase wifi_tools/
# AP(and wpa Contents, Build )
cp $W/usr/sbin/hostapd wifi_tools/
# If incan andPackage:hostapd_cli
test -f $W/usr/sbin/hostapd_cli && cp $W/usr/sbin/hostapd_cli wifi_tools/
cp $W/usr/lib/libnl-3.so.200.26.0 wifi_tools/
cp $W/usr/lib/libnl-genl-3.so.200.26.0 wifi_tools/
cp $W/usr/lib/libnl-route-3.so.200.26.0 wifi_tools/
cp wifi_tools/libnl-3.so.200.26.0 wifi_tools/libnl-3.so.200
cp wifi_tools/libnl-genl-3.so.200.26.0 wifi_tools/libnl-genl-3.so.200
cp wifi_tools/libnl-route-3.so.200.26.0 wifi_tools/libnl-route-3.so.200
cd wifi_tools
tar -cvf ../wifi_tools.tar .
willGenerateof wifi_tools.tar Copyto canAccessContents(If U /SD of /mnt/sd/)。
Note
in 200.26.0 with Tree Actual usr/lib/libnl-*.so.* File is ;If libnl,need Modify cp of File 。
6.2.2. STA:wpa_supplicant Configuration File¶
in can Contents wpa_supplicant.conf (for example /mnt/sd/wpa_supplicant.conf),ContentExample(SSID/Password ActualModify):
network={
ssid="111"
psk="1234qwer"
key_mgmt=WPA-PSK
}
6.2.3. STA:Board-Side Operation Steps¶
following wifi_tools.tar and wpa_supplicant.conf in /mnt/sd/, 8189fs.ko alreadyCopyto (If /mnt/sd/)。
# 1. Load WiFi Driver
insmod /mnt/sd/8189fs.ko
# 2. Extract wpa_supplicant、hostapd and
mkdir -p /mnt/sd/wifi
cd /mnt/sd/wifi
tar -xvf /mnt/sd/wifi_tools.tar
# 3. Settings Pathand wpa_supplicant(STA)
export LD_LIBRARY_PATH=/mnt/sd/wifi
/mnt/sd/wifi/wpa_supplicant -B -i wlan0 -c /mnt/sd/wpa_supplicant.conf
# 4. Wait seconds laterGet IP
sleep 5
udhcpc -i wlan0
# 5. View wlan0 Statusand IP
ifconfig wlan0
If udhcpc ,can Hotspot DHCP; HotspotNetwork Segmentis 192.168.43.x,can Configuration:
ifconfig wlan0 192.168.43.100 netmask 255.255.255.0 up
route add default gw 192.168.43.1
6.2.4. STA:Verification¶
ifconfig wlan0inet addrandUP BROADCAST RUNNING。ping 192.168.43.1(orHotspotGateway)canVerification ;IfHotspot Network,canping 8.8.8.8Verification 。
6.2.5. AP Mode: hostapd¶
:andon ,alreadyfrom
$W/usr/sbin/hostapdInsertwifi_tools.tar,Extractafter/mnt/sd/wifi/hostapd。:and wpa_supplicant of libnl so,Settings
LD_LIBRARY_PATH=/mnt/sd/wifican。
in /mnt/sd/ under hostapd.conf (interface= andActual AP Ethernet Port ;SSID/PasswordPlease ActualModify):
interface=wlan1
driver=nl80211
ssid=MyAP
hw_mode=g
channel=6
country_code=CN
ieee80211d=1
auth_algs=1
wmm_enabled=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ieee80211w=0
6.2.6. AP Steps( eth0 NAT Uplink)¶
:wlan0 is STA Hotspot(If 192.168.43.0/24),eth0 is or on (If 192.168.137.0/24);in wlan1 on AP,under Terminal wlan1 → NAT → eth0 。If ip route in in wlan0 of default Routing, and“Default eth0 Uplink” ,can DefaultRouting(GatewayandInterfacewith ip route is )。
udhcpd.conf ( in /mnt/sd/udhcpd.conf;Network Segmentcan Definition):
start 192.168.1.100
end 192.168.1.200
interface wlan1
max_leases 20
option subnet 255.255.255.0
option router 192.168.1.1
option dns 8.8.8.8
ExecutefollowingCommandsConfigurationForwarding :
export LD_LIBRARY_PATH=/mnt/sd/wifi
# Delete STA default, eth0 of default(Uplink ActualModify)
ip route del default via 192.168.43.1 dev wlan0
# IPv4 Forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# NAT:Ifalready in not Add(Uplink eth0 ActualModify)
iptables -t nat -C POSTROUTING -o eth0 -j MASQUERADE 2>/dev/null || \
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# Forwarding
iptables -P FORWARD ACCEPT
iptables -F FORWARD
iptables -A FORWARD -i wlan1 -j ACCEPT
iptables -A FORWARD -o wlan1 -j ACCEPT
# hostapd Need toRun Contents
mkdir -p /var/run/hostapd
killall wpa_supplicant 2>/dev/null
# AP Local Host IP mustand udhcpd in option router
ifconfig wlan1 192.168.1.1 netmask 255.255.255.0 up
/mnt/sd/wifi/hostapd -B /mnt/sd/hostapd.conf
udhcpd /mnt/sd/udhcpd.conf
udhcpd Description:IfSystem udhcpd need rootfs or dnsmasq;before can -f; need leases File(IfExecute touch /var/lib/misc/udhcpd.leases,PathwithLocal Host udhcpd –help is )。
DHCP :under DevicecanUse IP(192.168.1.x,Gateway 192.168.1.1, 255.255.255.0)。
If STA、 wlan0 of default Routing,can ip route del;192.168.43.1 and wlan0 Example。iptables and ip_forward needKernelEnable netfilter rootfs iptables。
:Execute killall hostapd;If udhcpd killall udhcpd(or PID )。