Add library for reset interface (#2629)
* Allow use of reset interface with custom descriptors
* Fix pico_config assertion error
* Create separate library for reset interface
* Move pico_usb_reset_interface library into separate folder
* Fix bazel build
* Move ms_os_20_desc into header
* CFG_TUD_VENDOR isn't actually used
* Add documentation to usb_reset_interface.h
* Change #if PICO_ON_DEVICE -> #if LIB_PICO_USB_RESET_INTERFACE
Cleaner way of separating the usb_reset_interface.h header
* Rename publically accessible functions
* Move LIB_PICO_USB_RESET_INTERFACE only headers into separate files
* Make new usb_reset_interface_device header so old usb_reset_interface header remains the same
* Review fixups
pico_usb_reset_... -> usb_reset_...
PICO_STDIO_USB_RESET_INCLUDE_APP_DRIVER_CB -> PICO_STDIO_USB_RESET_INCLUDE_DEFAULT_APP_DRIVER_CB
Add to docs/index.h
* Remove STDIO from defines
Include backwards compatibility with old define names
Also fix bazel build
* Merge pico_stdio_usb: fix overlap between activity-LED GPIO and active_low bit (#2947)
commit 97ed432d39da36146ea423ad7b0a175b3add1590
Author: Graham Sanderson <graham.sanderson@raspberrypi.com>
Date: Tue May 19 17:37:03 2026 -0500
grr
commit 90c5d5a023f5d0ae38efbb47b1a4b7efe289abb3
Author: Graham Sanderson <graham.sanderson@raspberrypi.com>
Date: Tue May 19 17:36:27 2026 -0500
missing ) in comment
commit 082e45980f52cfef103ac92700868d3bd8614020
Author: Graham Sanderson <graham.sanderson@raspberrypi.com>
Date: Tue May 19 17:35:37 2026 -0500
Re-arrange bit patterns to be more backwards compatible
commit e2436165ad8d1cd286afc577efbda62bf253febb
Author: Andrii Anoshyn <anoshyn.andrii@gmail.com>
Date: Sat May 16 14:29:23 2026 +0300
pico_stdio_usb: fix overlap between activity-LED GPIO and active_low bit
The bootsel reset USB control transfer encodes the activity-LED GPIO in
wValue. The current layout reads:
if (request->wValue & 0x100) {
gpio = request->wValue >> 9u;
}
active_low = request->wValue & 0x200;
Bit 9 (0x200) is the active_low flag, but `gpio = wValue >> 9` also
makes bit 9 the low bit of the extracted GPIO number. As a result:
- Any odd-numbered activity-LED GPIO is silently flagged active_low.
- Any client wanting active_low has the GPIO number's low bit forced.
The active_low line was added in commit 5a988894 (\"add
rom_reset_usb_boot_extra which supports >32 pins and ACTIVE_LOW\") on
top of the original \"gpio = wValue >> 9\" encoding from commit 383e88ea,
without shifting the gpio over by an extra bit to make room. See #2713.
Shift the GPIO extraction to (wValue >> 10) so bit 9 is reserved for
active_low alone. The resulting GPIO field is 6 bits (0-63), enough
for RP2040 (30 GPIOs) and RP2350 (48 GPIOs). The canonical client
(picotool) only sends wValue=disable_mask with bits 0-1 set, so this
does not change any in-tree behavior; the change is only visible to
out-of-tree clients that build wValue with the GPIO-specified bit set.
Fixes #2713.
* fix search & replace typo
* Rename library to pico_usb_reset, and move headers into rp2_common
* Fix bazel build, and remove some unnecessary backwards compatibility for new defines
* fix bazel formatting
* Reorder pico_config defines
Place vendor interface defines after PICO_ENABLE_USB_RESET_VIA_VENDOR_INTERFACE, and bootsel defines after PICO_USB_RESET_SUPPORT_RESET_TO_BOOTSEL
* Mention that active_low is ignored on RP2040
* Make wValue parsing better match the commentThe Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build system necessary to write programs for the RP-series microcontroller-based devices such as the Raspberry Pi Pico or Raspberry Pi Pico 2 in C, C++ or assembly language.
The SDK is designed to provide an API and programming environment that is familiar both to non-embedded C developers and embedded C developers alike. A single program runs on the device at a time and starts with a conventional main() method. Standard C/C++ libraries are supported along with C-level libraries/APIs for accessing all of the RP-series microcontroller's hardware including PIO (Programmable IO).
Additionally, the SDK provides higher level libraries for dealing with timers, synchronization, Wi-Fi and Bluetooth networking, USB and multicore programming. These libraries should be comprehensive enough that your application code rarely, if at all, needs to access hardware registers directly. However, if you do need or prefer to access the raw hardware registers, you will also find complete and fully-commented register definition headers in the SDK. There's no need to look up addresses in the datasheet.
The SDK can be used to build anything from simple applications, fully-fledged runtime environments such as MicroPython, to low level software such as the RP-series microcontroller's on-chip bootrom itself.
The design goal for entire SDK is to be simple but powerful.
Additional libraries/APIs that are not yet ready for inclusion in the SDK can be found in pico-extras.
See Getting Started with the Raspberry Pi Pico-Series for information on how to setup your hardware, IDE/environment and how to build and debug software for the Raspberry Pi Pico and other RP-series microcontroller based devices.
See Connecting to the Internet with Raspberry Pi Pico W to learn more about writing applications for your Raspberry Pi Pico W that connect to the internet.
See Raspberry Pi Pico-Series C/C++ SDK to learn more about programming using the SDK, to explore more advanced features, and for complete PDF-based API documentation.
See Online Raspberry Pi Pico SDK API docs for HTML-based API documentation.
See pico-examples for example code you can build.
The master branch of pico-sdk on GitHub contains the latest stable release of the SDK. If you need or want to test upcoming features, you can try the develop branch instead.
You can install the Raspberry Pi Pico Visual Studio Code extension in VS Code.
These instructions are extremely terse, and Linux-based only. For detailed steps, instructions for other platforms, and just in general, we recommend you see Raspberry Pi Pico-Series C/C++ SDK
Install CMake (at least version 3.13), python 3, a native compiler, and a GCC cross compiler
sudo apt install cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
Set up your project to point to use the Raspberry Pi Pico SDK
Either by cloning the SDK locally (most common) :
git clone this Raspberry Pi Pico SDK repository
Copy pico_sdk_import.cmake from the SDK into your project directory
Set PICO_SDK_PATH to the SDK location in your environment, or pass it (-DPICO_SDK_PATH=) to cmake later.
Setup a CMakeLists.txt like:
cmake_minimum_required(VERSION 3.13...3.27) # initialize the SDK based on PICO_SDK_PATH # note: this must happen before project() include(pico_sdk_import.cmake) project(my_project) # initialize the Raspberry Pi Pico SDK pico_sdk_init() # rest of your project
Or with the Raspberry Pi Pico SDK as a submodule :
Clone the SDK as a submodule called pico-sdk
Setup a CMakeLists.txt like:
cmake_minimum_required(VERSION 3.13...3.27) # initialize pico-sdk from submodule # note: this must happen before project() include(pico-sdk/pico_sdk_init.cmake) project(my_project) # initialize the Raspberry Pi Pico SDK pico_sdk_init() # rest of your project
Or with automatic download from GitHub :
Copy pico_sdk_import.cmake from the SDK into your project directory
Setup a CMakeLists.txt like:
cmake_minimum_required(VERSION 3.13) # initialize pico-sdk from GIT # (note this can come from environment, CMake cache etc) set(PICO_SDK_FETCH_FROM_GIT on) # pico_sdk_import.cmake is a single file copied from this SDK # note: this must happen before project() include(pico_sdk_import.cmake) project(my_project) # initialize the Raspberry Pi Pico SDK pico_sdk_init() # rest of your project
Or by cloning the SDK locally, but without copying pico_sdk_import.cmake:
git clone this Raspberry Pi Pico SDK repository
Setup a CMakeLists.txt like:
cmake_minimum_required(VERSION 3.13) # initialize the SDK directly include(/path/to/pico-sdk/pico_sdk_init.cmake) project(my_project) # initialize the Raspberry Pi Pico SDK pico_sdk_init() # rest of your project
Write your code (see pico-examples or the Raspberry Pi Pico-Series C/C++ SDK documentation for more information)
About the simplest you can do is a single source file (e.g. hello_world.c)
#include <stdio.h> #include "pico/stdlib.h" int main() { stdio_init_all(); printf("Hello, world!\n"); return 0; }
And add the following to your CMakeLists.txt:
add_executable(hello_world hello_world.c ) # Add pico_stdlib library which aggregates commonly used features target_link_libraries(hello_world pico_stdlib) # create map/bin/hex/uf2 file in addition to ELF. pico_add_extra_outputs(hello_world)
Note this example uses the default UART for stdout; if you want to use the default USB see the hello-usb example.
Setup a CMake build directory. For example, if not using an IDE:
$ cmake -S . -B build
The cmake -S flag indicates the source directory, and the -B flag tells cmake the name of the output-directory to create. This doesn't have to be named “build”, you can call it whatever you want.
When building for a board other than the Raspberry Pi Pico, you should pass -DPICO_BOARD=board_name to the cmake command above, e.g. cmake -S . -B build -DPICO_BOARD=pico2 or cmake -S . -B build -DPICO_BOARD=pico_w to configure the SDK and build options accordingly for that particular board.
Specifying PICO_BOARD=<boardname> sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain cases also enables the use of additional libraries (e.g. wireless support when building for PICO_BOARD=pico_w) which cannot be built without a board which provides the requisite hardware functionality.
For a list of boards defined in the SDK itself, look in this directory which has a header for each named board.
Make your target from the build directory you created.
$ cmake --build build --target hello_world
The directory-name supplied to the
--buildflag needs to match the directory-name that was passed to the-Bflag in the earlier cmake command.
You now have hello_world.elf to load via a debugger, or hello_world.uf2 that can be installed and run on your Raspberry Pi Pico-series device via drag and drop.
See Raspberry Pi Pico-series C/C++ SDK for information on setting up a build environment for RISC-V on RP2350.
The pico-sdk-tools repository contains some prebuilt versions of the RISC-V compiler.
You can use these to get a working RISC-V compiler on Raspberry Pi OS for example.
wget https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz sudo mkdir -p /opt/riscv/riscv-toolchain-14 sudo chown $USER /opt/riscv/riscv-toolchain-14 tar xvf riscv-toolchain-14-aarch64-lin.tar.gz -C /opt/riscv/riscv-toolchain-14
To use the RISC-V compiler to build code you need to set a couple of environment variables and run cmake from fresh.
export PICO_TOOLCHAIN_PATH=/opt/riscv/riscv-toolchain-14/ export PICO_PLATFORM=rp2350-riscv