Pico W only connects to WIFI after 2 restarts #1373
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#1373
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
99% of the time when i recompile/flash/debug no WIFI connection... after restarting the program (while debugging in VS Code) WIFI will connect.
You'll have to add some more information if you want use to do anything with this. If you run it in debug can you capture the logs from the uart? Anything interesting about your wifi? What type of router? Are you close to the router? What's the rssi when you connect? Does waiting longer help? How long does it take to connect when it succeeds? Do any other devices have a problem?
I've run into a similar issue, and the solution was to retry the connection to the wifi. ie if the first call to cyw43_arch_wifi_connect_timeout_ms() times out, repeat the call, and it will always work on the second call. The same applies when using cyw43_arch_wifi_connect_async(): if you don't hear back from it, call it again, and it will work the second time. Everything seems to be working fine, it just takes slightly longer to connect. A 12 second retry timeout is what I use.
I'm not convinced this is the Pico's fault, because it appears the AP is refusing to respond to the initial connection request, rather than the Pico not sending such a request. Seems like maybe a security mechanism on the AP's side (hostapd/Pi 3b+) might be doing it. Takes it a moment to realize the old connection is gone before allowing a new connection from the same device.
A clue that it's the AP is that if you call cyw43_wifi_leave() then reboot via watchdog, the next wifi connection attempt is instant, because the AP knows we want a new connection.
I also support @BigRedTower comments. This is not a Pico issue, but a behavioural issue with the Wi-Fi client requirements. If you leave Wi-Fi without calling
cyw43_wifi_leave()orcyw43_arch_disable_sta_mode()during shutdown, the AP assumes the client is still present and will refuse the first connection.Best practice is to retry the connection. If possible, call
cyw43_wifi_leave()before shutting down/restarting.