Introduction
UF2 is a firmware format made by Microsoft for its
MakeCode editor, for flashing microcontrollers
without special software. A board’s bootloader appears on the computer as a USB drive;
copying a .uf2 file onto it writes the firmware into flash, and the board
restarts. The Raspberry Pi Pico, many Adafruit boards and other hobby boards work this
way, and projects such as MicroPython and CircuitPython publish their firmware as UF2.
Structure
A UF2 file is a series of 512-byte blocks, each complete in itself. Every block carries its own target address, so the bootloader can write each one as it arrives, in any order, and ignore anything else the operating system writes to the drive. Each block starts with two magic numbers and ends with a third, all 32-bit little-endian, and holds up to 476 bytes of data, usually 256.
A flag can mark that the word at offset 28 is a family ID rather than the file size, which names the kind of chip the firmware is for, so a board can reject firmware meant for another. Every field and flag, the file-container, MD5 and extension-tag extensions and how bootloaders treat blocks are on blocks and flags; every registered family is on family IDs.
0magic0x0A324655(UF2\n), then0x9E5D51578 bytes8flags4 bytes12target address in flash4 bytes16payload size, usually 2564 bytes20block number and total blocks8 bytes28file size or family ID4 bytes32data, padded with zeros476 bytes508final magic0x0AB16F304 bytes
Not described
The blocks, the family IDs and how the blocks make a flash image are written. What remains:
- Viewer: the explorer opens
.uf2files: every field of every block, the magic numbers, the block numbers (counted within each family), sizes, flags, extension tags, MD5 regions and contained files; the families, the image assembled by target address with its gaps, overlaps and out-of-order blocks; and the code, as Cortex-M Thumb (the vector table shown as a table) or RISC-V, as the family says. The processor of a family comes from a table of the chips’ cores in which every entry cites a vendor source (a family without one is Unknown), not from the file, so a choice in the options bar can override it, and so can the architecture, the position of the vector table and the start address. The ESP families are read as flash images: the viewer finds the ESP images and the partition table in them (header, segments with their load addresses and memory windows, entry point, checksum, SHA-256, application description) and disassembles the IRAM and IROM segments at their load addresses, with our Xtensa decoder (ESP32, S2, S3, ESP8266) or our RISC-V decoder (the others), see the images page. For Cortex-M families the vector table at the start of the image names the stack pointer and each handler, with the memory window each points into. Code and data: the code is followed from the reset handler and the vector table handlers (Cortex-M, with the RP2040’s second stage), the ESP image entry point, the ARM exception vectors and the AVR interrupt vectors, and what the walk does not reach is shown as data (literal pools, jump tables, strings, other data) in the Data in the image table; the option Code and data can show every byte as an instruction instead. In a chip with one SRAM window for code and data a data segment is no longer decoded as code. How it is checked, and its limits (a function reached only through a pointer the walk does not look at, code never called, code copied to RAM at start-up, the 32 MB limit), are on the images page. Still not done: the RP2350 IMAGE_DEF blocks are not named as such (they are data the walk does not reach), the walk knows three ways of copying code to RAM at start-up (Nordic’scopy_region, Zephyr’sz_early_memcpyand the CMSIS copy table, see the images page) but not an inline copy loop, so code copied by such a start-up is shown as data at its flash address, and the registers inside a peripheral are named only for the families with a register map (see the memory-map item below). The viewer was run in a browser by an independent re-check on 19 November 2026 (before the ESP image reading, the memory maps, the lazy image, the code walk and the register names were added); those additions have been run through the viewer’s code in Node with real files, but not yet in a browser. - Viewer: the tables of extension tags and contained files and the code of every segment are shown in full (earlier versions stopped at 200 rows, 500 rows and 16 segments; those limits are gone, and a test with 250 tags and segments and 600 files covers it). A very large file simply gives long tables. The CRC of the RP2040 second stage and the RP2350 IMAGE_DEF blocks are chip boot details, not part of the UF2 format, and the viewer does not check or name them.
- Viewer: three defects found by the second re-check are fixed. A gap between two runs of main-flash blocks is information, not a problem: the README calls each block self-contained and independent and never requires contiguous addresses (the Presto firmware with a file system has a gap of 831,488 bytes on purpose). A block with a damaged magic number is reported once; it is not checked for number or total, and it still counts as a block of the family its own flags and family ID name (when those are plausible, else of the block before it), so its neighbours are not reported as wrong. Damaged extension tags and a container block without a name now appear among the file’s problems. That counting of a damaged block is our reading (the README only says the number and total “make it easy for the bootloader to detect that all blocks have been transferred”); see the numbering item below. If the damage also ruins the flags and family ID of the first block of a family, the damaged block counts toward the wrong family.
- Viewer: the MD5 of an MD5 region is checked against our own MD5 of the image bytes of that region, shown on the
block’s MD5 node (match, mismatch, or region not wholly in the file). A mismatch is not called an error: the README says a flasher
compares the value with the device’s flash, not with the file. Our MD5 is checked against Node’s crypto and the RFC 1321 test strings. Files as esptool writes them: a writer
that follows esptool’s
uf2_writer.py(read for the format only, the raw copy is in the samples folder; our port isscripts/uf2/esp-uf2-writer.mjs) made UF2 files from a real ESP32-S3 application (bootloader, partition table, application) and from the real MicroPython ESP32-C3 image, and every one of their blocks has an MD5 region that matches the image bytes. Two things that esptool does were found and are handled: for a block shorter than 452 bytes (the last block of each input file, or every block with a small--chunk-size) esptool puts the 24-byte region right after the payload, not in the last 24 bytes of the data area as the README says, and the viewer reads it there when the README’s place is empty (and says so on the node); and esptool numbers the blocks from 0 again for each input file it is given, so a file of several files (bootloader, table, application) is reported as having block numbers out of sequence, as the README requires. Still not done: no published firmware file with the MD5 flag was found. Real ESP UF2 files tested: Adafruit’s TinyUF2 for the ESP32-S2 (three files), MicroPython for the ESP32-S3, and CircuitPython 10.0.3, 9.2.9 and 9.2.8 for the ESP32-S3 (adafruit_qtpy_esp32s3_nopsram): none sets the MD5 flag (CircuitPython and MicroPython use their own tools, not esptool’s writer). ESP-IDF’smkuf2.pyhands the work to esptool (merge-bin --format uf2, with--md5-disableto leave the checksums out), so such files exist for those who build them; the esptool program itself is not on this machine, so the files above are made by our port of its writer, and the port was not compared byte for byte with esptool’s own output. - Viewer: the table of which core each family contains (it picks the default processor and fills the Core column)
cites a public source for every entry: 77 of the 80 families, from datasheets (Raspberry Pi, Espressif, GigaDevice,
Bouffalo, LISTENAI, NXP, Cypress), vendor-published headers and SDK files (ST, Nordic, Renesas, Realtek, Beken, XRadio, Artery, Puya,
Analog Devices, WCH, ESP-IDF), vendor SVD files (NXP) and vendor pack descriptions (Microchip); the list, with what each source says,
is on the images page. The three families left name no chip: the two RP2XXX
download layouts and the Adaboot bootloader; their Core column says Unknown, no processor is chosen, and the code is shown as
bytes only until one is picked in the Processor dropdown (so does a private family ID). Still not done:
some rows rest on weaker sources than a datasheet and say so on the images page (the Realtek Ameba cores come from SDK header macros, the
Bouffalo RISC-V extension strings from the SDK’s toolchain table, the ESP32-H4 and H21 from ESP-IDF build files, the GD32VF103 from the vendor library’s build flags, the BL618’s RV32IMAFCP from the reference manual with the P extension left undecoded, the CSK4 from the
CSK4002 brief only, the CH32V from the QingKeV4 Processor Manual (V4B and V4C RV32IMAC, V4F RV32IMACF, the XW extension left undecoded), the CH32V4X7 gives no extension string, and the CSK6’s core is the device tree’s
arm,cortex-m33where its datasheet says “ARM STAR”); the Cypress FX2 (an enhanced 8051) is decoded by the 8051 decoder (the standard MCS-51 instruction set; the FX2’s own special function registers and the cycle counts are not covered). The three Beken parts (ARM968E-S) and the RZ/A1LU (Cortex-A9) are decoded as ARM state, the ATmega32 as AVR, and the CSK6 as Armv8-M. A Cortex-A9’s Thumb-2 code is not switched to by the default. What a source says is the core; the ARM architecture level and the RISC-V profile used by the decoder are decoder settings that follow from it. Earlier entries that were wrong or unsupported changed: the ESP32-C2 is RV32IMAC, not RV32IMC (Espressif’s ESP8684 datasheet), and the RP2350’s Hazard3 profile does not include Zcmt, which the RP2350 datasheet does not list. - Viewer: the memory maps of the families (flash, RAM and peripheral windows, from vendor files) name the target
address range of the file, the places the vector table points to and the operands of the disassembly; they are on the
images page and checked entry by entry against the saved vendor files.
Added in the last round: the flash and RAM windows of the LPC55, MIMXRT10XX (the regions of NXP’s SDK linker scripts) and RA4M1, the peripherals of the ESP32-P4, H21, H4 and S31,
the nRF52 maps per chip (sizes from nrfx’s linker scripts, peripherals from each chip’s SVD), maps for the GD32F350, AT32F415, PY32F071, XR809, RTL8720C, the four
Analog Devices chips and the ATmega32, the names of the interrupts in the vector table (17 STM32 families, nRF52, SAMD21, SAMD51, LPC55, MIMXRT1052, RP2040, RP2350) and the names of
the registers inside the peripherals for the RP2040 and the STM32F4 (see the images page).
Added in round 9: the register names for every family whose SVD file is saved (37 register maps with the RP2040 and STM32F4 of the round before, each compared register by register with its SVD file by a test: the STM32 F0, F1, F2, F3, F4, F7, G0, G4,
H5, H7, L0, L1, L4, L5, WB and WL, SAMD21, SAMD51, SAML21, the nRF52 (832, 833, 840, 820), RA4M1, LPC55, MIMXRT1052, RP2040, RP2350 and the ESP32, S2, S3, C2, C3, C6, H2 and P4), and the interrupt names of the RA4M1
(IEL0 to IEL31, which the program assigns to peripheral events) and the SAML21.
Added in round 10: register maps for the GD32VF103 (cmsis-svd-data mirror of GigaDevice’s SVD), the AT32F415 (Artery’s SVD in the same mirror) and the Analog Devices MAX32690, MAX32650, MAX32665 and MAX78002 (the SVD files of the MSDK), each compared with its SVD file by the same test.
The ESP32-C5, C61, H21, H4 and S31 have register maps too, made from the ESP-IDF register headers (Espressif publishes no SVD file for them).
Added in round 11: register maps for the ESP8266 (made by hand from the register macros of Espressif’s ESP8266_RTOS_SDK headers: UART, SPI, GPIO, timers, RTC, watchdog, I2S, SLC, eFuse and the DPORT registers the SDK names; other registers are not named) and for the CH32V family (taken from WCH’s CH32V307 SVD file, so peripherals that a CH32V2xx part lacks still show their name, and the CH32V4X7 window list has no register names); the SET, XOR and CLEAR aliases of the RP2350’s peripherals are now recognised, as for the RP2040.
Added in round 12: register maps for the Bouffalo BL602, BL702 and BL616/BL618 (made from the headers of the Bouffalo SDK: the system peripherals GLB, EF_DATA, EF_CTRL, L1C, SF_CTRL, PDS, HBN, AON, TZC and the others whose register header the SDK keeps in its
hardwarefolder; in round 13 the UART, SPI, I2C, DMA, timer and PWM were added by hand: for the BL602 and BL702 from each chip’s own register headers in the older Bouffalo IoT SDK (the BL602 adds IR, GPIP, CCI, SEC_DBG and SEC_ENG; the BL702 adds IR, CKS, CCI, SEC_DBG, SEC_ENG, QDEC, KYS, I2S, CAM, MJPEG, EMAC and USB), and for the BL616/BL618 from the shared driver headers, reading only the branches that the BL616 build uses; in round 14 the BL616/BL618 GPIP (the ADC and DAC registers at 0x20002000), AUADC, AUDAC and USB were added the same way, the ADC, DAC and GPIO registers that live in AON and GLB being there already; the BL702 PDM, which has a register header but no base address in any Bouffalo SDK file that was read (the BL702/704/706 reference manual v1.2, Table 1.2 “Memory Map”, p. 20–21, lists no PDM either; it names the PDM only as a DMA peripheral selector, p. 114), and the DVP_DEBUG and DVP_DUMMY_REG registers of the BL702 camera block are not mapped), the K32 L2 (family 0x7f83e793, which covers two series with different peripheral addresses: the K32L2A and the K32L2B, both mapped from NXP’s SVD files, with interrupt names; the viewer has a K32 L2 series option that is set from which series’ peripheral addresses occur more often in the image, and you can override it), and the CH32V4X7 (the registers of the C structs of WCH’s header at their C offsets, checked against a C compiler). Added in stage 17: register names for the Beken BK7231U, BK7231N and BK7251, from the SDK driver headers, compared address by address with the saved headers by a test; the BK7231N has no PWM or AUDIO map (they share base 0x802B00 and the headers give the PWM only as macros with an argument), and none of the three has USB or UART3 registers named, because the headers give none. Added in stage 18: register names for the Realtek RTL8710B and RTL8720D from the register structs of theirhal_platform.hfiles, compared address by address with the saved headers by a test; the blocks without a struct (system control, Wi-Fi, SDIO device, crypto, USB, CRC, and the RTL8710B GDMA) stay unnamed; the images page lists them. Added in stage 19: register names for the RTL8710A (25 blocks) from the offset defines of the saved rtl8195a-fwlib headers, compared address by address by a test; the blocks those headers do not list stay unnamed and are listed on the images page. Also in stage 19: register names for 17 RZ/A1LU blocks (SCIF, OSTM, WDT, RIIC, RSPI, ADC, RTC) from the struct layouts of the saved iodefine headers, checked by a test; no flash or SDRAM size is added (no readable source). Added in stage 21: the Chip series option of the i.MX RT10xx family also offers the MIMXRT1042, 1051, 1061 and 1064 (the 1064 has its 4 MB flash at 0x70000000; the SDK has no folder for a 1060, 1050 or 1010) and the CH32V core is read as RV32IMAC[F] from the QingKeV4 manual. Added in stage 20: 46 named RZ/A1LU blocks (2999 registers; the CS spaces of 64 MB from the hardware manual R01UH0437, no external memory size is stated by any source) and the Chip series option for the LPC55 and i.MX RT10xx families (memory windows of 9 more LPC55 and 6 more RT10xx chips from their SDK linker scripts; no detection). Added in stage 22: register names for blocks of the Realtek RTL8710B (system control, SDIO device, GDMA0 and GDMA1) and RTL8720D (SDIO device, IPSEC, CRC_S and eight low-power system-control registers), from offset defines in other SDK headers and compared address by address with them by a test; the ESP32-H4 and ESP32-H21 notes now give the core count and 96 MHz clock from Espressif’s product pages (no datasheet is published, so the ISA strings still rest on ESP-IDF). Added in round 15 and stage 16: memory maps for the Realtek RTL8710A, RTL8710B and RTL8720D, the Beken BK7231U, BK7231N and BK7251, the CSK6 and the Renesas RZ/A1LU (45 peripheral blocks and the memory windows of the vendor header; only the RAM window has a size, from the board’s linker script), the PY32F071 register map, and cited core entries for the CSK6 (Cortex-M33 by its device tree), the RZ/A1LU (Cortex-A9 with FPU, from its header) and the BL618 (RV32IMAFCP, from the reference manual), and the GD32VF103 (RV32IMAC, from the vendor library’s build flags). For the three RP2350 family IDs the viewer now lists the metadata blocks (IMAGE_DEF and PARTITION_TABLE blocks: header 0xFFFFDED3, items, a LAST item, a link, footer 0xAB123579) and the block loop they form, read as section 5.1.5 and 5.9 of the RP2350 datasheet describe (a flash image is searched in its first 4 KiB, a RAM image whole). The IMAGE_TYPE, VERSION, VECTOR_TABLE, ENTRY_POINT and ROLLING_WINDOW_DELTA items are decoded; the PARTITION_TABLE fields, the hash and signature items and the load-map entries are named but not decoded. Checked on the datasheet’s two minimum blocks and on the CircuitPython 10.0.3 image for the Pico 2. Still not done: the registers inside a peripheral are not named for the families with no SVD or header, nor for a few ESP peripherals whose headers use a base macro the chip’s headers do not define (the UHCI, the LP I2C and SPI and the memory monitor of some of the five chips); the families with no map at all are listed on the images page with the reason; a window of the older maps runs to the next start because the vendor file gives a base, not a size; the RA4M1 interrupt slots are shown as IEL0 to IEL31 because each program chooses the ICU event behind a slot itself (Renesas’ start-up code copies a table,g_interrupt_event_link_select, written by the project’s build, into the registers IELSR0 to IELSR31), so the chip has no fixed event name per slot; the Nordic nRF52810 and nRF52811 have no family ID in the family list (uf2families.jsonnames the NRF52, NRF52820, NRF52832xxAA, NRF52833 and NRF52840 only), so a file for them carries one of the others; and the LPC55 and MIMXRT10XX windows are the regions of the SDK examples, not the chip’s total memory. - Viewer: a UF2 file of any size the engine allows opens: the block table is a virtual list and the image is read block by block when asked, not built in memory. Measured with a file given as a function (no file): 1,000,000 blocks (a 512 MB file) cost about 230 MB of resident memory (1.2 GB before) and 5,000,000 blocks (2.56 GB) about 460 MB, analysed in 2.8 s; a test covers 300,000 blocks. What the browser and the explorer engine can hold of a file of that size was not tested here.
- Viewer: the block numbers follow the README. It says that in a file container
blockNoandnumBlocks“refer to the entire UF2 file, not the current file” and that the program to run may sit in the main flash beside the files, so container blocks and flash blocks of a one-family file are numbered together, 0 upwards in file order (a file with 2 flash and 2 container blocks numbered 0 to 3 is clean). It also says a block of another family is disregarded “including blockNo and numBlocks”, so with several families each is counted on its own. Our reading, which the README does not say: in a file that holds container blocks and two or more families the README does not say what a container block’s number counts, so those blocks are neither counted in a family nor checked; and a damaged block counts as a block of the family its own flags name. The viewer’s “Numbering rule” row quotes the README and marks only these as our reading. A file that joins a container file and a flash file, each numbered from 0, is reported as wrong, because the README numbers the entire file. - Viewer: each fault is reported once: trailing bytes (a size that is not a multiple of 512) appear on the “Trailing bytes” node only, and a damaged first magic number in block 0 is the one message “A UF2 file starts with the magic numbers”, with the count of blocks with a wrong magic number covering the other blocks.
- Viewer: a family ID that is not in Microsoft’s list is information, not a problem: the README (Family IDs) tells developers whose board family is not listed to pick a new ID at random, so an unlisted ID is legal. The viewer shows a “Family IDs not in the list” row in the file’s fields and “not in the list” in the Families table, and reports no problem. Every count in a message is worded for its number (“1 block has”, “2 blocks have”, “1 byte”), checked by the tests.
- Viewer: the RP2350’s Hazard3 profile has no Zcmt: checked in the RP2350 datasheet (the single PDF, 1,371 pages, read as text): page 227 lists C (Zca), Zba, Zbb, Zbs, Zbkb, Zcb, Zcmp, Zicsr and Zifencei, and the word “zcmt” occurs on no page.
- Viewer: the Processor choice and the other options that follow the file (family, architecture, RISC-V profile, Xtensa chip, FPU, vector table, start address) are Auto by default, so a file whose core is Unknown no longer leaves “None” selected for the next file opened in the same explorer window; a choice you make yourself is still remembered.
- Viewer: the FPU version choice (FPv4-SP, FPv5-SP, FPv5-D16; the unit table) follows the core of the family by default (a Cortex-M4F has FPv4-SP, a Cortex-M33 FPv5-SP), else everything the
architecture level allows. A Cortex-M4F decodes
vfmaand the other fused multiply-accumulates, so the code walk of the nRF52840 CircuitPython image goes through them (171,645 instructions reached, the same number as llvm-mc counts in all 3,250 runs of consecutive instructions; a walk with a unit that has no VFMA, which is how the decoder behaved before, reaches 2,580 fewer).
Links
Software
- Microsoft MakeCode – block and JavaScript editor for microcontrollers that downloads programs as UF2 (web)
- picotool – inspects UF2 files and loads them onto Raspberry Pi boards (Windows, macOS, Linux)
- uf2conv.py – script in Microsoft’s UF2 repository that converts binary and HEX files to UF2 (Windows, macOS, Linux)
Reference
- microsoft/uf2 – the specification, with the list of family IDs