Raspberry Pi Pico 2 W in the field: remote access, logs and OTA
A Pico 2 W running a web page on your desk is easy. The same Pico on another network, behind a router you do not control, is unreachable, silent when it crashes, and updated only by plugging it in. This is how to change that.
What it takes
The Pico keeps one outbound connection to Pinscope; through it, its web server gets an HTTPS address, its printf output is streamed, and new firmware arrives. With the Pico SDK and FreeRTOS:
include(pinscope-pico/pinscope.cmake) # after pico_sdk_init() target_link_libraries(app pinscope pico_cyw43_arch_lwip_sys_freertos FreeRTOS-Kernel-Heap4)
pinscope_start(&(pinscope_config_t){ .project_key = "psk_..." }); /* once WiFi is up */
lwipopts.h needs lwIP's socket API (LWIP_SOCKET 1, NO_SYS 0); the build says so if it is missing.
Logs
Everything printed with printf or puts goes to the dashboard, live and stored, and still to USB or the UART.
Crashes
On a HardFault the program counter, the return address and the code addresses on the stack are kept in RAM across the reset and sent on the next connection. Upload the .elf of the build and they become functions and lines; builds are matched by their GNU build ID. For a fault on your desk, the Cortex-M HardFault decoder explains the status registers.
Updates with the RP2350's partitions
The RP2350 bootrom can hold two images in A/B partitions and boot a new one on trial. Pinscope writes the update into the partition that is not running and reboots into it; the new image is kept once it reaches Pinscope, and if it does not within five minutes the bootrom goes back to the old one. The board needs the partition table once:
picotool partition create partitions.json pt.uf2
Copy pt.uf2 to the board, then your app's UF2. Updates then come from the dashboard as UF2 files. The UF2 converter shows what a UF2 contains and converts a .bin.
Memory
About 9 KB of RAM: 4.2 KB of buffers, queue and state, a 3 KB task stack, and the task, lock and socket. Keys come from the RP2350's hardware random generator; no TLS library.
The Pico docs have the details.
Try it
Three devices are free, and no card is needed. Create an account, or read the guide for your platform: ESP32, Zephyr, Raspberry Pi Pico, Linux, ESP8266.
More
- Remote access to an ESP32 without TLS: what it measured and what it costs
- Serial monitor in the browser for ESP32 and Zephyr, with crash decoding
- Pinscope now runs on Zephyr, Raspberry Pi Pico, Linux and ESP8266
- Cortex-M HardFault decoder
- UF2 converter and inspector
- Memfault, Golioth, nRF Cloud and Pinscope compared
- The Cyber Resilience Act, for the devices you ship