(“High Risk Activities”). RPL specifically disclaims any express or implied warranty of fitness for High Risk Activities and accepts no liability for use or inclusions of Raspberry Pi products in High Risk Activities.
Raspberry Pi microcontroller-based board. Pico-series devices are built around microcontrollers designed by Raspberry Pi. Development on the boards is fully supported with both a C/C++ SDK, and an official MicroPython port. This book talks about how to get started with the SDK, and walks you through how to build, install, and work with the SDK toolchain.
Getting started with Raspberry Pi Pico-series Chapter 2. Install Visual Studio Code Visual Studio Code (VS Code) is a popular open source editor developed by Microsoft. The Raspberry Pi Pico VS Code Extension makes it easy to install dependencies and build software for Pico-series devices.
Chapter 3. Install the Raspberry Pi Pico VS Code Extension The Raspberry Pi Pico VS Code extension helps you create, develop, run, and debug projects in Visual Studio Code. It includes a project generator with many templating options, automatic toolchain management, one click project compilation, and offline documentation of the Pico SDK.
Getting started with Raspberry Pi Pico-series 3.2. Install the Extension You can find the extension in the VS Code Extensions Marketplace. Search for the Raspberry Pi Pico extension, published by Raspberry Pi. Click the Install button to add it to VS Code.
The Raspberry Pi Pico extension adds some capabilities to the status bar at the bottom right of the screen. Compile Compiles the sources and builds the target UF2 file. You can copy this binary onto your device to program it.
Getting started with Raspberry Pi Pico-series The extension sidebar also contains some quick access functions. Click on the Pico icon in the side menu and you’ll see Compile Project. Hit Compile Project and a terminal tab will open at the bottom of the screen displaying the compilation progress.
4.3. Debug The Raspberry Pi Debug Probe is a debug solution for any Arm-based computer. You can use other debug hardware with Pico-series devices, but we recommend the Debug Probe to make configuration as simple as possible. If you’d like...
Page 12
Getting started with Raspberry Pi Pico-series function, and run until that breakpoint is hit. Figure 4. Debugging in VS Code. Once in debugging mode, the sidebar has a number of windows displaying useful information about the current state of the device. At the top, a small control bar contains buttons that control code execution. Hover over the buttons to identify them.
Page 13
Getting started with Raspberry Pi Pico-series Figure 5. Debugging in VS Code. You can add and remove a breakpoint by clicking on the red dot. Press Run (F5); execution should halt on the breakpoint. Next, press Step-over (F10) and you should see the LED light...
Getting started with Raspberry Pi Pico-series Chapter 5. Say "Hello World" in C After blinking an LED on and off, the next thing that most developers will want to do is create and use a serial port, and say "Hello World."...
VSCode extension 1. In the VSCode left sidebar, select the Raspberry Pi Pico icon, labelled "Raspberry Pi Pico Project". 2. Select New Project. 3. In the Name field, name your project. For example "hello_world".
Getting started with Raspberry Pi Pico-series automatically generated the .vscode directory for you. Select yes. 5.3. Build your project To run the "Hello world" example: 1. Hold down the BOOTSEL button on your Pico-series device while plugging it into your development device using a micro USB cable to force it into USB Mass Storage Mode.
Getting started with Raspberry Pi Pico-series Appendix A: Debugprobe Raspberry Pi provides two ways to debug Pico-series devices: • Raspberry Pi Debug Probe • debugprobe firmware running on a second Pico or Pico 2 Both methods provide a way to debug Pico-series devices on platforms that lack GPIOs to connect directly to UART or SWD, such as Windows, macOS, and Linux.
Getting started with Raspberry Pi Pico-series To run OpenOCD, use the openocd command in your terminal. Debug Probe The simplest way to debug a Pico-series device is the Raspberry Pi Debug Probe. The Raspberry Pi Debug Probe provides Serial Wire Debug (SWD), and a generic USB-to-Serial bridge.
Getting started with Raspberry Pi Pico-series Figure 9. Wiring between the Debug Probe (left) and Pico (right). To connect Debug Probe to Pico H, connect the following: • Debug Probe "D" port to Pico H "DEBUG" SWD JST-SH connector •...
Getting started with Raspberry Pi Pico-series Figure 10. Wiring between Pico A (left) and Pico B (right) with Pico A acting as a debugger and Pico B as a system under test. You must connect at least the ground and the two SWD wires.
Pico B’s UART serial port through Pico A’s USB connection. You can also use the UART wires to talk to any other UART serial device, such as the boot console on a Raspberry Pi. To power Pico A with Pico B, connect the following pins: •...
Getting started with Raspberry Pi Pico-series $ sudo minicom /dev/ttyACM0 115200 Windows Download and install PuTTY. Open Device Manager and locate the COM port number of the device running debugprobe . In this example it is COM7 Open PuTTY. Select Serial under connection type.
Getting started with Raspberry Pi Pico-series Select Open to start the serial console. You are now ready to run your application. macOS First, install minicom using Homebrew: $ brew install minicom Then, run the following command to use the UART connection:...
Getting started with Raspberry Pi Pico-series $ minicom /dev/tty.usbmodem1234561 115200 Debug with OpenOCD With Debug Probe, you can load binaries via the SWD port and OpenOCD. First, build a binary. Then, run the following command to upload the binary to the Pico, replacing blink.elf...
Page 25
Getting started with Raspberry Pi Pico-series $ gdb blink.elf > target remote localhost:3333 > monitor reset init > continue GDB doesn’t work on all platforms. Use one of the following alternatives instead of , depending on your operating system and device: •...
Getting started with Raspberry Pi Pico-series Appendix B: Picotool It is possible to embed information into a Pico-series binary, which can be retrieved using a command line utility called picotool Getting picotool picotool utility is available in its own repository. You will need to clone and build it if you haven’t ran the pico-setup script.
Getting started with Raspberry Pi Pico-series NOTE If you are building on Microsoft Windows you should invoke CMake as follows, C:\Users\pico\picotool> mkdir build C:\Users\pico\picotool> cd build C:\Users\pico\picotool\build> cmake .. -G "NMake Makefiles" C:\Users\pico\picotool\build> nmake Using picotool picotool binary includes a command-line help function,...
The information can be either read from one or more connected Raspberry Pi microcontrollers in BOOTSEL mode, or from a file. This file can be an ELF, a UF2 or a BIN file.
Page 29
Getting started with Raspberry Pi Pico-series Include all information TARGET SELECTION: To target one or more connected RP2040 device(s) in BOOTSEL mode (the default) --bus <bus> Filter devices by USB bus number --address <addr> ...
Getting started with Raspberry Pi Pico-series $ sudo picotool info -bp Program Information name: hello_world features: stdout to UART Fixed Pin Information 20: UART1 TX 21: UART1 RX The tool can also be used on binaries still on your local filesystem, $ picotool info -a lcd_1602_i2c.uf2...
Getting started with Raspberry Pi Pico-series Filter devices by USB bus number --address <addr> Filter devices by USB device address -f, --force Force a device not in BOOTSEL mode but running compatible code to reset so the ...
Getting started with Raspberry Pi Pico-series • build attributes, this is a similar list of strings, for things pertaining to the binary itself (e.g. Debug Build) Pins This is certainly handy when you have an executable called hello_serial.elf but you forgot what Raspberry Pi microcontroller-based board it was built for, as different boards may have different pins broken out.
Configure your environment via Script If you are developing for a Pico-series device on the Raspberry Pi 5, the Raspberry Pi 4B, or the Raspberry Pi 400, most of the installation steps in this Getting Started guide can be skipped by running the pico_setup.sh...
Getting started with Raspberry Pi Pico-series $ sudo reboot Once your Raspberry Pi has rebooted, you can open Visual Studio Code in the "Programming" menu and follow the instructions from Chapter Manually Configure your Environment Get the SDK and examples Pico Examples repository provides a set of example applications written using the SDK.
Raspberry Pi. Exit raspi-config with Esc. Choose "Yes" and reboot your Raspberry Pi to enable the serial port. IMPORTANT Raspberry Pi 5 makes the UART on the 3-pin debug header the default for serial0 . To use use GPIO pins 15 and 14...
Learning how to blink an LED gets you half way to anywhere. So let’s blink the LED on a Pico-series device. This code shown here for the Raspberry Pi Pico and Pico 2 blinks the LED connected to pin 25 of the device. Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/blink_simple/blink_simple.c...
Getting started with Raspberry Pi Pico-series -- Build files have been written to: /home/pi/pico/pico-examples/build IMPORTANT The SDK builds binaries for the Raspberry Pi Pico 2 by default. To build a binary for a different board, pass the -DPICO_BOARD=<board> option to CMake, replacing the <board>...
Getting started with Raspberry Pi Pico-series Figure 13. Blinking the on-board LED on the Raspberry Pi Pico 2. Arrows point to the on- board LED, and the BOOTSEL button. Using the command line You can use picotool to load a UF2 binary onto your Pico-series device, see...
Removing power from the board does not remove the code. When you restore power to the board, the flashed code will run again. Aside: Other Boards If you are not following these instructions on a Raspberry Pi Pico-series device, you may not have a BOOTSEL button (as...
Page 40
Getting started with Raspberry Pi Pico-series while (1) { gpio_put(LED_PIN, 0); sleep_ms(250); gpio_put(LED_PIN, 1); puts("Hello World\n"); sleep_ms(1000); 24 } ① ② The onboard LED is connected to GP25 on Pico and Pico 2, if These lines will add strings to the binary visible using you’re building for Pico W the LED is connected to...
$ cmake .. $ make IMPORTANT The SDK builds binaries for the Raspberry Pi Pico by default. To build a binary for a different board, pass the -DPICO_BOARD=<board> option to CMake, replacing the <board> placeholder with the name of the board you’d like to target.
Page 42
Getting started with Raspberry Pi Pico-series deeper into how your project is actually built, and how the lines in our CMakeLists.txt files here relate to the structure of the SDK, if you find yourself wanting to know more at some future point.
Eclipse is a multiplatform Integrated Development environment (IDE) available for Linux, macOS, and Windows. The latest version works well on the Raspberry Pi 4, 400, and 5 (4GB and up) running a 64-bit OS. The following instructions describe how to set up Eclipse on a Linux device for to develop on Pico-series devices. Instructions for other systems will be broadly similar, although the details of connecting to Pico-series devices vary.
Page 44
2-wire debug connections from the host device to the microcontroller prior to running the code. On a Raspberry Pi, this can be done via GPIO connections, but on a laptop or desktop device, you need to use extra hardware for this connection.
Getting started with Raspberry Pi Pico-series Figure 14. Setting the OCD executable name and path in Eclipse. Creating a Run configuration In order to run or debug code in Eclipse you need to set up a Run Configuration. This sets up all the information needed to identify the code to run, any parameters, the debugger, source paths and SVD information.
Page 46
Eclipse. Setting up the debugger Let’s set up OpenOCD to talk to the Raspberry Pi microcontroller. openocd in the boxes labelled Executable and Actual Executable. We also need to set up OpenOCD to use the Pico specific configuration, so in the Config options sections add the following.
Page 47
Getting started with Raspberry Pi Pico-series Figure 17. Setting up the Debugger and OpenOCD in Eclipse. Setting up the SVD plugin SVD provides a mechanism to view and set peripheral registers on the Pico board. An SVD file provides register locations and descriptions, and the SVD plugin for Eclipse integrates that functionality in to the Eclipse IDE.
Mac. This is a commercial IDE often the choice of professional developers (or those who love JetBrains IDEs) although there are free or reduce price licenses available. It will run on a Raspberry Pi, however the performance is not ideal, so it is expected you would be using CLion on your desktop or laptop.
Page 49
Getting started with Raspberry Pi Pico-series Figure 20. A newly opened CLion pico- examples project. Notice at the bottom that CLion attempted to load the CMake project, but there was an error; namely that we hadn’t specified PICO_SDK_PATH Configuring CMake Profiles Select Settings…...
Page 50
Getting started with Raspberry Pi Pico-series IMPORTANT The SDK builds binaries for the Raspberry Pi Pico by default. To build a binary for a different board, pass the -DPICO_BOARD=<board> option to CMake, replacing the <board> placeholder with the name of the board you’d like to target.
Page 51
(see Figure 25). In this case this is the cmake-build-debug directory. The UF2 file can be copied onto a Raspberry Pi microcontroller in BOOTSEL mode, or the ELF can be used for debugging. Figure 25. Locating hello_usb build...
Getting started with Raspberry Pi Pico-series Other Environments There are too development environments available to describe all of them here. You can use many of them with the SDK. In general, IDEs require the following features to support Pico-series devices: •...
Need help?
Do you have a question about the Pico Series and is the answer not in the manual?
Questions and answers