1.. _target-raspberry-pi-pico: 2 3----------------- 4Raspberry Pi Pico 5----------------- 6.. warning:: 7 This target is in an early state and is under active development. Usability 8 is not very polished, and many features/configuration options that work in 9 upstream Pi Pico CMake build have not yet been ported to the GN build. 10 11----- 12Setup 13----- 14To use this target, Pigweed must be set up to build against the Raspberry Pi 15Pico SDK. This can be downloaded via ``pw package``, and then the build must be 16manually configured to point to the location of the downloaded SDK. 17 18.. code:: sh 19 20 pw package install pico_sdk 21 22 gn args out 23 # Add these lines, replacing ${PW_ROOT} with the path to the location that 24 # Pigweed is checked out at. 25 PICO_SRC_DIR = "${PW_ROOT}/.environment/packages/pico_sdk" 26 27----- 28Usage 29----- 30The Pi Pico is currently configured to output logs and test results over UART 31via GPIO 1 and 2 (TX and RX, respectively) at a baud rate of 115200. Because 32of this, you'll need a USB TTL adapter to communicate with the Pi Pico. 33 34Once the pico SDK is configured, the Pi Pico will build as part of the default 35GN build: 36 37.. code:: sh 38 39 ninja -C out 40 41Pigweed's build will produce ELF files for each unit test built for the Pi Pico. 42While ELF files can be flashed to a Pi Pico via SWD, it's slightly easier to 43use the Pi Pico's bootloader to flash the firmware as a UF2 file. 44 45Pigweed currently does not yet build/provide the elf2uf2 utility used to convert 46ELF files to UF2 files. This tool can be built from within the Pi Pico SDK with 47the following command: 48 49.. code:: sh 50 51 mkdir build && cd build && cmake -G Ninja ../ && ninja 52 # Copy the tool so it's visible in your PATH. 53 cp elf2uf2/elf2uf2 $HOME/bin/elf2uf2 54 55Flashing 56======== 57Flashing the Pi Pico is as easy as 1-2-3: 58 59#. Create a UF2 file from an ELF file using ``elf2uf2``. 60#. While holding the button on the Pi Pico, connect the Pico to your computer 61 via the micro USB port. 62#. Copy the UF2 to the RPI-RP2 volume that enumerated when you connected the 63 Pico. 64