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]
| Key | Required | Value |
|---|---|---|
size | yes | The flash size, or "detect": the size is read from the chip when flashing. |
minimum | with 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. |
alignment | no | The default alignment of every partition. Default 4 KiB (0x1000). |
base-address | no | The 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.
| Key | Required | Value |
|---|---|---|
name | yes | A name, unique in the layout. Images and erase entries of a manifest name it. |
role | yes | bootloader, partition-table, firmware, update, storage, crash-record or custom. |
slot | for update | The update slot number n. |
offset | no | A fixed offset. Without it, the partition goes at the first offset after the previous partition that satisfies its alignment. |
size | yes | A size, "remaining", or a table { minimum, grow, maximum }. See Growing sizes. |
alignment | no | The alignment of this partition. Default: the alignment of [flash]. |
filesystem | no | Informative. On Espressif, fat, spiffs and littlefs select the subtype of a storage partition. |
espressif | no | Attributes of the Espressif partition table. |
mbr | no | Attributes of the MBR. |
linker | no | Attributes of the linker writer. |
Roles
| Role | Meaning |
|---|---|
bootloader | The bootloader. |
partition-table | Where the table writer puts its table. flash writes the generated table there unless a manifest image targets it. |
firmware | The application. nanoflash run writes its image to the one firmware partition. |
update | An update slot, with slot = <n>. |
storage | Data, such as a file system. |
crash-record | A crash record, such as a core dump. |
custom | Anything 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.
| Table | Keys |
|---|---|
espressif | type and subtype, by name (such as "data", "nvs", "phy", "ota", "coredump", "factory") or by number; encrypted and readonly, booleans. |
mbr | type, the partition type byte; bootable, a boolean. |
linker | region, 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 leastminimum, plus a share of the free space weighted bygrow(a whole number from 1, default 1), up tomaximum(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:
| Format | Output | Notes |
|---|---|---|
espressif | The binary Espressif partition table, placed at the partition-table partition. | Checked against esp-idf-part and gen_esp32part.py. |
mbr | A 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. |
linker | The 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. |
constants | Rust 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.