WiFi (wlan0) Setup¶
How to enable WiFi on the CanMV K230 and connect to an access point.
Prerequisites¶
- Board is booted and serial console is accessible
- Target WiFi network uses 2.4GHz band (K230 does not support 5GHz)
2.4GHz only
The K230 WiFi chip (bcmdhd) only supports 2.4GHz (ch1-13). It cannot connect to 5GHz SSIDs.
1. Check Initial State¶
By default, wlan0 exists but is DOWN and does not appear in ifconfig (without -a).
Inspection Commands¶
expect -c '
log_user 1
set timeout 10
set serial [open /dev/ttyACM0 r+]
fconfigure $serial -mode 115200,n,8,1 -translation binary -buffering none
spawn -open $serial
send "\r"
expect "]#"
send "ifconfig -a\r"
expect "]#"
send "ip link show wlan0\r"
expect "]#"
send "lsmod\r"
expect "]#"
send "ps | grep wpa_supplicant\r"
expect "]#"
send "cat /etc/network/interfaces\r"
expect "]#"
send "cat /etc/wpa_supplicant.conf\r"
expect "]#"
'
Default State¶
| Item | Status |
|---|---|
wlan0 |
Exists but DOWN (qdisc noop) |
bcmdhd driver |
Loaded |
wpa_supplicant |
Not running |
/etc/network/interfaces |
Only lo and eth0 |
/etc/wpa_supplicant.conf |
key_mgmt=NONE, no SSID configured |
2. Edit Configuration Files¶
/etc/wpa_supplicant.conf¶
Use wpa_passphrase to hash the password:
# Create header
cat > /etc/wpa_supplicant.conf << 'EOF'
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
EOF
# Generate hashed PSK and append (exclude plaintext line)
wpa_passphrase "YourSSID" "YourPassword" | grep -v '#psk=' >> /etc/wpa_supplicant.conf
# Verify
cat /etc/wpa_supplicant.conf
Result:
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
network={
ssid="YourSSID"
psk=abcdef1234567890... <- 256-bit hashed PSK
}
About wpa_passphrase
wpa_passphrase generates the PSK from the SSID + password combination.
If you change the SSID, you must regenerate the PSK.
/etc/network/interfaces¶
Add auto-start configuration for wlan0.
Run on the K230 serial console:
cat > /etc/network/interfaces << 'EOF'
# interface file auto-generated by buildroot
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
pre-up wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
post-down killall -q wpa_supplicant
EOF
3. Start WiFi¶
The /etc/network/interfaces configuration automatically:
- Starts
wpa_supplicantand connects to the WiFi AP - Obtains an IP address via DHCP
Verify Connection¶
# WPA connection state (should show COMPLETED)
wpa_cli -i wlan0 status
# Check for IP address
ifconfig wlan0
# Test internet connectivity
ping -c 3 8.8.8.8
4. Troubleshooting¶
AP Not Found (stuck on SCANNING)¶
# List detected APs
iwlist wlan0 scan 2>&1 | head -30
# Check supported frequencies
iwlist wlan0 frequency 2>&1
The WLAN on the CanMV K230 only supports 2.4GHz. Make sure you are not using a 5GHz SSID.
Buffalo routers
| SSID Pattern | Band | K230 Support |
|---|---|---|
Buffalo-A-xxxx |
5GHz | Not supported |
Buffalo-G-xxxx |
2.4GHz | Supported |
4-Way Handshake Failure (DEAUTH reason 15)¶
If WLC_E_DEAUTH_IND reason 15 appears, the PSK is incorrect.
Common causes:
- Password typo
- SSID was changed but PSK was not regenerated (
wpa_passphraseoutput depends on the SSID)
Fix:
cat > /etc/wpa_supplicant.conf << 'EOF'
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
EOF
# Regenerate PSK with the correct SSID
wpa_passphrase "YourSSID" "YourPassword" | grep -v '#psk=' >> /etc/wpa_supplicant.conf
# Restart WiFi
ifdown wlan0
ifup wlan0
# Verify
wpa_cli -i wlan0 status
ifconfig wlan0
ping -c 3 8.8.8.8
No Auto-Connect After Reboot¶
Verify that /etc/network/interfaces contains auto wlan0.
The init script /etc/init.d/S40network runs ifup -a at boot,
so auto wlan0 ensures WiFi starts automatically.