LinuxCommandLibrary

picotool

Program and debug Raspberry Pi Pico

TLDR

Display information about the currently loaded program on a Pico

$ picotool info
copy

Load a binary onto a Pico
$ picotool load [path/to/binary]
copy

Convert an ELF or BIN file to UF2
$ picotool uf2 convert [path/to/elf_or_bin] [path/to/output]
copy

Reboot a Pico
$ picotool reboot
copy

List all known registers
$ picotool otp list
copy

Display version
$ picotool version
copy

Display help
$ picotool help
copy

SYNOPSIS

picotool [options] [file.uf2]
picotool --flash <file.uf2> [options]
picotool --reboot
picotool --info

PARAMETERS

-f, --flash
    Flash the specified UF2 file to the connected RP2040 device.

-r, --reboot
    Reboot the connected RP2040 device into its normal application mode.

-b, --boot
    Reboot the connected RP2040 device into BOOTSEL mode.

-u, --usb
    Specify the USB device path for interaction (e.g., /dev/sdb).

-m, --memory
    Show detailed memory usage information of the device.

-i, --info
    Display detailed information about the connected RP2040 device.

-l, --list
    List all currently connected RP2040 devices in BOOTSEL mode.

-v, --verbose
    Enable verbose output, providing more detailed logs for operations.

--size
    Show the size of the given UF2 file without flashing it.

--verify
    Verify the flash operation after writing the UF2 file.

--address
    Specify a flash address for read or write operations.

--offset
    Specify an offset for flash operations, often used with --address.

--dump
    Dump the contents of the device's flash memory to the specified file.

--clear-bootsel-pin
    Clear the BOOTSEL pin state, typically for persistent bootloader bypass.

--set-bootsel-pin
    Set the BOOTSEL pin state, forcing the device into BOOTSEL on reboot.

DESCRIPTION

picotool is a command-line utility designed by Raspberry Pi to interact with RP2040 microcontrollers, particularly the Raspberry Pi Pico, when they are in BOOTSEL mode.
This mode presents the device as a USB Mass Storage device, allowing picotool to easily flash new firmware (in UF2 format), query device information, reboot the microcontroller, and perform memory inspections.
It's an essential tool for developers working with RP2040-based boards, providing a convenient way to program and debug without needing complex debugging hardware. It streamlines the firmware deployment process, especially for rapid iteration during development.

CAVEATS

picotool requires the target RP2040 device to be in BOOTSEL mode, which means it appears as a USB Mass Storage device. Ensure the device is connected and in this mode before running commands.
Depending on your system's udev rules and user permissions, you might need to run picotool with sudo for it to detect and interact with the device correctly. It primarily interacts with the device's bootloader, not the running application.

TYPICAL USAGE WORKFLOW

A common workflow involves compiling your RP2040 firmware into a UF2 file.
Then, hold the BOOTSEL button on your Pico while plugging it into USB to enter BOOTSEL mode. The device will appear as a USB drive.
You can then use picotool --flash your_firmware.uf2 --reboot to quickly flash and run your new code. This rapid iteration is crucial for embedded development.

HISTORY

picotool was developed by the Raspberry Pi Foundation as an integral part of the Raspberry Pi Pico SDK. It was released alongside the Raspberry Pi Pico and the RP2040 microcontroller in January 2021, providing a dedicated and user-friendly tool for flashing and interacting with the new chip's unique BOOTSEL mode.
Its development aimed to simplify the firmware update process for developers and users of the RP2040, making rapid prototyping and deployment more accessible.

SEE ALSO

lsblk(8), dfu-util(1), mount(8)

Copied to clipboard