{"id":13685076,"url":"https://github.com/raspberrypi/picotool","last_synced_at":"2025-05-14T15:09:32.540Z","repository":{"id":38384378,"uuid":"331380867","full_name":"raspberrypi/picotool","owner":"raspberrypi","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-30T12:41:02.000Z","size":1935,"stargazers_count":714,"open_issues_count":29,"forks_count":133,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-04-30T14:11:00.924Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raspberrypi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-01-20T17:30:44.000Z","updated_at":"2025-04-28T00:18:01.000Z","dependencies_parsed_at":"2024-11-05T19:39:46.913Z","dependency_job_id":"95a58b63-e663-4a5f-a75c-8483dc2ec684","html_url":"https://github.com/raspberrypi/picotool","commit_stats":{"total_commits":114,"total_committers":27,"mean_commits":4.222222222222222,"dds":0.6052631578947368,"last_synced_commit":"df21059f7ca6f1babc7f1f3b92122cacffc85951"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Fpicotool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Fpicotool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Fpicotool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspberrypi%2Fpicotool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raspberrypi","download_url":"https://codeload.github.com/raspberrypi/picotool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254170046,"owners_count":22026219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T14:00:43.385Z","updated_at":"2025-05-14T15:09:32.494Z","avatar_url":"https://github.com/raspberrypi.png","language":"C++","readme":"## Building\n\nYou need to set PICO_SDK_PATH in the environment, or pass it to cmake with `-DPICO_SDK_PATH=/path/to/pico-sdk`. To use features such as signing or hashing, you will need to make sure the mbedtls submodule in the SDK is checked out - this can be done by running this from your SDK directory.\n\n```console\ngit submodule update --init lib/mbedtls\n```\n\nYou also need to install `libusb-1.0`.\n\n### Linux / macOS\n\nUse your favorite package tool to install dependencies. For example, on Ubuntu:\n\n```console\nsudo apt install build-essential pkg-config libusb-1.0-0-dev cmake\n```\n\n\u003e If libusb-1.0-0-dev is not installed, picotool still builds, but it omits all options that deal with managing a pico via USB (load, save, erase, verify, reboot). Builds that do not include USB support can be recognized because these commands also do not appear in the help command. The build output message 'libUSB is not found - no USB support will be built' also appears in the build logs.\n\nThen simply build like a normal CMake project:\n\n```console\nmkdir build\ncd build\ncmake ..\nmake\n```\n\nOn Linux you can add udev rules in order to run picotool without sudo:\n\n```console\nsudo cp udev/99-picotool.rules /etc/udev/rules.d/\n```\n\n### Windows\n\n##### For Windows without MinGW\n\nDownload libUSB from here https://libusb.info/\n\nset LIBUSB_ROOT environment variable to the install directory.\n```console\nmkdir build\ncd build\ncmake -G \"NMake Makefiles\" ..\nnmake\n```\n\n##### For Windows with MinGW in WSL\n\nDownload libUSB from here https://libusb.info/\n\nset LIBUSB_ROOT environment variable to the install directory.\n\n```console\nmkdir build\ncd build\ncmake ..\nmake\n```\n\n##### For Windows with MinGW in MSYS2:\n\nNo need to download libusb separately or set `LIBUSB_ROOT`.\n\n```console\npacman -S $MINGW_PACKAGE_PREFIX-{toolchain,cmake,libusb}\nmkdir build\ncd build\ncmake .. -DCMAKE_INSTALL_PREFIX=$MINGW_PREFIX\ncmake --build .\n```\n\n## Usage by the Raspberry Pi Pico SDK\n\nThe Raspberry Pi Pico SDK ([pico-sdk](https://github.com/raspberrypi/pico-sdk)) version 2.0.0 and above uses `picotool` to do the ELF-to-UF2 conversion previously handled by the `elf2uf2` tool in the SDK. The SDK also uses `picotool` to hash and sign binaries.\n\nWhilst the SDK can download picotool on its own per project, if you have multiple projects or build configurations, it is preferable to install a single copy of `picotool` locally. This can be done most simply with `make install` or `cmake --install .`, using `sudo` if required; the SDK will use this installed version by default.\n\n\u003e On some Linux systems, the `~/.local` prefix may be used for an install without `sudo`; from your build directory simply run\n\u003e ```console\n\u003e cmake -DCMAKE_INSTALL_PREFIX=~/.local ..\n\u003e make install\n\u003e ```\n\u003e This will only work if `~/.local` is included in your `PATH`\n\nAlternatively, you can install to a custom path via:\n\n```console\ncmake -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR -DPICOTOOL_FLAT_INSTALL=1 ..\nmake install\n```\n\nIn order for the SDK to find `picotool` in this custom folder, you will usually need to set the `picotool_DIR` variable in your project. This can be achieved either by setting the `picotool_DIR` environment variable to `$MY_INSTALL_DIR/picotool`, by passing `-Dpicotool_DIR=$MY_INSTALL_DIR/picotool` to your `cmake` command, or by adding `set(picotool_DIR $MY_INSTALL_DIR/picotool)` to your CMakeLists.txt file.\n\n\u003e See the [find_package documentation](https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure) for more details\n\n## Overview\n\n`picotool` is a tool for working with RP2040/RP2350 binaries, and interacting with RP2040/RP2350 devices when they are in BOOTSEL mode. (As of version 1.1 of `picotool` it is also possible to interact with devices that are not in BOOTSEL mode, but are using USB stdio support from the Raspberry Pi Pico SDK by using the `-f` argument of `picotool`).\n\nNote for additional documentation see https://rptl.io/pico-get-started\n\n```text\n$ picotool help\nPICOTOOL:\n    Tool for interacting with RP-series device(s) in BOOTSEL mode, or with an RP-series binary\n\nSYNOPSIS:\n    picotool info [-b] [-m] [-p] [-d] [--debug] [-l] [-a] [device-selection]\n    picotool info [-b] [-m] [-p] [-d] [--debug] [-l] [-a] \u003cfilename\u003e [-t \u003ctype\u003e]\n    picotool config [-s \u003ckey\u003e \u003cvalue\u003e] [-g \u003cgroup\u003e] [device-selection]\n    picotool config [-s \u003ckey\u003e \u003cvalue\u003e] [-g \u003cgroup\u003e] \u003cfilename\u003e [-t \u003ctype\u003e]\n    picotool load [--ignore-partitions] [--family \u003cfamily_id\u003e] [-p \u003cpartition\u003e] [-n] [-N] [-u] [-v] [-x] \u003cfilename\u003e [-t \u003ctype\u003e] [-o \u003coffset\u003e] [device-selection]\n    picotool encrypt [--quiet] [--verbose] [--hash] [--sign] \u003cinfile\u003e [-t \u003ctype\u003e] [-o \u003coffset\u003e] \u003coutfile\u003e [-t \u003ctype\u003e] \u003caes_key\u003e [-t \u003ctype\u003e] [\u003csigning_key\u003e] [-t \u003ctype\u003e]\n    picotool seal [--quiet] [--verbose] [--hash] [--sign] [--clear] \u003cinfile\u003e [-t \u003ctype\u003e] [-o \u003coffset\u003e] \u003coutfile\u003e [-t \u003ctype\u003e] [\u003ckey\u003e] [-t \u003ctype\u003e] [\u003cotp\u003e] [-t \u003ctype\u003e] [--major \u003cmajor\u003e] [--minor \u003cminor\u003e] [--rollback \u003crollback\u003e [\u003crows\u003e..]]\n    picotool link [--quiet] [--verbose] \u003coutfile\u003e [-t \u003ctype\u003e] \u003cinfile1\u003e [-t \u003ctype\u003e] \u003cinfile2\u003e [-t \u003ctype\u003e] [\u003cinfile3\u003e] [-t \u003ctype\u003e] [-p] \u003cpad\u003e\n    picotool save [-p] [-v] [--family \u003cfamily_id\u003e] [device-selection]\n    picotool save -a [-v] [--family \u003cfamily_id\u003e] [device-selection]\n    picotool save -r \u003cfrom\u003e \u003cto\u003e [-v] [--family \u003cfamily_id\u003e] [device-selection]\n    picotool erase [-a] [device-selection]\n    picotool erase -p \u003cpartition\u003e [device-selection]\n    picotool erase -r \u003cfrom\u003e \u003cto\u003e [device-selection]\n    picotool verify [device-selection]\n    picotool reboot [-a] [-u] [-g \u003cpartition\u003e] [-c \u003ccpu\u003e] [device-selection]\n    picotool otp list|get|set|load|dump|permissions|white-label\n    picotool partition info|create\n    picotool uf2 info|convert\n    picotool version [-s] [\u003cversion\u003e]\n    picotool coprodis [--quiet] [--verbose] \u003cinfile\u003e [-t \u003ctype\u003e] \u003coutfile\u003e [-t \u003ctype\u003e]\n    picotool help [\u003ccmd\u003e]\n\nCOMMANDS:\n    info        Display information from the target device(s) or file.\n                Without any arguments, this will display basic information for all connected RP-series devices in BOOTSEL mode\n    config      Display or change program configuration settings from the target device(s) or file.\n    load        Load the program / memory range stored in a file onto the device.\n    encrypt     Encrypt the program.\n    seal        Add final metadata to a binary, optionally including a hash and/or signature.\n    link        Link multiple binaries into one block loop.\n    save        Save the program / memory stored in flash on the device to a file.\n    erase       Erase the program / memory stored in flash on the device.\n    verify      Check that the device contents match those in the file.\n    reboot      Reboot the device\n    otp         Commands related to the RP2350 OTP (One-Time-Programmable) Memory\n    partition   Commands related to RP2350 Partition Tables\n    uf2         Commands related to UF2 creation and status\n    version     Display picotool version\n    coprodis    Post-process coprocessor instructions in disassembly files.\n    help        Show general help or help for a specific command\n\nUse \"picotool help \u003ccmd\u003e\" for more info\n```\n\nNote commands that aren't acting on files require a device in BOOTSEL mode to be connected.\n\n## info\n\nThere is _Binary Information_ support in the SDK which allows for easily storing compact information that `picotool`\ncan find (See Binary Info section below). The info command is for reading this information.\n\nThe information can be either read from one or more connected devices in BOOTSEL mode, or from \na file. This file can be an ELF, a UF2 or a BIN file.\n\n```text\n$ picotool help info\nINFO:\n    Display information from the target device(s) or file.\n    Without any arguments, this will display basic information for all connected RP-series devices in BOOTSEL mode\n\nSYNOPSIS:\n    picotool info [-b] [-m] [-p] [-d] [--debug] [-l] [-a] [device-selection]\n    picotool info [-b] [-m] [-p] [-d] [--debug] [-l] [-a] \u003cfilename\u003e [-t \u003ctype\u003e]\n\nOPTIONS:\n    Information to display\n        -b, --basic\n            Include basic information. This is the default\n        -m, --metadata\n            Include all metadata blocks\n        -p, --pins\n            Include pin information\n        -d, --device\n            Include device information\n        --debug\n            Include device debug information\n        -l, --build\n            Include build attributes\n        -a, --all\n            Include all information\n\nTARGET SELECTION:\n    To target one or more connected RP-series device(s) in BOOTSEL mode (the default)\n        --bus \u003cbus\u003e\n            Filter devices by USB bus number\n        --address \u003caddr\u003e\n            Filter devices by USB device address\n        --vid \u003cvid\u003e\n            Filter by vendor id\n        --pid \u003cpid\u003e\n            Filter by product id\n        --ser \u003cser\u003e\n            Filter by serial number\n        -f, --force\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be rebooted back to application mode\n        -F, --force-no-reboot\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the\n            RPI-RP2 drive mounted\n    To target a file\n        \u003cfilename\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n```\n\nNote the -f arguments vary slightly for Windows vs macOS / Unix platforms.\n\ne.g.\n\n```text\n$ picotool info\nProgram Information\n name:      hello_world\n features:  stdout to UART\n```\n\n```text\n$ picotool info -a\nProgram Information\n name:          hello_world\n features:      stdout to UART\n binary start:  0x10000000\n binary end:    0x1000606c\n\nFixed Pin Information\n 20:  UART1 TX\n 21:  UART1 RX\n\nBuild Information\n build date:        Dec 31 2020\n build attributes:  Debug build\n\nDevice Information\n flash size:   2048K\n ROM version:  2\n```\n\n```text\n$ picotool info -bp\nProgram Information\n name:      hello_world\n features:  stdout to UART\n\nFixed Pin Information\n 20:  UART1 TX\n 21:  UART1 RX\n```\n\n```text\n$ picotool info -a lcd_1602_i2c.uf2\nFile lcd_1602_i2c.uf2:\n\nProgram Information\n name:          lcd_1602_i2c\n web site:      https://github.com/raspberrypi/pico-examples/tree/HEAD/i2c/lcd_1602_i2c\n binary start:  0x10000000\n binary end:    0x10003c1c\n\nFixed Pin Information\n 4:  I2C0 SDA\n 5:  I2C0 SCL\n\nBuild Information\n build date:  Dec 31 2020\n```\n\n## config\n\nConfig allows you to configure the binary info on a device, if it is configurable. Specifically, you can configure `bi_ptr_int32` and `bi_ptr_string`.\n\n```text\n$ picotool help config\nCONFIG:\n    Display or change program configuration settings from the target device(s) or file.\n\nSYNOPSIS:\n    picotool config [-s \u003ckey\u003e \u003cvalue\u003e] [-g \u003cgroup\u003e] [device-selection]\n    picotool config [-s \u003ckey\u003e \u003cvalue\u003e] [-g \u003cgroup\u003e] \u003cfilename\u003e [-t \u003ctype\u003e]\n\nOPTIONS:\n        \u003ckey\u003e\n            Variable name\n        \u003cvalue\u003e\n            New value\n        -g \u003cgroup\u003e\n            Filter by feature group\n\nTARGET SELECTION:\n    To target one or more connected RP-series device(s) in BOOTSEL mode (the default)\n        --bus \u003cbus\u003e\n            Filter devices by USB bus number\n        --address \u003caddr\u003e\n            Filter devices by USB device address\n        --vid \u003cvid\u003e\n            Filter by vendor id\n        --pid \u003cpid\u003e\n            Filter by product id\n        --ser \u003cser\u003e\n            Filter by serial number\n        -f, --force\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be rebooted back to application mode\n        -F, --force-no-reboot\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the\n            RPI-RP2 drive mounted\n    To target a file\n        \u003cfilename\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n```\n\n```text\n$ picotool config\nn = 5\nname = \"Billy\"\nnonconst_pins:\n default_pin = 3\n default_name = \"My First Pin\"\n```\n\n```text\n$ picotool config -g nonconst_pins\nnonconst_pins:\n default_pin = 3\n default_name = \"My First Pin\"\n```\n\n```text\n$ picotool config -s name Jane\nname = \"Billy\"\nsetting name -\u003e \"Jane\"\n\n$ picotool config\nn = 5\nname = \"Jane\"\nnonconst_pins:\n default_pin = 3\n default_name = \"My First Pin\"\n```\n\n## load\n\n`load` allows you to write data from a file onto the device (either writing to flash, or to RAM)\n\n```text\n$ picotool help load\nLOAD:\n    Load the program / memory range stored in a file onto the device.\n\nSYNOPSIS:\n    picotool load [--ignore-partitions] [--family \u003cfamily_id\u003e] [-p \u003cpartition\u003e] [-n] [-N] [-u] [-v] [-x] \u003cfilename\u003e [-t \u003ctype\u003e] [-o\n                \u003coffset\u003e] [device-selection]\n\nOPTIONS:\n    Post load actions\n        --ignore-partitions\n            When writing flash data, ignore the partition table and write to absolute space\n        --family\n            Specify the family ID of the file to load\n        \u003cfamily_id\u003e\n            family ID to use for load\n        -p, --partition\n            Specify the partition to load into\n        \u003cpartition\u003e\n            partition to load into\n        -n, --no-overwrite\n            When writing flash data, do not overwrite an existing program in flash. If picotool cannot determine the size/presence of the\n            program in flash, the command fails\n        -N, --no-overwrite-unsafe\n            When writing flash data, do not overwrite an existing program in flash. If picotool cannot determine the size/presence of the\n            program in flash, the load continues anyway\n        -u, --update\n            Skip writing flash sectors that already contain identical data\n        -v, --verify\n            Verify the data was written correctly\n        -x, --execute\n            Attempt to execute the downloaded file as a program after the load\n    File to load from\n        \u003cfilename\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n    BIN file options\n        -o, --offset\n            Specify the load address for a BIN file\n        \u003coffset\u003e\n            Load offset (memory address; default 0x10000000)\n    Target device selection\n        --bus \u003cbus\u003e\n            Filter devices by USB bus number\n        --address \u003caddr\u003e\n            Filter devices by USB device address\n        --vid \u003cvid\u003e\n            Filter by vendor id\n        --pid \u003cpid\u003e\n            Filter by product id\n        --ser \u003cser\u003e\n            Filter by serial number\n        -f, --force\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be rebooted back to application mode\n        -F, --force-no-reboot\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the\n            RPI-RP2 drive mounted\n```\n\ne.g.\n\n```text\n$ picotool load blink.uf2\nLoading into Flash: [==============================]  100%\n```\n\n## save\n\n`save` allows you to save a range of RAM, the program in flash, or an explicit range of flash from the device to a BIN file or a UF2 file.\n\n```text\n$ picotool help save\nSAVE:\n    Save the program / memory stored in flash on the device to a file.\n\nSYNOPSIS:\n    picotool save [-p] [-v] [--family \u003cfamily_id\u003e] [device-selection]\n    picotool save -a [-v] [--family \u003cfamily_id\u003e] [device-selection]\n    picotool save -r \u003cfrom\u003e \u003cto\u003e [-v] [--family \u003cfamily_id\u003e] [device-selection]\n\nOPTIONS:\n    Selection of data to save\n        -p, --program\n            Save the installed program only. This is the default\n        -a, --all\n            Save all of flash memory\n        -r, --range\n            Save a range of memory. Note that UF2s always store complete 256 byte-aligned blocks of 256 bytes, and the range is expanded\n            accordingly\n        \u003cfrom\u003e\n            The lower address bound in hex\n        \u003cto\u003e\n            The upper address bound in hex\n    Other\n        -v, --verify\n            Verify the data was saved correctly\n        --family\n            Specify the family ID to save the file as\n        \u003cfamily_id\u003e\n            family id to save file as\n    Source device selection\n        --bus \u003cbus\u003e\n            Filter devices by USB bus number\n        --address \u003caddr\u003e\n            Filter devices by USB device address\n        --vid \u003cvid\u003e\n            Filter by vendor id\n        --pid \u003cpid\u003e\n            Filter by product id\n        --ser \u003cser\u003e\n            Filter by serial number\n        -f, --force\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be rebooted back to application mode\n        -F, --force-no-reboot\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the\n            RPI-RP2 drive mounted\n    File to save to\n        \u003cfilename\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n```\n\ne.g. first looking at what is on the device...\n\n```text\n$ picotool info\nProgram Information\nname:      lcd_1602_i2c\nweb site:  https://github.com/raspberrypi/pico-examples/tree/HEAD/i2c/lcd_1602_i2c\n```\n\n... saving it to a file ... \n```text\n$ picotool save spoon.uf2\nSaving file: [==============================]  100%\nWrote 51200 bytes to spoon.uf2\n```\n\n... and looking at the file:\n```text\n$ picotool info spoon.uf2\nFile spoon.uf2:\nProgram Information\nname:      lcd_1602_i2c\nweb site:  https://github.com/raspberrypi/pico-examples/tree/HEAD/i2c/lcd_1602_i2c\n```\n\n## erase\n\n`erase` allows you to erase all of flash, a partition of flash, or an explicit range of flash on the device.\nIt defaults to erasing all of flash.\n\n```text\n$ picotool help erase\nERASE:\n    Erase the program / memory stored in flash on the device.\n\nSYNOPSIS:\n    picotool erase [-a] [device-selection]\n    picotool erase [-p \u003cpartition\u003e] [device-selection]\n    picotool erase -r \u003cfrom\u003e \u003cto\u003e [device-selection]\n\nOPTIONS:\n    Selection of data to erase\n        -a, --all\n            Erase all of flash memory. This is the default\n        -p, --partition\n            Erase a partition\n        \u003cpartition\u003e\n            Partition number to erase\n        -r, --range\n            Erase a range of memory. Note that erases must be 4096 byte-aligned, so the range is expanded accordingly\n        \u003cfrom\u003e\n            The lower address bound in hex\n        \u003cto\u003e\n            The upper address bound in hex\n    Source device selection\n        --bus \u003cbus\u003e\n            Filter devices by USB bus number\n        --address \u003caddr\u003e\n            Filter devices by USB device address\n        --vid \u003cvid\u003e\n            Filter by vendor id\n        --pid \u003cpid\u003e\n            Filter by product id\n        --ser \u003cser\u003e\n            Filter by serial number\n        -f, --force\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be rebooted back to application mode\n        -F, --force-no-reboot\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the\n            RPI-RP2 drive mounted\n```\n\ne.g. first looking at what is on the device...\n\n```text\n$ picotool info\nPartition 0\n Program Information\n  none\n\nPartition 1\n Program Information\n  name:          blink\n  web site:      https://github.com/raspberrypi/pico-examples/tree/HEAD/blink\n  features:      UART stdin / stdout\n  binary start:  0x10000000\n  binary end:    0x1000a934\n  target chip:   RP2350\n  image type:    ARM Secure\n```\n\n... then erase partition 1 ...\n```text\n$ picotool erase -p 1\nErasing partition 1:\n  0007f000-\u003e000fc000\nErasing: [==============================]  100%\nErased 512000 bytes\n```\n\n... and looking at the device again:\n```text\n$ picotool info\nPartition 0\n Program Information\n  none\n\nPartition 1\n Program Information\n  none\n```\n\n## seal\n\n`seal` allows you to sign and/or hash a binary to run on RP2350.\n\nBy default, it will just sign the binary, but this can be configured with the `--hash` and `--no-sign` arguments.\n\nYour signing key must be for the _secp256k1_ curve, in PEM format. You can create a .PEM file with:\n\n```bash\nopenssl ecparam -name secp256k1 -genkey -out private.pem\n```\n\n```text\n$ picotool help seal\nSEAL:\n    Add final metadata to a binary, optionally including a hash and/or signature.\n\nSYNOPSIS:\n    picotool seal [--quiet] [--verbose] [--hash] [--sign] [--clear] \u003cinfile\u003e [-t \u003ctype\u003e] [-o \u003coffset\u003e] \u003coutfile\u003e [-t \u003ctype\u003e] [\u003ckey\u003e] [-t\n                \u003ctype\u003e] [\u003cotp\u003e] [-t \u003ctype\u003e] [--major \u003cmajor\u003e] [--minor \u003cminor\u003e] [--rollback \u003crollback\u003e [\u003crows\u003e..]]\n\nOPTIONS:\n        --quiet\n            Don't print any output\n        --verbose\n            Print verbose output\n        --major \u003cmajor\u003e\n            Add Major Version\n        --minor \u003cminor\u003e\n            Add Minor Version\n        --rollback \u003crollback\u003e [\u003crows\u003e..]\n            Add Rollback Version\n    Configuration\n        --hash\n            Hash the file\n        --sign\n            Sign the file\n        --clear\n            Clear all of SRAM on load\n    File to load from\n        \u003cinfile\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n    BIN file options\n        -o, --offset\n            Specify the load address for a BIN file\n        \u003coffset\u003e\n            Load offset (memory address; default 0x10000000)\n    File to save to\n        \u003coutfile\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n    Key file\n        \u003ckey\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (pem) explicitly, ignoring file extension\n    File to save OTP to (will edit existing file if it exists)\n        \u003cotp\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (json) explicitly, ignoring file extension\n```\n\n## encrypt\n\n`encrypt` allows you to encrypt and sign a binary for use on the RP2350. By default, it will sign the encrypted binary, but that can be configured similarly to `picotool sign`.\n\nThe encrypted binary will have the following structure:\n\n- First metadata block (5 words)\n- IV (4 words)\n- Encrypted Binary\n- Padding to ensure the encrypted length is a multiple of 4 words\n- Signature metadata block\n\nThe AES key must be provided as a .bin file of the 256 bit AES key to be used for encryption.\n\n```text\n$ picotool help encrypt\nENCRYPT:\n    Encrypt the program.\n\nSYNOPSIS:\n    picotool encrypt [--quiet] [--verbose] [--hash] [--sign] \u003cinfile\u003e [-t \u003ctype\u003e] [-o \u003coffset\u003e] \u003coutfile\u003e [-t \u003ctype\u003e] \u003caes_key\u003e [-t \u003ctype\u003e]\n                [\u003csigning_key\u003e] [-t \u003ctype\u003e]\n\nOPTIONS:\n        --quiet\n            Don't print any output\n        --verbose\n            Print verbose output\n    Signing Configuration\n        --hash\n            Hash the encrypted file\n        --sign\n            Sign the encrypted file\n    File to load from\n        \u003cinfile\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n    BIN file options\n        -o, --offset\n            Specify the load address for a BIN file\n        \u003coffset\u003e\n            Load offset (memory address; default 0x10000000)\n    File to save to\n        \u003coutfile\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n    AES Key\n        \u003caes_key\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (bin) explicitly, ignoring file extension\n    Signing Key file\n        \u003csigning_key\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (pem) explicitly, ignoring file extension\n```\n\n## partition\n\nThe `partition` commands allow you to interact with the partition tables on RP2350 devices, and also create them.\n\n### info\n\n```text\n$ picotool help partition info\nPARTITION INFO:\n    Print the device's partition table.\n\nSYNOPSIS:\n    picotool partition info -m \u003cfamily_id\u003e [device-selection]\n\nOPTIONS:\n        -m \u003cfamily_id\u003e [device-selection]\n```\n\n```text\n$ picotool partition info\nun-partitioned_space :  S(rw) NSBOOT(rw) NS(rw), uf2 { absolute }\npartitions:\n  0(A)       00002000-\u003e00201000 S(rw) NSBOOT(rw) NS(rw), id=0000000000000000, \"A\", uf2 { rp2350-arm-s, rp2350-riscv }, arm_boot 1, riscv_boot 1\n  1(B w/ 0)  00201000-\u003e00400000 S(rw) NSBOOT(rw) NS(rw), id=0000000000000001, \"B\", uf2 { rp2350-arm-s, rp2350-riscv }, arm_boot 1, riscv_boot 1\n```\n\n```text\n$ picotool partition info -m rp2350-arm-s\nun-partitioned_space :  S(rw) NSBOOT(rw) NS(rw), uf2 { absolute }\npartitions:\n  0(A)       00002000-\u003e00201000 S(rw) NSBOOT(rw) NS(rw), id=0000000000000000, \"A\", uf2 { rp2350-arm-s, rp2350-riscv }, arm_boot 1, riscv_boot 1\n  1(B w/ 0)  00201000-\u003e00400000 S(rw) NSBOOT(rw) NS(rw), id=0000000000000001, \"B\", uf2 { rp2350-arm-s, rp2350-riscv }, arm_boot 1, riscv_boot 1\nFamily ID 'rp2350-arm-s' can be downloaded in partition 0:\n  00002000-\u003e00201000\n```\n\n### create\n\nThis command allows you to create partition tables, and additionally embed them into the block loop of ELF files (for example, for bootloaders).\nBy default, all partition tables are hashed, and you can also sign them. The schema for this JSON file is [here](json/schemas/partition-table-schema.json).\n\n```text\n$ picotool help partition create\nPARTITION CREATE:\n    Create a partition table from json\n\nSYNOPSIS:\n    picotool partition create [--quiet] [--verbose] \u003cinfile\u003e [-t \u003ctype\u003e] \u003coutfile\u003e [-t \u003ctype\u003e] [[-o \u003coffset\u003e] [--family \u003cfamily_id\u003e]]\n                [\u003cbootloader\u003e] [-t \u003ctype\u003e] [[--sign \u003ckeyfile\u003e] [-t \u003ctype\u003e] [--no-hash] [--singleton]] [[--abs-block] [\u003cabs_block_loc\u003e]]\n\nOPTIONS:\n        --quiet\n            Don't print any output\n        --verbose\n            Print verbose output\n    partition table JSON\n        \u003cinfile\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (json) explicitly, ignoring file extension\n    output file\n        \u003coutfile\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n    UF2 output options\n        -o, --offset\n            Specify the load address for UF2 file output\n        \u003coffset\u003e\n            Load offset (memory address; default 0x10000000)\n        --family\n            Specify the family if for UF2 file output\n        \u003cfamily_id\u003e\n            family ID for UF2 (default absolute)\n    embed partition table into bootloader ELF\n        \u003cbootloader\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (elf) explicitly, ignoring file extension\n    Partition Table Options\n        --sign \u003ckeyfile\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (pem) explicitly, ignoring file extension\n        --no-hash\n            Don't hash the partition table\n        --singleton\n            Singleton partition table\n    Errata RP2350-E10 Fix\n        --abs-block\n            Enforce support for an absolute block\n        \u003cabs_block_loc\u003e\n            absolute block location (default to 0x10ffff00)\n```\n\n## uf2\n\nThe `uf2` commands allow for creation of UF2s, and can provide information if a UF2 download has failed.\n\n### convert\n\nThis command replaces the elf2uf2 functionality that was previously in the Raspberry Pi Pico SDK. It will attempt to auto-detect the family ID, but if this fails you can specify one manually with the `--family` argument.\n\n```text\npicotool help uf2 convert\nUF2 CONVERT:\n    Convert ELF/BIN to UF2.\n\nSYNOPSIS:\n    picotool uf2 convert [--quiet] [--verbose] \u003cinfile\u003e [-t \u003ctype\u003e] \u003coutfile\u003e [-t \u003ctype\u003e] [-o \u003coffset\u003e] [--family \u003cfamily_id\u003e]\n                [[--abs-block] [\u003cabs_block_loc\u003e]]\n\nOPTIONS:\n        --quiet\n            Don't print any output\n        --verbose\n            Print verbose output\n    File to load from\n        \u003cinfile\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2 | elf | bin) explicitly, ignoring file extension\n    File to save UF2 to\n        \u003coutfile\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (uf2) explicitly, ignoring file extension\n    Packaging Options\n        -o, --offset\n            Specify the load address\n        \u003coffset\u003e\n            Load offset (memory address; default 0x10000000 for BIN file)\n    UF2 Family options\n        \u003cfamily_id\u003e\n            family ID for UF2\n    Errata RP2350-E10 Fix\n        --abs-block\n            Add an absolute block\n        \u003cabs_block_loc\u003e\n            absolute block location (default to 0x10ffff00)\n```\n\n### info\n\nThis command reads the information on a device about why a UF2 download has failed. It will only give information if the most recent download has failed.\n\n```text\n$ picotool help uf2 info\nUF2 INFO:\n    Print info about UF2 download.\n\nSYNOPSIS:\n    picotool uf2 info [device-selection]\n\nOPTIONS:\n    Target device selection\n        --bus \u003cbus\u003e\n            Filter devices by USB bus number\n        --address \u003caddr\u003e\n            Filter devices by USB device address\n        --vid \u003cvid\u003e\n            Filter by vendor id\n        --pid \u003cpid\u003e\n            Filter by product id\n        --ser \u003cser\u003e\n            Filter by serial number\n        -f, --force\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be rebooted back to application mode\n        -F, --force-no-reboot\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the\n            RPI-RP2 drive mounted\n\n```\n\n## otp\n\nThe `otp` commands are for interacting with the RP2350 OTP Memory. They are not available on  RP2040 devices, as RP2040 has no OTP.\n\nNote that the OTP Memory is One-Time-Programmable, which means that once a bit has been changed from 0 to 1, it cannot be changed back.\nTherefore, caution should be used when using these commands, as they risk bricking your RP2350 device. For example, if you set SECURE_BOOT_ENABLE but don't set a boot key, and disable the PICOBOOT interface, then your device will be unusable.\n\nFor the `list`, `set`, `get` and `load` commands, you can define your own OTP layout in a JSON file and pass that in with the `-i` argument. These rows will be added to the default rows when parsing. The schema for this JSON file is [here](json/schemas/otp-contents-schema.json)\n\n```text\n$ picotool help otp\nOTP:\n    Commands related to the RP2350 OTP (One-Time-Programmable) Memory\n\nSYNOPSIS:\n    picotool otp list [-p] [-n] [-f] [-i \u003cfilename\u003e] [\u003cselector\u003e..]\n    picotool otp get [-c \u003ccopies\u003e] [-r] [-e] [-n] [-i \u003cfilename\u003e] [device-selection] [-z] [\u003cselector\u003e..]\n    picotool otp set [-c \u003ccopies\u003e] [-r] [-e] [-s] [-i \u003cfilename\u003e] [-z] \u003cselector\u003e \u003cvalue\u003e [device-selection]\n    picotool otp load [-r] [-e] [-s \u003crow\u003e] [-i \u003cfilename\u003e] \u003cfilename\u003e [-t \u003ctype\u003e] [device-selection]\n    picotool otp dump [-r] [-e] [device-selection]\n    picotool otp permissions \u003cfilename\u003e [-t \u003ctype\u003e] [--led \u003cpin\u003e] [--hash] [--sign] [\u003ckey\u003e] [-t \u003ctype\u003e] [device-selection]\n    picotool otp white-label -s \u003crow\u003e \u003cfilename\u003e [-t \u003ctype\u003e] [device-selection]\n\nSUB COMMANDS:\n    list          List matching known registers/fields\n    get           Get the value of one or more OTP registers/fields (RP2350 only)\n    set           Set the value of an OTP row/field (RP2350 only)\n    load          Load the row range stored in a file into OTP and verify. Data is 2 bytes/row for ECC, 4 bytes/row for raw. (RP2350 only)\n    dump          Dump entire OTP (RP2350 only)\n    permissions   Set the OTP access permissions (RP2350 only)\n    white-label   Set the white labelling values in OTP (RP2350 only)\n\n```\n\n### set/get\n\nThese commands will set/get specific rows of OTP. By default, they will write/read all redundant rows, but this can be overridden with the `-c` argument\n\n### load\n\nThis command allows loading of a range of OTP rows onto the device. The source can be a binary file, or a JSON file such as the one output by `picotool sign`. The schema for this JSON file is [here](json/schemas/otp-schema.json)\nFor example, if you wish to sign a binary and then test secure boot with it, you can run the following set of commands:\n```text\n$ picotool sign hello_world.elf hello_world.signed.elf private.pem otp.json\n$ picotool load hello_world.signed.elf\n$ picotool otp load otp.json\n$ picotool reboot\n```\n\n### white-label\n\nThis command allows for OTP white-labelling, which sets the USB configuration used by the device in BOOTSEL mode.\nThis can be configured from a JSON file, an example of which is in [sample-wl.json](json/sample-wl.json). The schema for this JSON file is [here](json/schemas/whitelabel-schema.json)\n\n```text\n$ picotool help otp white-label\nOTP WHITE-LABEL:\n    Set the white labelling values in OTP\n\nSYNOPSIS:\n    picotool otp white-label -s \u003crow\u003e \u003cfilename\u003e [-t \u003ctype\u003e] [device-selection]\n\nOPTIONS:\n    File with white labelling values\n        \u003cfilename\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (json) explicitly, ignoring file extension\n    Target device selection\n        --bus \u003cbus\u003e\n            Filter devices by USB bus number\n        --address \u003caddr\u003e\n            Filter devices by USB device address\n        --vid \u003cvid\u003e\n            Filter by vendor id\n        --pid \u003cpid\u003e\n            Filter by product id\n        --ser \u003cser\u003e\n            Filter by serial number\n        -f, --force\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be rebooted back to application mode\n        -F, --force-no-reboot\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the\n            RPI-RP2 drive mounted\n\n```\n\n```text\n$ picotool otp white-label -s 0x100 sample-wl.json \nSetting attributes 20e0\n0x2e8b, 0x000e, 0x0215, 0x0c09, 0x1090, 0x200c, 0x2615, 0x20e0, 0x310b, 0x3706, 0x3a04, 0x3c04, 0x3e21, 0x4f15, 0x5a0a, 0x5f0a, 0x007a, 0x00df, 0x6c34, 0xd83c, 0xdf4c, 0x0020, 0x0054, 0x0065, 0x0073, 0x0074, 0x0027, 0x0073,\n0x0020, 0x0050, 0x0069, 0x0073, 0x6554, 0x7473, 0x5220, 0x3250, 0x3533, 0x3f30, 0x6f6e, 0x6e74, 0x6365, 0x7365, 0x6173, 0x6972, 0x796c, 0x6e61, 0x6d75, 0x6562, 0x0072, 0x6554, 0x7473, 0x6950, 0x4220, 0x6f6f, 0x0074, 0x6554,\n0x7473, 0x6950, 0x794d, 0x6950, 0x3876, 0x3739, 0x7468, 0x7074, 0x3a73, 0x2f2f, 0x7777, 0x2e77, 0x6172, 0x7073, 0x6562, 0x7272, 0x7079, 0x2e69, 0x6f63, 0x2f6d, 0x656e, 0x7377, 0x002f, 0x6f53, 0x656d, 0x4e20, 0x7765, 0x2073,\n0x6241, 0x756f, 0x2074, 0x7453, 0x6675, 0x0066, 0x794d, 0x5420, 0x7365, 0x2074, 0x6950, 0x5054, 0x2d49, 0x5052, 0x3332, 0x3035,\n$ picotool reboot -u\n$ lsusb -v -s 1:102\nBus 001 Device 102: ID 2e8b:000e zß水🍌 Test's Pis Test RP2350?\nDevice Descriptor:\n  bLength                18\n  bDescriptorType         1\n  bcdUSB               2.10\n  bDeviceClass            0 \n  bDeviceSubClass         0 \n  bDeviceProtocol         0 \n  bMaxPacketSize0        64\n  idVendor           0x2e8b \n  idProduct          0x000e \n  bcdDevice            2.15\n  iManufacturer           1 zß水🍌 Test's Pis\n  iProduct                2 Test RP2350?\n  iSerial                 3 notnecessarilyanumber\n  bNumConfigurations      1\n  Configuration Descriptor:\n    bLength                 9\n    bDescriptorType         2\n    wTotalLength       0x0037\n    bNumInterfaces          2\n    bConfigurationValue     1\n    iConfiguration          0 \n    bmAttributes         0xc0\n      Self Powered\n    MaxPower               64mA\n...\n```\n\n### permissions\n\nThis command will run a binary on your device in order to set the OTP permissions, as these are not directly accessible from `picotool` on due to the default permissions settings required to fix  errata XXX on RP2350. \nBecause it runs a binary, the binary needs to be sign it if secure boot is enabled. The binary will print what it is doing over uart, which\ncan be configured using the UART Configuration arguments. You can define your OTP permissions in a json file, an example of which\nis in [sample-permissions.json](json/sample-permissions.json). The schema for this JSON file is [here](json/schemas/permissions-schema.json)\n\n```text\n$ picotool help otp permissions\nOTP PERMISSIONS:\n    Set the OTP access permissions\n\nSYNOPSIS:\n    picotool otp permissions \u003cfilename\u003e [-t \u003ctype\u003e] [--led \u003cpin\u003e] [--hash] [--sign] [\u003ckey\u003e] [-t \u003ctype\u003e] [device-selection]\n\nOPTIONS:\n    File to load permissions from\n        \u003cfilename\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (json) explicitly, ignoring file extension\n        --led \u003cpin\u003e\n            LED Pin to flash; default 25\n    Signing Configuration\n        --hash\n            Hash the executable\n        --sign\n            Sign the executable\n    Key file\n        \u003ckey\u003e\n            The file name\n        -t \u003ctype\u003e\n            Specify file type (pem) explicitly, ignoring file extension\n    Target device selection\n        --bus \u003cbus\u003e\n            Filter devices by USB bus number\n        --address \u003caddr\u003e\n            Filter devices by USB device address\n        --vid \u003cvid\u003e\n            Filter by vendor id\n        --pid \u003cpid\u003e\n            Filter by product id\n        --ser \u003cser\u003e\n            Filter by serial number\n        -f, --force\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be rebooted back to application mode\n        -F, --force-no-reboot\n            Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the\n            command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the\n            RPI-RP2 drive mounted\n```\n\n```text\n$ picotool otp permissions --sign private.pem --tx 46 sample-permissions.json \nPicking file ./xip_ram_perms.elf\npage10\npage10 = 0\nsetting page10 -\u003e 4063233\npage11\npage11 = 0\nsetting page11 -\u003e 4128781\npage12\npage12 = 0\nsetting page12 -\u003e 4128781\ntx_pin = 0\nsetting tx_pin -\u003e 46\nLoading into XIP RAM: [==============================]  100%\n\u003e\u003e\u003e using flash update boot of 13ffc000\n\nThe device was rebooted to start the application.\n```\n\n## Binary Information\n\nBinary information is machine locatable and generally machine consumable. I say generally because anyone can\ninclude any information, and we can tell it from ours, but it is up to them whether they make their data self describing.\n\nNote that we will certainly add more binary info over time, but I'd like to get a minimum core set included\nin most binaries from launch!!\n\n### Basic Information\n\nThis information is really handy when you pick up a Pico and don't know what is on it!\n\nBasic information includes\n\n- program name\n- program description\n- program version string\n- program build date\n- program url\n- program end address\n- program features - this is a list built from individual strings in the binary, that can be displayed (e.g. we will have one for UART stdio and one for USB stdio) in the SDK\n- build attributes - this is a similar list of strings, for things pertaining to the binary itself (e.g. Debug Build)\n\nThe binary information is self-describing/extensible, so programs can include information picotool is not aware of (e.g. MicroPython includes a list of in-built libraries)\n\n### Pins\n\nThis is certainly handy when you have an executable called 'hello_world.elf' but you forgot what board it is built for...\n\nStatic (fixed) pin assignments can be recorded in the binary in very compact form:\n\n```text\n$ picotool info --pins sprite_demo.elf\nFile sprite_demo.elf:\n\nFixed Pin Information\n0-4:    Red 0-4\n6-10:   Green 0-4\n11-15:  Blue 0-4\n16:     HSync\n17:     VSync\n18:     Display Enable\n19:     Pixel Clock\n20:     UART1 TX\n21:     UART1 RX\n```\n\n### Configuration\n\nThis is very handy if you want to be able to modify parameters in a binary, without having to recompile it.\n\n```text\n$ picotool config -s name Jane\nname = \"Billy\"\nsetting name -\u003e \"Jane\"\n```\n\n### Including Binary information\n\nBinary information is declared in the program by macros (vile warped macros); for the pins example:\n\n```text\n$ picotool info --pins sprite_demo.elf\nFile sprite_demo.elf:\n\nFixed Pin Information\n0-4:    Red 0-4\n6-10:   Green 0-4\n11-15:  Blue 0-4\n16:     HSync\n17:     VSync\n18:     Display Enable\n19:     Pixel Clock\n20:     UART1 TX\n21:     UART1 RX\n```\n\n... there is one line in the `setup_default_uart` function:\n\n```c\nbi_decl_if_func_used(bi_2pins_with_func(PICO_DEFAULT_UART_RX_PIN, PICO_DEFAULT_UART_TX_PIN, GPIO_FUNC_UART));\n```\n\n\nThe two pin numbers, and the function UART are stored, then decoded to their actual function names (UART1 TX etc) by picotool.\nThe `bi_decl_if_func_used` makes sure the binary information is only included if the containing function is called.\n\nEqually, the video code contains a few lines like this:\n\n```c\nbi_decl_if_func_used(bi_pin_mask_with_name(0x1f \u003c\u003c (PICO_SCANVIDEO_COLOR_PIN_BASE + PICO_SCANVIDEO_DPI_PIXEL_RSHIFT), \"Red 0-4\"));\n```\n\nFor the configuration example, you put the line\n\n```c\nbi_decl(bi_ptr_string(0x1111, 0x3333, name, \"Billy\", 128));\n```\n\ninto your code, which will then create the name variable for you to subsequently print.\nThe parameters are the tag, the ID, variable name, default value, and maximum string length.\n\n```c\nprintf(\"Name is %s\\n\", name);\n```\n\n### Details\n\nThings are designed to waste as little space as possible, but you can turn everything off with preprocessor variable `PICO_NO_BINARY_INFO=1`. Additionally,\nany SDK code that inserts binary info can be separately excluded by its own preprocessor variable.\n\nYou need\n```c\n#include \"pico/binary_info.h\"\n```\n\nBasically you either use `bi_decl(bi_blah(...))` for unconditional inclusion of the binary info blah, or\n`bi_decl_if_func_used(bi_blah(...))` for binary information that may be stripped if the enclosing function\nis not included in the binary by the linker (think `--gc-sections`)\n\nThere are a bunch of bi_ macros in the headers\n\n```c\n#define bi_binary_end(end) ...\n#define bi_program_name(name) ...\n#define bi_program_description(description) ...\n#define bi_program_version_string(version_string) ...\n#define bi_program_build_date_string(date_string) ...\n#define bi_program_url(url) ...\n#define bi_program_feature(feature) ...\n#define bi_program_build_attribute(attr) ...\n#define bi_1pin_with_func(p0, func) ...\n#define bi_2pins_with_func(p0, p1, func) ...\n#define bi_3pins_with_func(p0, p1, p2, func) ...\n#define bi_4pins_with_func(p0, p1, p2, p3, func) ...\n#define bi_5pins_with_func(p0, p1, p2, p3, p4, func) ...\n#define bi_pin_range_with_func(plo, phi, func) ...\n#define bi_pin_mask_with_name(pmask, label) ...\n#define bi_pin_mask_with_names(pmask, label) ...\n#define bi_1pin_with_name(p0, name) ...\n#define bi_2pins_with_names(p0, name0, p1, name1) ...\n#define bi_3pins_with_names(p0, name0, p1, name1, p2, name2) ...\n#define bi_4pins_with_names(p0, name0, p1, name1, p2, name2, p3, name3) ... \n```\n\nwhich make use of underlying macros, e.g.\n```c\n#define bi_program_url(url) bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PROGRAM_URL, url)\n```\n\nNOTE: It is easy to forget to enclose these in `bi_decl` etc., so an effort has been made (at the expense of a lot of kittens)\nto make the build fail with a _somewhat_ helpful error message if you do so.\n\nFor example, trying to compile\n\n```c\nbi_1pin_with_name(0, \"Toaster activator\");\n```\n\ngives\n\n```\n/home/graham/dev/mu/pico_sdk/src/common/pico_binary_info/include/pico/binary_info/code.h:17:55: error: '_error_bi_is_missing_enclosing_decl_261' undeclared here (not in a function)\n17 | #define __bi_enclosure_check_lineno_var_name __CONCAT(_error_bi_is_missing_enclosing_decl_,__LINE__)\n|                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n... more macro call stack of doom\n```\n\n## Setting common fields from CMake\n\nYou can use \n\n```cmake\npico_set_program_name(foo \"not foo\") # as \"foo\" would be the default\npico_set_program_description(foo \"this is a foo\")\npico_set_program_version(foo \"0.00001a\")\npico_set_program_url(foo \"www.plinth.com/foo\")\n```\n\nNote all of these are passed as command line arguments to the compilation, so if you plan to use\nquotes, newlines etc you may have better luck defining via bi_decl in the code.\n\n## Additional binary information/picotool features\n\n### Block devices\n\nMicroPython and CircuitPython, eventually the SDK and others may support one or more storage devices in flash. We already\nhave macros to define these although picotool doesn't do anything with them yet... but backup/restore/file copy and even fuse mount\nin the future might be interesting.\n\nI suggest we tag these now... \n\nThis is what I have right now off the top of my head (at the time)\n```c\n#define bi_block_device(_tag, _name, _offset, _size, _extra, _flags)\n```\nwith the data going into\n```c\ntypedef struct __packed _binary_info_block_device {\n        struct _binary_info_core core;\n        bi_ptr_of(const char) name; // optional static name (independent of what is formatted)\n        uint32_t offset;\n        uint32_t size;\n        bi_ptr_of(binary_info_t) extra; // additional info\n        uint16_t flags;\n} binary_info_block_device_t;\n```\nand\n```c\nenum {\n    BINARY_INFO_BLOCK_DEV_FLAG_READ = 1 \u003c\u003c 0, // if not readable, then it is basically hidden, but tools may choose to avoid overwriting it\n    BINARY_INFO_BLOCK_DEV_FLAG_WRITE = 1 \u003c\u003c 1,\n    BINARY_INFO_BLOCK_DEV_FLAG_REFORMAT = 1 \u003c\u003c 2, // may be reformatted..\n\n    BINARY_INFO_BLOCK_DEV_FLAG_PT_UNKNOWN = 0 \u003c\u003c 4, // unknown free to look\n    BINARY_INFO_BLOCK_DEV_FLAG_PT_MBR = 1 \u003c\u003c 4, // expect MBR\n    BINARY_INFO_BLOCK_DEV_FLAG_PT_GPT = 2 \u003c\u003c 4, // expect GPT\n    BINARY_INFO_BLOCK_DEV_FLAG_PT_NONE = 3 \u003c\u003c 4, // no partition table\n};\n```\n\n### Forced Reboots\n\nRunning commands with `-f/F` requires compatible code to be running on the device. The definition of compatible code for the\npurposes of binaries compiled using the [pico-sdk](https://github.com/raspberrypi/pico-sdk) is code that\n- Is still running -\nIf your code has returned then rebooting with `-f/F` will not work - instead you can set the compile definition `PICO_ENTER_USB_BOOT_ON_EXIT`\nto reboot and be accessible to picotool once your code has finished execution, for example with\n`target_compile_definitions(\u003cyourTargetName\u003e PRIVATE PICO_ENTER_USB_BOOT_ON_EXIT=1)`\n- Uses stdio_usb -\nIf your binary calls `stdio_init_all()` and you have `pico_enable_stdio_usb(\u003cyourTargetName\u003e 1)` in your CMakeLists.txt file then you meet\nthis requirement (see the [hello_usb](https://github.com/raspberrypi/pico-examples/tree/master/hello_world/usb) example)\n\n### Issues\n\nIf you ctrl+c out of the middle of a long operation, then libusb seems to get a bit confused, which means we aren't able\nto unlock our lockout of USB MSD writes (we have turned them off so the user doesn't step on their own toes). Simply running\n`picotool info` again will unlock it properly the next time (or you can reboot the device).\n","funding_links":[],"categories":["C++","软件与工具","Software/Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraspberrypi%2Fpicotool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraspberrypi%2Fpicotool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraspberrypi%2Fpicotool/lists"}