zephyr-cp/wifi: route diagnostic output through the log subsystem - #11227
Open
mikeysklar wants to merge 2 commits into
Open
zephyr-cp/wifi: route diagnostic output through the log subsystem#11227mikeysklar wants to merge 2 commits into
mikeysklar wants to merge 2 commits into
Conversation
The event handler has a NET_EVENT_WIFI_SCAN_RESULT case that queues each AP as it arrives, but that event was never in the subscription mask, so the case never ran and scans always returned zero networks. RAW_SCAN_RESULT is in the mask but is not a substitute. It carries raw beacon frames and only fires when CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS is enabled, which it is not by default. Measured on a Raspberry Pi Pico 2 W running raspberrypi_rpi_pico2_w_zephyr, built from 069144c and flashed over SWD with pyOCD: len([1 for n in wifi.radio.start_scanning_networks()]) before 0 after 204 Same board, same probe, same script, with only this change reverted for the before run.
The Wi-Fi common-hal printed on every net event with raw printk. That output is unconditional, so it corrupts the serial handshake that raw-REPL tooling relies on, and it cannot be turned down per module. Register a cp_wifi log module and route the existing calls through it, at CONFIG_LOG_DEFAULT_LEVEL as supervisor/usb.c already does. Two printks in start_scanning_networks() only restated the message raised on the following line, so they are dropped rather than converted. Also fixes two defects the conversion exposed: - The unhandled-event print passed a uint64_t mgmt_event to %x, truncating to 32 bits. Since the layer lives in the high bits, every unhandled Wi-Fi event aliased to the same value. - NET_EVENT_IPV4_ADDR_ADD was already subscribed but had no case, so it fell through to the unhandled-event path and the status bar kept reading "No IP" after DHCP bound, while wifi.radio.ipv4_address returned the real lease.
mikeysklar
marked this pull request as ready for review
August 23, 2026 16:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Routes the zephyr-cp Wi-Fi common-hal's diagnostic output through Zephyr's log
subsystem instead of raw
printk, and fixes two defects that conversion exposed.Why
The Wi-Fi path printed unconditionally on every net event. That output cannot be
turned down per module, and it corrupts the serial handshake that raw-REPL
tooling relies on, which makes REPL automation on this port flaky.
Two real bugs came out of the conversion:
mgmt_eventis auint64_tand was printed with%x. The event layer lives in the high bits,so every unhandled Wi-Fi event aliased to the same value.
NET_EVENT_IPV4_ADDR_ADDhad nocase. The callback for it was alreadyregistered upstream, so the event arrived and fell through to the
unhandled-event path. The status bar therefore kept reading
Wi-Fi: No IPafter DHCP had bound, while
wifi.radio.ipv4_addressreturned the real lease.Two
printks instart_scanning_networks()only restated the message raised onthe next line, so they are deleted rather than converted.
LOG_MODULE_REGISTER(cp_wifi, CONFIG_LOG_DEFAULT_LEVEL)follows the existingprecedent in
ports/zephyr-cp/supervisor/usb.c.Hardware tested
siwx917_dk2605a, SoC SiWG917M111MGTBA), twoboards, one on macOS 15 and one on Ubuntu 24.04.
definition from zephyr-cp: add the Silicon Labs SiWx917-DK2605A #11218 (not yet merged).
Not tested: any other zephyr-cp board. This file builds for every Wi-Fi board in
the port, so CI is the check for the rest.
How I tested it
Console output is quiet by default now instead of printing per event, and the
status bar shows the address once DHCP binds rather than
No IP.Scope
Only
ports/zephyr-cp/common-hal/wifi/.printkis still used elsewhere in theport; converting those is out of scope here.
Notes
No new translatable strings, and
locale/circuitpython.potis unchanged.This is the first of three PRs splitting up the zephyr-cp Wi-Fi work. It is
stacked on #11223, so until that merges this diff also shows its one-line scan
subscription change.
AI assistance
Written with Claude Code. I reviewed the diff myself and verified the behaviour
on the hardware listed above.