This is a simple example project for the Raspberry Pi Pico W that demonstrates:
- Basic GPIO control
- WiFi connectivity
- LED blinking
- USB serial output
- Interactive CLI interface
- Docker or Podman installed on your system
- ARM GCC toolchain installed on your system
- picotool installed on your host system (not in container)
-
Build, create and start the container (only needed first time):
./p.sh bootstrap
Replace
/absolute/path/to/your/projectwith the full path to your project directory. -
To access the container's shell:
./p.sh shell
-
To build the app inside the container
./p.sh build ./build.sh
-
To stop the container:
podman stop pico-w-builder
-
To start the container again:
podman start pico-w-builder
-
To remove the container (if you need to recreate it):
podman rm pico-w-builder
The build process creates a UF2 file in the build directory. To program your Pico W:
- Make sure picotool is installed on your host system (not in the container)
- Connect your Pico W to your computer via USB
- Run the following command from your project directory:
picotool load build/picowbase.elf
If you need to reboot the Pico W into bootloader mode:
picotool reboot -f -uAfter programming, the Pico W will provide a command-line interface over USB serial. To access it:
-
Find the correct serial port:
ls /dev/tty.usbmodem* ls /dev/cu.usbmodem*
-
Connect using one of these methods:
a. Using
screen:screen /dev/tty.usbmodem* 115200To exit screen: Press
Ctrl-Afollowed byCtrl-\and confirm withyb. Using Serial (Mac App Store):
- Open Serial
- Select the port from the dropdown
- Set baud rate to 115200
- Click "Open"
c. Using CoolTerm:
- Download from http://freeware.the-meiers.org/
- Open CoolTerm
- Click "Options" and select the port
- Set baud rate to 115200
- Click "Connect"
- Connect using screen:
To exit screen: Press
screen /dev/ttyACM0 115200
Ctrl-Afollowed byCtrl-\and confirm withy
- Use a terminal program like PuTTY or MobaXterm
- Select the COM port assigned to the Pico W
- Set baud rate to 115200
Available commands:
help- Show available commandsled on- Turn the LED onled off- Turn the LED offstatus- Show system statusclear- Clear the screenexit- Enter bootloader mode for programming
main.cpp- Main application codeCMakeLists.txt- CMake build configurationbuild.sh- Build scriptlwipopts.h- lwIP configuration for WiFiDockerfile- Container build configuration
- Blinks the onboard LED
- Connects to WiFi
- Outputs status messages via USB serial
- Uses C++20 standard
- Supports programming without disconnecting USB cable
- Interactive CLI interface over USB serial
If you encounter any issues:
- Make sure your Pico W is properly connected
- Verify that picotool is installed and accessible from your host system
- Check that the container has access to your project directory
- Ensure you have the correct permissions to access the USB device
- If the container isn't working properly, try removing and recreating it:
podman rm pico-w-builder # Then follow the "Building the Project" steps again - If you can't access the CLI:
- Check that the USB serial port is available
- Try a different USB cable
- Verify the baud rate is set to 115200
- Try resetting the Pico W
- On macOS, make sure you're using the correct port name (tty.usbmodem*)
- Try a different terminal program if screen doesn't work
This project is licensed under the MIT License - see the LICENSE file for details.