• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
11Setup
12=====
13To use this target, Pigweed must be set up to build against the Raspberry Pi
14Pico SDK. This can be downloaded via ``pw package``, and then the build must be
15manually configured to point to the location of the downloaded SDK.
16
17.. code:: sh
18
19  pw package install pico_sdk
20
21  gn args out
22    # Add this line.
23    PICO_SRC_DIR = getenv("PW_PACKAGE_ROOT") + "/pico_sdk"
24
25Linux
26-----
27On linux, you may need to update your udev rules at
28``/etc/udev/rules.d/49-pico.rules`` to include the following:
29
30.. code:: none
31
32  SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE:="0666"
33  KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE:="0666"
34  SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0003", MODE:="0666"
35  KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0003", MODE:="0666"
36  SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", MODE:="0666"
37  KERNEL=="ttyACM*", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", MODE:="0666"
38
39Usage
40=====
41The Pi Pico is configured to output logs and test results over USB serial at a
42baud rate of 115200.
43
44Once the pico SDK is configured, the Pi Pico will build as part of the default
45GN build:
46
47.. code:: sh
48
49  ninja -C out
50
51Pigweed's build will produce ELF and UF2 files for each unit test built for the
52Pi Pico.
53
54Flashing
55========
56Flashing the Pi Pico is two easy steps:
57
58#. While holding the button on the Pi Pico, connect the Pico to your computer
59   via the micro USB port.
60#. Copy the desired UF2 firmware image to the RPI-RP2 volume that enumerated
61   when you connected the Pico.
62
63Testing
64=======
65Unlike some other targets, the RP2040 does not automatically run tests on boot.
66To run a test, flash it to the RP2040 and connect to the serial port and then
67press the spacebar to start the test:
68
69.. code:: none
70
71  $ python -m serial.tools.miniterm --raw /dev/ttyACM0 115200
72  --- Miniterm on /dev/cu.usbmodem142401  115200,8,N,1 ---
73  --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---INF  [==========] Running all tests.
74  INF  [ RUN      ] Status.Default
75  INF  [       OK ] Status.Default
76  INF  [ RUN      ] Status.ConstructWithStatusCode
77  INF  [       OK ] Status.ConstructWithStatusCode
78  INF  [ RUN      ] Status.AssignFromStatusCode
79  INF  [       OK ] Status.AssignFromStatusCode
80  INF  [ RUN      ] Status.Ok_OkIsTrue
81  INF  [       OK ] Status.Ok_OkIsTrue
82  INF  [ RUN      ] Status.NotOk_OkIsFalse
83  INF  [       OK ] Status.NotOk_OkIsFalse
84  INF  [ RUN      ] Status.Code
85  INF  [       OK ] Status.Code
86  INF  [ RUN      ] Status.EqualCodes
87  INF  [       OK ] Status.EqualCodes
88  INF  [ RUN      ] Status.IsError
89  INF  [       OK ] Status.IsError
90  INF  [ RUN      ] Status.IsNotError
91  INF  [       OK ] Status.IsNotError
92  INF  [ RUN      ] Status.Strings
93  INF  [       OK ] Status.Strings
94  INF  [ RUN      ] Status.UnknownString
95  INF  [       OK ] Status.UnknownString
96  INF  [ RUN      ] Status.Update
97  INF  [       OK ] Status.Update
98  INF  [ RUN      ] StatusCLinkage.CallCFunctionWithStatus
99  INF  [       OK ] StatusCLinkage.CallCFunctionWithStatus
100  INF  [ RUN      ] StatusCLinkage.TestStatusFromC
101  INF  [       OK ] StatusCLinkage.TestStatusFromC
102  INF  [ RUN      ] StatusCLinkage.TestStatusStringsFromC
103  INF  [       OK ] StatusCLinkage.TestStatusStringsFromC
104  INF  [==========] Done running all tests.
105  INF  [  PASSED  ] 15 test(s).
106
107This is done because the serial port enumerated by the Pi Pico goes away on
108reboot, so it's not safe to run tests until the port has fully enumerated and
109a terminal has connected. To avoid races, the Pico will just wait until it
110receives the space character (0x20) as a signal to start running the tests.
111
112The RP2040 does not yet provide an automated test runner with build system
113integration.
114