Skip to content
Eliott65Sondewiki
Contents

The Pico W firmware

On the Pico W, three pieces connect the CMSIS-DAP processor to the world: a PIO program for the two SWD wires, the lwIP network stack for Wi-Fi, and a loop that serves both ports.

SWD by PIO

The Pico W’s RP2040 has PIOs: small programmable input/output processors that produce signals to the cycle without occupying the main processor. The probe runs a 13-instruction program on one, written for the project.

  • The program receives a command word (number of bits, direction of SWDIO), then, for a write, the data.
  • Four PIO cycles per bit: the SWCLK clock is the PIO clock divided by 4.
  • The probe sets its data while the clock is low; it reads the target’s data on the rising edge.
  • On top, the SWD protocol is written in C: request, line turnaround, acknowledgement, data, parity, idle cycles, cases where the target asks to wait or reports a fault. It only knows two primitives, write and read n bits: on the probe, the PIO carries them out; on the PC, a PIO simulator (see Test benches).

Wi-Fi and the network

  • lwIP with no operating system: the main loop polls the Wi-Fi chip (CYW43) and the network stack on every pass. No tasks, no system.
  • Non-blocking connection, retrying if the network disappears; the LED blinks while searching and stays on once connected.
  • The name eliott65sonde is announced over DHCP and mDNS: eliott65sonde.local is enough to reach it.
  • The Wi-Fi credentials are in a file excluded from the repository; only a template is versioned.

The two servers

PortServiceClients
4441CMSIS-DAP over TCPone at a time; OpenOCD
4442local log and updates, own protocol (“E65S” header)the e65s.py tool

Packets are rebuilt from the TCP stream; responses go out in pieces, at the pace of the transmit buffer. The log’s readings are taken in the main loop, between two network polls.

Space taken

The firmware takes about 340 KiB of flash (178 KiB of static RAM out of 264 with the log). Since v0.6.0, it starts at 0x10008000, behind the boot loader: see Updates.

Sources in the repository : docs/adr/ADR-0002-firmware-pico-w.md, docs/journal/02-firmware-pico-w.md, docs/journal/06-integrite-du-signal.md.