Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Board manifest

A board manifest lists the boards of a project, how to reset them and what to write to them. It is TOML or JSON with the same keys. The command tells them apart by their content. The browser reads JSON only: convert a TOML manifest to JSON with the same keys, with board as an array. Unknown keys are refused.

# boards/esp32-s3.toml
[[board]]
identifier = "esp32-s3-devkitc"            # selected with --board-identifier
name = "ESP32-S3-DevKitC"
protocol = "espressif"
chip = "esp32-s3"
layout = "../layouts/esp32-s3-8mb.toml"   # paths are relative to the manifest
reset = "espressif-usb-serial-jtag"
application-devices = [{ vendor = 0x303a, product = 0x1001 }]

[[board.image]]
partition = "bootloader"                  # or offset = 0x0
path = "../build/bootloader.bin"
sha256 = "d67c656e01756650d77717b0839985a056ec28ffe174601d690fc407a2ceffca"   # optional

[[board.image]]
partition = "application"
path = "../build/application.bin"

[[board.erase]]                           # optional: erased before writing
partition = "nvs"

Top level

KeyRequiredValue
boardyesThe boards, at least one. Each identifier is unique.
prompt-erasenotrue makes the web component offer a checkbox to erase the whole flash. Default false.

[[board]]

KeyRequiredValue
identifieryesThe board, as --board-identifier, boardIdentifier and board-identifier of the Cargo metadata name it.
namenoA name for people.
protocolyesespressif, samba, stk500v1 (alias arduino), stk500v2 (alias wiring) or avr109. The aliases are the names of Arduino’s boards.txt.
chipyesThe chip. See Supported boards.
layoutnoThe layout file, relative to the manifest, or a URL in the browser. Without a layout, images are placed by offset only.
resetnoThe reset sequence. See Reset sequences.
application-devicesnoThe USB identities of the board when it runs its application.
bootloader-devicesnoThe USB identities of the board in its bootloader, when they differ.
imagenoThe images to write.
erasenoThe regions to erase before writing.

A board needs at least one image or one erase entry to flash (nothing-to-flash). A manifest for nanoflash run may list no image: the runner supplies it.

Device filters

application-devices and bootloader-devices are lists of tables:

KeyRequiredValue
vendoryesThe USB vendor identifier, such as 0x2341.
productnoThe USB product identifier. Without it, any product of the vendor matches.
serial-numbernoThe USB serial number. Without it, any device matches. The browser package ignores it: Web Serial does not give the serial number.

The USB identity of the selected port picks the board among the boards of the manifest. The application and bootloader identities also let nanoflash find the board again after a reset that changes its USB identity (a 1200-baud touch). See How nanoflash works.

[[board.image]]

KeyRequiredValue
partitionone of the twoThe partition of the layout that the image goes to.
offsetone of the twoThe flash offset that the image goes to.
pathyesThe image file, relative to the manifest, or a URL in the browser. The command refuses URLs: download the file next to the manifest.
sha256noThe SHA-256 digest of the file, 64 hexadecimal digits. A file with another digest is refused.

Image formats:

  • Binary, written as it is.
  • Intel HEX (.hex, .ihex, by extension), as Arduino, PlatformIO and objcopy write it. It is decoded for every protocol, after the SHA-256 check and the verifier, which see the file as read. The image is the span from the lowest to the highest address, 0xFF in the gaps. Its lowest address is an address of the memory map: it must equal the offset of the image plus the base-address of the flash of the layout (misplaced-intel-hex). .eep files (EEPROM) are refused.
  • ELF, found by its content (the magic 7f 45 4c 46) whatever its name. It is decoded after the SHA-256 check, the verifier and the .eep refusal. The check for ELF content comes before the check for the .hex extension. A file named .elf that is not an ELF file is refused. Reading ELF files needs the elf feature of the library: without it, an ELF image is refused (elf-not-enabled). The command has it. The WebAssembly modules of the browser package do not.
    • For every protocol but Espressif, the image is the PT_LOAD segments that have file data, at their physical address (p_paddr, where .data is stored in the flash), from the lowest to the highest byte with 0xFF in the gaps, as for an Intel HEX image. The bytes that a segment has only in memory (.bss) are not written. The segments must not overlap and must lie in the flash window: from the base-address of the layout for the size of its flash, or without a layout, from 0 for the address limit of the protocol, spanning at most 32 MiB. The lowest address must equal the offset of the image plus the base-address (misplaced-elf). The segments of an AVR file from 0x800000 (the data, EEPROM, fuse and lock spaces of avr-gcc) are not written and are named in an elf-segments-not-written warning. This applies to the three AVR protocols and to any file whose machine is AVR.
    • On the Espressif protocol, the bootloader boots application images, not flat segments. The ELF file is checked, then the image source builds its application image through ImageSource::application_image. The default refuses (application-image). The file may go only to a firmware or update partition, or by offset to a board without layout, or to an offset that starts such a partition (elf-not-an-application). It goes at a multiple of 0x10000 and not below 0x10000 (misaligned-application-image). The check runs again after the layout is resolved for the chip. The image is placed by its partition, not by its addresses: it follows a detect layout like a binary image.
    • The nanoflash command builds the Espressif application image with espflash 4.7. It writes a partition table with one factory application partition, at the offset and with the size of the partition of the layout, to a temporary file in the temporary directory of the system (TMPDIR on Unix, TMP or TEMP on Windows), and removes the file afterward. A panic of espflash on a malformed ELF file becomes an error. The library, the browser package and other programs that use the library refuse, because they provide no application_image.

The partition table is generated from the layout and written with the images, unless an image replaces it.

[[board.erase]]

An erase entry names a partition, or an offset and a size (at least one byte), not both.

[[board.erase]]
partition = "nvs"

[[board.erase]]
offset = 0x9000
size = "24 KiB"

Reset sequences

ValueSequence
espressif-classicDTR and RTS through a UART bridge, as on most ESP32 boards.
espressif-usb-serial-jtagThe USB-Serial-JTAG peripheral of the ESP32-S3, ESP32-C3 and later chips.
touch-1200Open the port at 1200 baud and clear DTR: the sketch restarts into its bootloader, which appears as another USB device. SAM-BA and AVR109 boards.
uf2-touch-1200The same touch, for UF2 bootloaders, which no backend supports yet.
noneNo reset: the board is already in its bootloader.
{ custom = [...] }A list of steps, each { dtr = true, rts = false, wait = "100 ms" }. wait is a number of milliseconds or text such as "100 ms" or "2 s", at most 10 s.

Without reset, the backend chooses the usual sequence of its protocol: touch-1200 on SAM-BA and AVR109, and on Espressif espressif-usb-serial-jtag for the USB identity 303a:1001, else espressif-classic. The STK500 boards (Uno, Nano, Pro Mini, Mega 2560) are reset by a pulse on DTR. A sequence that does not apply to the protocol is refused (unsupported-reset).

Several boards in one manifest

A manifest may list several boards, of one protocol or of several. flash picks the one whose chip matches what the backend detects (as esp-web-tools does with chipFamily), or the one that --board-identifier names. A port that suits no board fails with no-matching-board, and one that suits boards of several protocols fails with several-protocols.

esp-web-tools manifests

An esp-web-tools manifest (JSON with builds[].chipFamily) is detected and converted on load:

  • protocol espressif, chip from chipFamily, one board per build;
  • images from parts, at their offsets, with path relative to the manifest or a URL;
  • no layout (offsets only);
  • the reset from serialType (cdc or uart) or from the detected port;
  • new_install_prompt_erase maps to the erase option of the web component (prompt-erase).

Only the fields that affect flashing are honoured. Improv Wi-Fi provisioning and home_assistant_domain are ignored. ESP8266 builds are refused with a clear error: the ESP8266 is not supported. The fields of the format are listed in Prior art and licences.