Format:RP2040 boot2
| On this wiki | Facts · Code · Notes · Topics |
|---|
The 256-byte second-stage bootloader at the start of an RP2040 flash image: the boot ROM copies it to SRAM, checks a CRC32 in its last 4 bytes, and runs it to configure XIP flash before jumping to the application vector table.
Overview
An RP2040 program in external flash (XIP base 0x10000000) begins with a 256-byte boot2 block, followed by the application's vector table at offset 0x100. The boot ROM loads these 256 bytes from flash to the top 256 bytes of SRAM, verifies the checksum, and jumps in; boot2 sets up the flash chip for execute-in-place and then enters the application. The pico-sdk ships several variants per flash chip (boot2_w25q080, boot2_generic_03h, boot2_is25lp080, boot2_at25sf128a, boot2_w25x10cl, boot2_usb_blinky) and a compile-time chooser.
Layout
Bytes 0-251: Thumb code (linker script places it at 0x20041f00 with length 252); bytes 252-255: little-endian CRC32 of the first 252 bytes. pad_checksum pads the compiled binary with zeros to 252 bytes and appends the checksum.
Checksum
The pico-sdk script computes it as a bit-reversed variant of CRC-32: reverse the bits of each input byte, run zlib crc32 with initial value (seed ^ 0xFFFFFFFF) (seed default 0), XOR the result with 0xFFFFFFFF, then reverse the 32 bits of the result. This is the same as the MPEG-2 style CRC-32 (polynomial 0x04C11DB7, init 0xFFFFFFFF, no reflection, no final xor): Unverified, derived by reasoning not by test. The script comment calls the bootrom CRC awkward but kept.
Identification
The first 256 bytes of a flash dump of an RP2040 board; the last four bytes are the checksum. On RP2350 boot2 is a different mechanism: see Format:RP2350 picobin block. The pico-sdk also has an rp2350 boot_stage2 directory (Unverified: its role was not read).
Platform
See Platform:ARM Cortex-M for the vector table that follows.
Code & repositories
- https://github.com/raspberrypi/pico-sdk @
079c6f39023649b154152db30f1d781e884879bc· license: BSD-3-Clause
pico-sdk: src/rp2040/boot_stage2 (pad_checksum, boot_stage2.ld) and src/common/boot_picobin_headers picobin.h.
Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-10-18