No description
- CMake 51.5%
- C 38.5%
- Python 10%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| docs | ||
| .gitignore | ||
| CMakeLists.txt | ||
| main.c | ||
| main.py | ||
| mkdocs.yml | ||
| pico_sdk_import.cmake | ||
| README.md | ||
Raspberry Pi Pico Hardware Test Project
This project provides a complete test suite and setup guide for the Raspberry Pi Pico, Pico W, and Pico 2 (RP2350).
🎯 What This Test Verifies
- Microcontroller Core & System Clocks: Verifies the processor starts properly and runs at standard clock frequencies (125 MHz sys clock).
- Onboard LED Blink: Hardware GPIO control and timing checks.
- Internal Temperature Sensor: Reads analog voltage from ADC channel 4 and computes temperature in °C and °F.
- USB CDC Serial Communication: Transmits real-time heartbeat logs and receives interactive terminal commands over standard USB cable.
- Software BOOTSEL Reset: Allows software reboot into flasher mode without physically unplugging the cable.
📁 Project Structure
test-rpi-pico/
├── CMakeLists.txt # CMake build configuration for C/C++ SDK
├── pico_sdk_import.cmake # Raspberry Pi Pico SDK importer
├── main.c # C firmware (Blink, ADC Temp, USB Serial CLI)
├── main.py # MicroPython alternative script
├── .gitignore
└── README.md # Complete setup and walkthrough documentation
🚀 Walkthrough: Method 1 (C/C++ Pico SDK)
1. Build the Firmware
Open a terminal in the project directory:
mkdir -p build
cd build
cmake ..
make -j$(nproc)
This compiles the firmware and produces:
build/test_rpi_pico.uf2(Ready for drag-and-drop flashing)build/test_rpi_pico.elf(For debugging via SWD / GDB)build/test_rpi_pico.hex/build/test_rpi_pico.bin
2. Flash to Raspberry Pi Pico
Drag-and-Drop Method (No extra tools required):
- Unplug your Pico from your computer.
- Press and hold the white BOOTSEL button on the Pico board.
- While holding the button, plug the Pico into your computer via USB.
- Release the BOOTSEL button. The Pico will mount as a USB storage drive named
RPI-RP2(orRP2350on Pico 2). - Copy the
.uf2file to the drive:
(Or drag and dropcp build/test_rpi_pico.uf2 /media/$USER/RPI-RP2/test_rpi_pico.uf2in your file manager). - The drive will automatically disconnect and the Pico will reboot running the new firmware.
Command-Line Method using picotool:
With the Pico in BOOTSEL mode:
picotool load -x build/test_rpi_pico.uf2
3. Open Serial Terminal to Monitor & Test
Once flashed, the onboard LED will start blinking, and the Pico will expose a USB Serial port (typically /dev/ttyACM0 on Linux, COMx on Windows, /dev/cu.usbmodem* on macOS).
Connect to the serial monitor:
# Using minicom:
minicom -b 115200 -o -D /dev/ttyACM0
# Or using picocom:
picocom -b 115200 /dev/ttyACM0
# Or using screen:
screen /dev/ttyACM0 115200
Interactive Commands:
Type any of these keys into the serial terminal:
hor?: Display the help menut: Read immediate temperature sensor valuel: Toggle LED blinking on/offi: Display system clocks & uptime informationb: Reboot Pico directly back into BOOTSEL mode for rapid re-flashing
🐍 Walkthrough: Method 2 (MicroPython)
If you prefer testing with Python:
- Install MicroPython Firmware:
- Download the official MicroPython
.uf2for your board from raspberrypi.com/documentation/microcontrollers/micropython.html. - Boot Pico into BOOTSEL mode and copy the
.uf2onto theRPI-RP2drive.
- Download the official MicroPython
- Run the Test Script:
- Open Thonny IDE (or your favorite IDE) and select MicroPython (Raspberry Pi Pico) interpreter at the bottom right.
- Open
main.pyand click Run. - Or run from command line using
mpremote:pip install mpremote mpremote run main.py
🔧 Troubleshooting & Tips
-
Permission Denied on
/dev/ttyACM0(Linux): Add your user to thedialoutgroup to access serial devices withoutsudo:sudo usermod -a -G dialout $USER(Log out and log back in for changes to take effect).
-
Pico Doesn't Appear as
RPI-RP2Drive:- Verify your USB cable supports data transfer (some cheap cables are charge-only).
- Ensure you are holding BOOTSEL firmly before inserting the USB cable and releasing it after it is plugged in.