Getting started with Raspberry Pi Pico Colophon Copyright © 2020 Raspberry Pi (Trading) Ltd. The documentation of the RP2040 microcontroller is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND). build-date: 2021-09-30 build-version: 000dcb1-clean About the SDK Throughout the text "the SDK" refers to our Raspberry Pi Pico SDK. More details about the SDK can be found in the Raspberry Pi Pico C/C++ SDK book.
Getting started with Raspberry Pi Pico Table of Contents Colophon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Legal Disclaimer Notice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1. Quick Pico Setup . . . . . . . . . . . . . . . . . . . . . . . . . .
Getting started with Raspberry Pi Pico 10.2.1. Setting up CLion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.3. Other Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.3.1. Using openocd-svd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Getting started with Raspberry Pi Pico Chapter 1. Quick Pico Setup If you are developing for Raspberry Pi Pico on 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 setup script. NOTE This setup script requires approximately 2.5GB of disk space on your SD card, so make sure you have enough free space before running it. You can check how much free disk space you have with the df -h command.
Getting started with Raspberry Pi Pico NOTE The pico directory will be created in the folder where you run the pico_setup.sh script. Once it has run, you will need to reboot your Raspberry Pi, $ sudo reboot for the UART reconfiguration to take effect. Once your Raspberry Pi has rebooted you can open Visual Studio Code in the "Programming" menu and follow the instructions from Section 7.2. Chapter 1.
Getting started with Raspberry Pi Pico Chapter 2. The SDK IMPORTANT The following instructions assume that you are using a Raspberry Pi Pico and some details may differ if you are using a different RP2040-based board. They also assume you are using Raspberry Pi OS running on a Raspberry Pi 4, or an equivalent Debian-based Linux distribution running on another platform. Alternative instructions for those using Microsoft Windows (see Section 9.2) or Apple macOS (see Section 9.1) are also provided.
Getting started with Raspberry Pi Pico WARNING If you have not initialised the tinyusb submodule in your pico-sdk checkout then USB CDC serial, and other USB functions and example code, will not work as the SDK will contain no USB functionality. NOTE There are additional repositories: pico-extras, and pico-playground that you may also be interested in. 2.2. Install the Toolchain To build the applications in pico-examples, you’ll need to install some extra tools.
Getting started with Raspberry Pi Pico Chapter 3. Blinking an LED in C When you’re writing software for hardware, turning an LED on, off, and then on again, is typically the first program that gets run in a new programming environment. Learning how to blink an LED gets you half way to anywhere. We’re going to go ahead and blink the on-board LED on the Raspberry Pi Pico which is connected to pin 25 of the RP2040. Pico Examples: https://github.com/raspberrypi/pico-examples/tree/master/blink/blink.
Getting started with Raspberry Pi Pico . . -- Build files have been written to: /home/pi/pico/pico-examples/build NOTE cmake will default to a Release build with compiler optimisations enabled and debugging information removed. To build a debug version, run cmake -DCMAKE_BUILD_TYPE=Debug ... We will explore this later in Section 6.1. CMake has now prepared a build area for the pico-examples tree. From here, it is possible to type make to build all example applications.
Getting started with Raspberry Pi Pico 3.2.1. From the desktop If you are running the Raspberry Pi Desktop the Raspberry Pi Pico should automatically mount as a USB Mass Storage Device. From here, you can Drag-and-drop blink.uf2 onto the Mass Storage Device. RP2040 will reboot, unmounting itself as a Mass Storage Device, and start to run the flashed code, see Figure 1. Figure 1. Blinking the on-board LED on the Raspberry Pi Pico. Arrows point to the onboard LED, and the BOOTSEL button. 3.2.2.
Getting started with Raspberry Pi Pico sudo umount /mnt/pico NOTE Removing power from the board does not remove the code. When the board is reattached to power, the code you have just loaded will begin running again. If you want to upload new code to the board (and overwrite whatever was already on there), press and hold the BOOTSEL button when applying power to put the board into Mass Storage mode. 3.2.3.
Getting started with Raspberry Pi Pico Chapter 4. Saying "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." Pico Examples: https://github.com/raspberrypi/pico-examples/tree/master/hello_world/serial/hello_serial.c Lines 10 - 17 10 int main() { 11 stdio_init_all(); 12 while (true) { 13 printf("Hello, world!\n"); 14 sleep_ms(1000); 15 } 16 return 0; 17 } 4.1.
Getting started with Raspberry Pi Pico The destination for stdout can be changed using CMake directives, with output directed to UART or USB CDC, or to both, pico_enable_stdio_usb(hello_world 1) ① pico_enable_stdio_uart(hello_world 0) ② 1. Enable printf output via USB CDC (USB serial) 2. Disable printf output via UART This means that without changing the C source code, you can change the destination for stdio from UART to USB. Pico Examples: https://github.
Getting started with Raspberry Pi Pico Amongst other targets, we have now built: • serial/hello_serial.elf, which is used by the debugger • serial/hello_serial.uf2, which can be dragged onto the RP2040 USB Mass Storage Device (UART serial binary) • usb/hello_usb.elf, which is used by the debugger • usb/hello_usb.uf2, which can be dragged onto the RP2040 USB Mass Storage Device (USB serial binary) Where hello_serial directs stdio to UART0 on pins GP0 and GP1, and hello_usb directs stdio to USB CDC serial.
Getting started with Raspberry Pi Pico $ sudo apt install minicom and open the serial port: $ minicom -b 115200 -o -D /dev/ttyACM0 You should see Hello, world! printed to the console. TIP To exit minicom, use CTRL-A followed by X. NOTE If you are intending to using SWD for debugging (see Chapter 6) you need to use a UART based serial connection as the USB stack will be paused when the RP2040 cores are stopped during debugging, which will cause any attached USB devices to disconnect. 4.5.
Getting started with Raspberry Pi Pico You should then wire the Raspberry Pi and the Raspberry Pi Pico together with the following mapping: Raspberry Pi Raspberry Pi Pico GND (Pin 14) GND (Pin 3) GPIO15 (UART_RX0, Pin 10) GP0 (UART0_TX, Pin 1) GPIO14 (UART_TX0, Pin 8) GP1 (UART0_RX, Pin 2) See Figure 4. Figure 4. A Raspberry Pi 4 and the Raspberry Pi Pico with UART0 connected together.
Getting started with Raspberry Pi Pico Figure 5. Raspberry Pi and Raspberry Pi Pico connected only using the GPIO pins. Whilst it is possible to connect the Raspberry Pi’s 5V pin to the Raspberry Pi Pico VBUS pin, this is not recommended. Shorting the 5V rails together will mean that the Micro USB cannot be used. An exception is when using the Raspberry Pi Pico in USB host mode, in this case 5V must be connected to the VBUS pin. The 3.
Getting started with Raspberry Pi Pico Chapter 5. Flash Programming with SWD Serial Wire Debug (SWD) is a standard interface on Cortex-M-based microcontrollers, which the machine you are using to develop your code (commonly called the host) can use to reset the board, load code into flash, and set the code running. Raspberry Pi Pico exposes the RP2040 SWD interface on three pins at the bottom edge of the board.
Getting started with Raspberry Pi Pico RP2040) inside the microcontroller. The debug translator also knows how to talk to the specific debug probe that you have connected to the SWD port, and how to program the flash on your device. This section walks through installing a debug translator called OpenOCD. TIP If you have run the pico-setup script on your Raspberry Pi (Chapter 1), OpenOCD is already installed and you can skip to the next section.
Getting started with Raspberry Pi Pico Raspberry Pi Raspberry Pi Pico GND (Pin 20) SWD GND GPIO24 (Pin 18) SWDIO GPIO25 (Pin 22) SWCLK as seen in Figure 7. TIP If you are using another debug probe, like Picoprobe (Appendix A), you need to connect the GND, SWCLK and SWDIO pins on your probe to the matching pins on your Raspberry Pi Pico, or other RP2040-based board.
Getting started with Raspberry Pi Pico reset Put the RP2040 into a clean initial state, as though it had just powered up, so that it is ready to run our code. exit Disconnect from the RP2040 and exit. Our freshly-programmed code will start running once OpenOCD disconnects. TIP If you see an error like Info: DAP init failed then OpenOCD could not see an RP2040 on the SWD interface it used. The most common reasons are that your board is not correctly powered via e.g.
Getting started with Raspberry Pi Pico Chapter 6. Debugging with SWD As well as resetting the board, loading and running code, the SWD port on RP2040-based boards like Raspberry Pi Pico can be used to interactively debug a program you have loaded.
Getting started with Raspberry Pi Pico $ openocd -f interface/raspberrypi-swd.cfg -f target/rp2040.cfg Your output should look like this: ... Info : rp2040.core0: hardware has 4 breakpoints, 2 watchpoints Info : rp2040.core1: hardware has 4 breakpoints, 2 watchpoints Info : starting gdb server for rp2040.
Getting started with Raspberry Pi Pico IMPORTANT If you see errors similar to Error finishing flash operation or Error erasing flash with vFlashErase packet in GDB when attempting to load the binary onto the Raspberry Pi Pico via OpenOCD then there is likely poor signal integrity between the Raspberry Pi and the Raspberry Pi Pico. If you are not directly connecting the SWD connection between the two boards, see Figure 7, you should try to do that.
Getting started with Raspberry Pi Pico Chapter 7. Using Visual Studio Code Visual Studio Code (VSCode) is a popular open source editor developed by Microsoft. It is the recommended Integrated Development Environment (IDE) on the Raspberry Pi 4 if you want a graphical interface to edit and debug your code. 7.1.
Getting started with Raspberry Pi Pico 7.2. Loading a Project Go ahead and open the pico-examples folder by going to the Explorer toolbar (Ctrl + Shift + E), selecting "Open Folder," and nagivating to, /home/pi/pico/pico-examples in the file popup. Then click "OK" to load the Folder into VSCode. As long as the CMake Tools extension is installed, after a second or so you should see a popup in the lower right-hand corner of the vscode window. Hit "Yes" to configure the project.
Getting started with Raspberry Pi Pico Figure 9. Building the pico-examples project in Visual Studio Code As we did from the command line previously, amongst other targets, we have now built: • hello_usb.elf, which is used by the debugger • hello_usb.uf2, which can be dragged onto the RP2040 USB Mass Storage Device 7.3. Debugging a Project The pico-examples repo contains an example debug configuration that will start OpenOCD, attach GDB, and finally launch the application CMake is configured to build.
Getting started with Raspberry Pi Pico 11 // This may need to be arm-none-eabi-gdb depending on your system 12 "gdbPath" : "gdb-multiarch", 13 "device": "RP2040", 14 "configFiles": [ 15 "interface/raspberrypi-swd.cfg", 16 "target/rp2040.cfg" 17 ], 18 "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.
Getting started with Raspberry Pi Pico IMPORTANT Ensure that the example "Hello USB" code has been built as a Debug binary (CMAKE_BUILD_TYPE=Debug). Now go to the Debug toolbar (Ctrl + Shift + D) and click the small green arrow (play button) at the top of the left-hand window pane to load your code on the Raspberry Pi Pico and start debugging. Figure 10.
Getting started with Raspberry Pi Pico Chapter 8. Creating your own Project Go ahead and create a directory to house your test project sitting alongside the pico-sdk directory, $ ls -la total 16 drwxr-xr-x 7 aa staff 224 6 Apr 10:41 ./ drwx------@ 27 aa staff 864 6 Apr 10:41 ../ drwxr-xr-x 10 aa staff 320 6 Apr 09:29 pico-examples/ drwxr-xr-x 13 aa staff 416 6 Apr 09:22 pico-sdk/ $ mkdir test $ cd test and then create a test.c file in the directory, 1 #include
Getting started with Raspberry Pi Pico pico_enable_stdio_usb(test 1)① pico_enable_stdio_uart(test 1)② pico_add_extra_outputs(test) target_link_libraries(test pico_stdlib) 1. This will enable serial output via USB. 2. This will enable serial output via UART. Then copy the pico_sdk_import.cmake file from the external folder in your pico-sdk installation to your test project folder. $ cp ../pico-sdk/external/pico_sdk_import.cmake .
Getting started with Raspberry Pi Pico NOTE UF2 (USB Flashing Format) is a file format, developed by Microsoft, that is used for flashing the RP2040 board over USB. More details can be found on the Microsoft UF2 Specification Repo NOTE To build a binary to run in SRAM, rather than Flash memory you can either setup your cmake build with -DPICO_NO_FLASH=1 or you can add pico_set_binary_type(TARGET_NAME no_flash) to control it on a per binary basis in your CMakeLists.txt file.
Getting started with Raspberry Pi Pico This OpenOCD terminal needs to be left open. So go ahead and open another terminal window and start gdb-multiarch using $ cd ~/pico/test/build $ gdb-multiarch test.elf Connect GDB to OpenOCD, and load the test.elf binary into flash, (gdb) target remote localhost:3333 (gdb) load and then start it running, (gdb) monitor reset init (gdb) continue 8.2.
Getting started with Raspberry Pi Pico Figure 12. Creating a RP2040 project using the graphical project creation tool. You can add specific features to your project by selecting them from the check boxes on the GUI. This will ensure the build system adds the appropriate code to the build, and also adds simple example code to the project showing how to use the feature. There are a number of options available, which provide the following functionality.
Getting started with Raspberry Pi Pico Build Options Description Run Build Once the project has been created, build it. This will produce files ready for download to the Raspberry Pi Pico. Overwrite Project If a project already exists in the specified folder, overwrite it with the new project. This will overwrite any changes you may have made. IDE Options Description Create VSCode Project As well as the CMake files, also create the appropriate Visual Studio Code project files.
Getting started with Raspberry Pi Pico Chapter 9. Building on other platforms While the main supported platform for developing for the RP2040 is the Raspberry Pi, support for other platforms, such as Apple macOS and Microsoft Windows, is available. 9.1. Building on Apple macOS Using macOS to build code for RP2040 is very similar to Linux. 9.1.1.
Getting started with Raspberry Pi Pico "PICO_SDK_PATH":"../../pico-sdk" }, } Now click on the Cog Wheel at the bottom of the navigation bar on the left-hand side of the interface and select "Settings". Then in the Settings pane click on "Extensions" and the "CMake Tools configuration". Then scroll down to "Cmake: Generator" and enter "Unix Makefiles" into the box. NOTE Depending on your local setup you may not need to set the CMake generator manually to "Unix Makefiles".
Getting started with Raspberry Pi Pico 9.1.4. Saying "Hello World" As we did previously in Chapter 4 you can build the Hello World example with stdio routed either to USB CDC (Serial) or to UART0 on pins GP0 and GP1. No driver installation is necessary if you’re building with USB CDC as the target output, as it’s a class-compliant device. You just need to use a Terminal program, e.g. Serial or similar, to connect to the USB serial port. 9.1.4.1.
Getting started with Raspberry Pi Pico WARNING Using Raspberry Pi Pico with Windows 7 or 8 is not officially supported but can be made to work. 9.2.1. Installing the Toolchain To build you will need to install some extra tools. • ARM GCC compiler • CMake • Build Tools for Visual Studio 2019 • Python 3.
Getting started with Raspberry Pi Pico Figure 16. Installing the Build Tools for Visual Studio 2019. When prompted by the Build Tools for Visual Studio installer you need to install the C++ build tools only. NOTE You must install the full "Windows 10 SDK" package as the SDK will need to build the pioasm and elf2uf2 tools locally. Removing it from the list of installed items will mean that you will be unable to build Raspberry Pi Pico binaries. 9.2.1.4. Installing Python 3.
Getting started with Raspberry Pi Pico 9.2.1.5. Installing Git When installing Git you should ensure that you change the default editor away from vim, see Figure 18. Figure 18.
Getting started with Raspberry Pi Pico C:\Users\pico\Downloads> cd pico-examples C:\Users\pico\Downloads\pico-examples> mkdir build C:\Users\pico\Downloads\pico-examples> cd build C:\Users\pico\Downloads\pico-examples\build> cmake -G "NMake Makefiles" .. C:\Users\pico\Downloads\pico-examples\build> nmake to build the target. This will produce ELF, bin, and uf2 targets, you can find these in the hello_world/serial and hello_world/usb directories inside your build directory.
Getting started with Raspberry Pi Pico Figure 19. Setting PICO_SDK_PATH Environment Variable in the CMake Extension Additionally you will need to scroll down to "Cmake: Generator" and enter "NMake Makefiles" into the box. IMPORTANT If you do not change the "Cmake: Generator" Visual Studio will default to ninja and the build might fail as GCC outputs dependency-information in a slightly-incorrect format that ninja can’t understand.
Getting started with Raspberry Pi Pico 9.2.5. Flashing and Running "Hello World" Connect the Raspberry Pi Pico to your Raspberry Pi using a micro-USB cable, making sure that you hold down the BOOTSEL button to force it into USB Mass Storage Mode. The board should automatically appear as a external drive. You can now drag-and-drop the UF2 binary onto the external drive. The Raspberry Pi Pico will reboot, and unmount itself as an external drive, and start running the flashed code.
Getting started with Raspberry Pi Pico NOTE If you have multiple serial devices and can’t figure out which one is your UART to USB serial converter, try unplugging your cable, and running chgport again to see which COM port disappears. After entering the speed and port, hit the "Open" button and you should see the UART output from the Raspberry Pi Pico in your Terminal window. 9.2.
Getting started with Raspberry Pi Pico Chapter 10. Using other Integrated Development Environments Currently the recommended Integrated Development Environment (IDE) is Visual Studio Code, see Chapter 7. However other environments can be used with RP2040 and the Raspberry Pi Pico. 10.1. Using Eclipse Eclipse is a multiplatform Integrated Development environment (IDE), available for x86 Linux, Windows and Mac.
Getting started with Raspberry Pi Pico 10.1.1.2. Using pico-examples The standard build system for the Pico environment is CMake. However Eclipse does not use CMake as it has its own build system, so we need to convert the pico-examples CMake build to an Eclipse project.
Getting started with Raspberry Pi Pico 10.1.1.5. 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. From the Eclipse Run menu, select Run Configurations. To create a debugger configuration, select GDB OpenOCD Debugging option, then select the New Configuration button. Figure 23.
Getting started with Raspberry Pi Pico Figure 24. Setting the executable to debug in Eclipse. 10.1.1.5.2. Setting up the debugger We are using OpenOCD to talk to the Raspberry Pi Pico, so we need to set this up. Set openocd in the Executable box and Actual Executable box. We also need to set up OpenOCD to use the Pico specific configuration, so in the Config options sections add the following. Note you will need to change the path to point to the location where the Pico version of OpenOCD is installed.
Getting started with Raspberry Pi Pico 10.1.1.5.3. 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. The SVD plugin comes as part of the Embedded development plugins. Select the SVD path tab on the Launch configuration, and enter the location on the file system where the SVD file is located.
Getting started with Raspberry Pi Pico 10.2. Using CLion CLion is a multiplatform Integrated Development environment (IDE) from JetBrains, available for Linux, Windows and 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.
Getting started with Raspberry Pi Pico Figure 29. Configuring a CMake profile in CLion. You can have as many CMake profiles as you like with different settings. You probably want to add a Release build by hitting the + button, and then filling in the PICO_SDK_PATH again, or by hitting the copy button two to the right, and fixing the name and settings (see Figure 30) Figure 30. Configuring a second CMake Profile in CLion. After pressing OK, you’ll see something like Figure 31.
Getting started with Raspberry Pi Pico Figure 31. Configuring a second CMake profile in CLion. 10.2.1.1.2. Running a build Now we can choose to build one or more targets. For example you can navigate to the drop down selector in the middle of the toolbar, and select or starting typing hello_usb; then press the tool icon to its left to build (see Figure 32). Alternatively you can do a full build of all targets or other types of build from the Build menu. Figure 32. hello_usb successfully built.
Getting started with Raspberry Pi Pico 10.2.1.1.3. Build Artifacts The build artifacts are located under cmake-build- under the project root (see Figure 33). In this case this is the cmake-build-debug directory. The UF2 file can be copied onto an RP2040 device in BOOTSEL mode, or the ELF can be used for debugging. Figure 33. Locating the hello_usb build artifacts 10.3.
Getting started with Raspberry Pi Pico Ensuring your Raspberry Pi 4 and Raspberry Pi Pico are correctly wired together, we can attach OpenOCD to the chip, via the swd and rp2040 configs. $ openocd -f interface/raspberrypi-swd.cfg -f target/rp2040.cfg WARNING If your flash has DORMANT mode code in it, or any code that stops the system clock, the debugger will fail to attach because the system clock is stopped.
Getting started with Raspberry Pi Pico Figure 34. OpenOCD SVD running and connected to the Raspberry Pi Pico. 10.3.
Getting started with Raspberry Pi Pico Appendix A: Using Picoprobe One Raspberry Pi Pico can be used to reprogram and debug another, using the picoprobe firmware, which transforms a Pico into a USB → SWD and UART bridge. This makes it easy to use a Raspberry Pi Pico on non Raspberry Pi platforms such as Windows, Mac, and Linux computers where you don’t have GPIOs to connect directly to UART or SWD, but you do have a USB port. Figure 35.
Getting started with Raspberry Pi Pico software." Download and run the installer from https://www.msys2.org/. Start by updating the package database and core system packages with: pacman -Syu If MSYS2 closes, start it again (making sure you select the 64-bit version) and run pacman -Su to finish the update.
Getting started with Raspberry Pi Pico Close MSYS2 and reopen the 64-bit version to make sure the environment picks up GCC. $ git clone https://github.com/raspberrypi/openocd.git --branch picoprobe --depth=1 $ cd openocd $ ./bootstrap $ ./configure --enable-picoprobe --disable-werror ① $ make -j4 1. Unfortunately disable-werror is needed because not everything compiles cleanly on Windows Finally run OpenOCD to check it has built correctly.
Getting started with Raspberry Pi Pico Install dependencies brew install libtool automake libusb wget pkg-config gcc texinfo ① 1. The version of texinfo shipped with OSX is below the version required to build OpenOCD docs $ cd ~/pico $ git clone https://github.com/raspberrypi/openocd.git --branch picoprobe --depth=1 $ cd openocd $ export PATH="/usr/local/opt/texinfo/bin:$PATH" ① $ ./bootstrap $ ./configure --enable-picoprobe --disable-werror ② $ make -j4 1. Put newer version of texinfo on the path 2.
Getting started with Raspberry Pi Pico cmake .. make -j4 Boot the Raspberry Pi Pico you would like to act as a debugger with the BOOTSEL button pressed and drag on picoprobe.uf2. Picoprobe Wiring Figure 36. Wiring between Pico A (left) and Pico B (right) configuring Pico A as a debugger. Note that if Pico B is a USB Host then you’d want to hook VBUS up to VBUS so it can provide 5V instead of VSYS to VSYS. The wiring loom between the two Pico boards is shown in Figure 36.
Getting started with Raspberry Pi Pico IMPORTANT If Pico B is a USB Host then you must connect VBUS to VBUS, not VSYS to VSYS, so that Pico B can provide 5V on its USB connector. If Pico B is using USB in device mode, or not using its USB at all, this is not necessary. Install Picoprobe driver (only needed on Windows) The Picoprobe device has two usb interfaces: 1. A class-compliant CDC UART (serial port), which means it works on Windows out of the box 2. A vendor-specific interface for SWD probe data.
Getting started with Raspberry Pi Pico Windows Download and install PuTTY https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html Open Device Manager and locate Picoprobe’s COM port number. In this example it is COM7. Open PuTTY. Select Serial under connection type. Then type the name of your COM port along with 115200 as the speed. Select Open to start the serial console.
Getting started with Raspberry Pi Pico Mac brew install minicom minicom -D /dev/tty.usbmodem1234561 -b 115200 Using Picoprobe with OpenOCD Same for all platforms src/openocd -f interface/picoprobe.cfg -f target/rp2040.
Getting started with Raspberry Pi Pico Appendix B: Using Picotool It is possible to embed information into a Raspberry Pi Pico binary, which can be retrieved using a command line utility called picotool. Getting picotool The 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. $ git clone -b master https://github.com/raspberrypi/picotool.
Getting started with Raspberry Pi Pico 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 The picotool binary includes a command-line help function, $ picotool help PICOTOOL: Tool for interacting with a RP2040 device in BOOTSEL mode, or with a RP2040 binary SYNOPSYS: picotool info [-b] [-p] [-d]
Getting started with Raspberry Pi Pico IMPORTANT If you get an error message No accessible RP2040 devices in BOOTSEL mode were found. accompanied with a note similar to Device at bus 1, address 7 appears to be a RP2040 device in BOOTSEL mode, but picotool was unable to connect indicating that there was a Raspberry Pi Pico connected then you should run pictool using sudo, e.g.
Getting started with Raspberry Pi Pico $ sudo picotool info Program Information name: hello_world features: stdout to UART or, $ sudo picotool info -a Program Information name: hello_world features: stdout to UART binary start: 0x10000000 binary end: 0x1000606c Fixed Pin Information 20: UART1 TX 21: UART1 RX Build Information build date: Dec 31 2020 build attributes: Debug build Device Information flash size: 2048K ROM version: 2 for more information.
Getting started with Raspberry Pi Pico Save the program Save allows you to save a range of memory or a program or the whole of flash from the device to a BIN file or a UF2 file. $ picotool help save SAVE: Save the program / memory stored in flash on the device to a file.
Getting started with Raspberry Pi Pico Basic information This information is really handy when you pick up a Pico and don’t know what is on it! Basic information includes • program name • program description • program version string • program build date • program url • program end address • program features, this is a list built from individual strings in the binary, that can be displayed (e.g.
Getting started with Raspberry Pi Pico 20: UART1 TX 21: UART1 RX There is one line in the setup_default_uart function: bi_decl_if_func_used(bi_2pins_with_func(PICO_DEFAULT_UART_RX_PIN, PICO_DEFAULT_UART_TX_PIN, GPIO_FUNC_UART)); The two pin numbers, and the function UART are stored, then decoded to their actual function names (UART1 TX etc) by picotool. The bi_decl_if_func_used makes sure the binary information is only included if the containing function is called.
Getting started with Raspberry Pi Pico #define bi_program_url(url) bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PROGRAM_URL, url) You then either use bi_decl(bi_blah(…)) for unconditional inclusion of the binary info blah, or bi_decl_if_func_used(bi_blah(…)) for binary information that may be stripped if the enclosing function is not included in the binary by the linker (think --gc-sections). For example, 1 #include 2 #include "pico/stdlib.
Getting started with Raspberry Pi Pico Setting common fields from CMake You can also set fields directly from your project’s CMake file, e.g., pico_set_program_name(foo "not foo") ① pico_set_program_description(foo "this is a foo") pico_set_program_version_string(foo "0.00001a") pico_set_program_url(foo "www.plinth.com/foo") 1. The name "foo" would be the default. NOTE All of these are passed as command line arguments to the compilation, so if you plan to use quotes, newlines etc.
Getting started with Raspberry Pi Pico Appendix C: Documentation Release History Table 1. Documentation Release History Release Date 1.0 21/Jan/2021 • Initial release 1.1 26/Jan/2021 • Minor corrections • Extra information about using DMA with ADC • Clarified M0+ and SIO CPUID registers • Added more discussion of Timers • Update Windows and macOS build instructions • Renamed books and optimised size of output PDFs 1.
Getting started with Raspberry Pi Pico Release Date 1.4.1 13/Apr/2021 Description • Minor corrections • Clarified that all source code in the documentation is under the 3-Clause BSD license. 1.5 07/Jun/2021 • Minor updates and corrections • Updated FAQ • Added SDK release history • To accompany the V1.2.0 release of the C SDK 1.6 23/Jun/2021 • Minor updates and corrections • ADC information updated • Added errata E11 1.6.