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

Layout file

A layout file (TOML) describes the flash of one board: its size and its named partitions. The nanoflash command, the build feature and the browser package read the same file. Unknown keys are refused.

# layouts/esp32-s3-8mb.toml
[flash]
size = "8 MiB"
alignment = "4 KiB"          # default alignment of every partition
base-address = 0x0           # where flash is mapped, for the linker writer

[[partition]]
name = "bootloader"
role = "bootloader"
offset = 0x0
size = "32 KiB"

[[partition]]
name = "partition-table"
role = "partition-table"
offset = 0x8000
size = "4 KiB"

[[partition]]
name = "nvs"
role = "custom"
size = "24 KiB"
espressif = { type = "data", subtype = "nvs" }   # per-family attributes

[[partition]]
name = "application"
role = "firmware"
size = "3 MiB"
alignment = "64 KiB"

[[partition]]
name = "storage"
role = "storage"
filesystem = "littlefs"       # informative; drives the Espressif subtype
size = "remaining"            # shares what is left with the other growing partitions

Sizes and offsets

Sizes and offsets are integers (4096), hexadecimal integers or text (0x1000, "0x1000"), or text with a binary unit: B, KiB, MiB, GiB ("4 KiB", "8 MiB", "512 B").

[flash]

KeyRequiredValue
sizeyesThe flash size, or "detect": the size is read from the chip when flashing.
minimumwith size = "detect"A fixed size with a minimum is refused. The smallest flash that the layout supports. Offline tools (layout check, layout write, build, image build without --flash-size) resolve the layout for it.
alignmentnoThe default alignment of every partition. Default 4 KiB (0x1000).
base-addressnoThe address at which the flash is mapped, for the linker writer and for the addresses of Intel HEX and ELF images. Default 0x0.

[[partition]]

Partitions are listed in file order.

KeyRequiredValue
nameyesA name, unique in the layout. Images and erase entries of a manifest name it.
roleyesbootloader, partition-table, firmware, update, storage, crash-record or custom.
slotfor updateThe update slot number n.
offsetnoA fixed offset. Without it, the partition goes at the first offset after the previous partition that satisfies its alignment.
sizeyesA size, "remaining", or a table { minimum, grow, maximum }. See Growing sizes.
alignmentnoThe alignment of this partition. Default: the alignment of [flash].
filesystemnoInformative. On Espressif, fat, spiffs and littlefs select the subtype of a storage partition.
espressifnoAttributes of the Espressif partition table.
mbrnoAttributes of the MBR.
linkernoAttributes of the linker writer.

Roles

RoleMeaning
bootloaderThe bootloader.
partition-tableWhere the table writer puts its table. flash writes the generated table there unless a manifest image targets it.
firmwareThe application. nanoflash run writes its image to the one firmware partition.
updateAn update slot, with slot = <n>.
storageData, such as a file system.
crash-recordA crash record, such as a core dump.
customAnything else. On Espressif it needs explicit espressif attributes.

Per-family attributes

Per-family attributes live in a table named after the family. They override what the role implies.

TableKeys
espressiftype and subtype, by name (such as "data", "nvs", "phy", "ota", "coredump", "factory") or by number; encrypted and readonly, booleans.
mbrtype, the partition type byte; bootable, a boolean.
linkerregion, the name of the memory region.

The Espressif writer maps the roles like this: firmware to app/factory, update slot n to app/ota_n, storage to data with a subtype from filesystem, crash-record to data/coredump. Update slots require an otadata partition (espressif = { type = "data", subtype = "ota" }).

Growing sizes

A partition size is one of:

  • a size, such as "1 MiB";
  • "remaining", which is { minimum = 0, grow = 1 };
  • a table { minimum = "1 MiB", grow = 3, maximum = "8 MiB" }: at least minimum, plus a share of the free space weighted by grow (a whole number from 1, default 1), up to maximum (optional).
[flash]
size = "detect"                # read from the chip when flashing
minimum = "4 MiB"              # what offline tools resolve against

# in a partition: at least 1 MiB, three shares of the free space, at most 8 MiB
size = { minimum = "1 MiB", grow = 3, maximum = "8 MiB" }

Partitions that grow share the free space by weight, in steps that keep the partitions after them aligned. In a detect layout, fixed offsets must ascend in file order, and firmware and update partitions cannot grow. Growable partitions gives the rules and every error.

Table writers

nanoflash layout write --format <format> and writeLayout in the browser write:

FormatOutputNotes
espressifThe binary Espressif partition table, placed at the partition-table partition.Checked against esp-idf-part and gen_esp32part.py.
mbrA 512-byte master boot record.For SD cards and disk images. Sector size 512. Partition types come from the attributes or the role. Checked against mbrman and sfdisk.
linkerThe MEMORY regions of the layout (text).For families with no table on the flash, such as an nRF52840 behind a bootloader whose application starts at a fixed address.
constantsRust constants (text).The same constants as the build feature.

The linker regions and constants of a detect layout are written for its minimum flash. See Build and cargo features.