Raspberry Pi Pico W – Minimal Wi-Fi UDP Example (Arch Linux)
Authorship
This document was generated using ChatGPT (OpenAI), version 5.2. It has not been independently reviewed or validated yet.
Purpose
Minimal Pico W Wi-Fi example using the Arch Linux packaged Pico SDK. Goal: clean build, no hidden assumptions, raw lwIP usage.
Environment
- Arch Linux
pico-sdkfrom/usr/share/pico-sdk- Board: Pico W
- Toolchain:
arm-none-eabi-gcc - lwIP in
NO_SYSmode - Driver:
pico_cyw43_arch_lwip_poll
Add the following sections.
Build
mkdir build
cd build
cmake ..
make -j
Explanation:
cmake ..configures the project and generates build files.make -jbuilds using all available CPU cores.- After configuration, normal source changes require only
make -j. - If
CMakeLists.txtchanges, delete thebuild/directory and runcmakeagain.
The resulting firmware file:
build/pico_w_udp_client.uf2
Flash
picotool load -f pico_w_udp_client.uf2
This writes the UF2 image to the Pico W over USB (device must be in BOOTSEL mode or rebooted via picotool).
Runtime Behavior
After flashing and reset:
- The Pico W connects to the configured Wi-Fi network.
- Once DHCP assigns an IP address, the onboard LED turns on.
- The device begins sending periodic
hello worldUDP messages to the configured destination IP address.
CMake Configuration
Board is selected in CMakeLists.txt:
set(PICO_BOARD pico_w)
include(pico_sdk_import.cmake)
Wi-Fi credentials are kept outside the main source tree:
target_include_directories(pico_w_udp_client PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/../secrets
)
Example usage:
#include "secrets/fra.h"
This keeps credentials separate from firmware logic.
Networking Model
- lwIP raw API (UDP)
NO_SYS = 1- Explicit polling via
cyw43_arch_poll() - Project-local
lwipopts.h
No sockets, no netconn, no sys_arch, no background threads.
Key Points
- Arch SDK requires providing your own
lwipopts.h. - Sockets require
NO_SYS = 0and asys_archimplementation — not used here. - Raw API is the simplest and fully self-contained option.
- TCP/UDP framing must be handled at application level.
Result
✔ Builds cleanly ✔ Pico W connects to Wi-Fi ✔ UDP packets transmitted ✔ Deterministic configuration