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 command [ options ]

PARAMETERS

info
    Displays basic information about the attached Pico device, such as serial number and board type.

load file
    Flashes the specified file onto the Pico's flash memory. The file can be a .uf2 file or a raw binary image.

save address length file
    Reads length bytes from the Pico's memory starting at address and saves them to the specified file.

dump address length
    Dumps length bytes from the Pico's memory starting at address to the console.

peek address
    Reads a single word (4 bytes) from the Pico's memory at the specified address and displays its value.

poke address value
    Writes the specified value (a 32-bit word) to the Pico's memory at the specified address.

reset
    Resets the Pico device.

dfu
    Puts the Pico into DFU (Device Firmware Update) mode for flashing.

erase
    Erase whole flash memory.

--version
    Displays the version of picotool.

--help
    Displays help information about picotool.

DESCRIPTION

The picotool utility is a command-line tool designed to interact with Raspberry Pi Pico boards and devices that implement the Raspberry Pi RP2040 microcontroller. It facilitates flashing firmware onto the device, debugging running code, examining memory, and inspecting device information. It allows you to easily upload your compiled programs (.uf2 files or raw binary images) onto the Pico via USB. Furthermore, it can be used to inspect the memory map of the RP2040, read and write memory locations, and even provide basic debugging capabilities by examining register values and setting breakpoints. The command also supports features like switching the Pico into bootloader mode to facilitate flashing and interacting with the built-in flash memory.

CAVEATS

Requires the libusb library to be installed. Proper permissions might be required to access the USB device, potentially requiring running the tool as root or configuring udev rules.

UF2 FORMAT

picotool primarily works with UF2 (USB Flashing Format) files. UF2 files are a simple container format that includes the binary data to be flashed, along with metadata like the target address in memory.

Understanding how to create UF2 files (often done by build systems like CMake with appropriate Pico SDK configuration) is crucial for using picotool load effectively.

BOOTLOADER MODE

The Pico enters bootloader mode when the BOOTSEL button is held down during power-up or reset. picotool dfu forces the device to reset into DFU mode. In this mode, the Pico presents itself as a USB mass storage device, allowing you to drag and drop .uf2 files directly onto it, or use picotool load.

HISTORY

The picotool utility was developed by Raspberry Pi to provide a dedicated tool for interacting with their RP2040 based Pico microcontroller. It aimed to simplify the process of flashing, debugging, and inspecting the device's memory, offering a user-friendly command-line interface tailored to the Pico's specific hardware. Its development coincided with the release of the Raspberry Pi Pico and has been continuously updated to support new features and improve usability.

SEE ALSO

dfu-util(1)

Copied to clipboard