espsss / reference / quick / flash-offsets

Flash offsets and esptool commands

Where the bootloader, the partition table and the app go in flash on each ESP32 chip, and the esptool commands that write them the way Arduino IDE does.

In short

  • Second-stage bootloader: 0x1000 on ESP32 and ESP32-S2, 0x2000 on ESP32-C5 and ESP32-P4, 0x0 on the other chips in the table below. The ROM bootloader fixes it; it is not configurable.1
  • Partition table: 0x8000 by default on every chip (CONFIG_PARTITION_TABLE_OFFSET); Arduino always writes it there.2
  • Arduino upload writes four files: bootloader, partitions at 0x8000, boot_app0.bin at 0xe000, the sketch at 0x10000.3
  • arduino-esp32 3.3.12 ships esptool v5.3.1, which uses dashes in command names (write-flash, merge-bin); the old underscore names still work with a deprecation warning.4

Offsets per chip

Bootloader offset from ESP-IDF Kconfig, cross-checked against arduino-esp32 boards.txt. Partition table and first app offset are the same for all chips in the Arduino default scheme.

ChipBootloaderPartition tableApp (app0)
ESP320x1000150x8000230x1000063
ESP32-S20x1000150x8000230x1000063
ESP32-S30x0150x8000230x1000063
ESP32-C20x0150x8000230x1000063
ESP32-C30x0150x8000230x1000063
ESP32-C50x2000150x8000230x1000063
ESP32-C60x0150x8000230x1000063
ESP32-C610x0150x8000230x1000063
ESP32-H20x0150x8000230x1000063
ESP32-P40x2000150x8000230x1000063

App offset is from the Arduino default partition scheme (default.csv); other schemes may differ.

Arduino default layout (4 MB)

What an Arduino upload puts where with the default partition scheme. Everything after the partition table comes from default.csv.

OffsetWhatWritten by upload
0x0 / 0x1000 / 0x2000Second-stage bootloader (chip-dependent, see above)yes: <sketch>.bootloader.bin3
0x8000Partition tableyes: <sketch>.partitions.bin3
0x9000nvs, 0x5000 bytesno6
0xe000otadata, 0x2000 bytesyes: boot_app0.bin6
0x10000app0 (ota_0), 0x140000 bytesyes: <sketch>.bin6
0x150000app1 (ota_1), 0x140000 bytesno6
0x290000spiffs, 0x160000 bytesno6
0x3F0000coredump, 0x10000 bytesno6

esptool cheat sheet (v5 syntax)

PORT is /dev/ttyUSB0, /dev/ttyACM0, COM3 and so on. --chip is optional for write-flash: esptool detects the chip.

Chip, flash and MAC

chip-id prints the chip ID, flash-id the SPI flash manufacturer, device and detected size, read-mac the built-in MAC address.7

esptool --port PORT chip-id
esptool --port PORT flash-id
esptool --port PORT read-mac

Erase

erase-flash sets the whole chip to 0xFF, including the nvs partition. erase-region erases a range; address and length must be multiples of 0x1000.8

esptool --port PORT erase-flash
esptool --port PORT erase-region 0x290000 0x160000

Write an Arduino build (ESP32-S3)

The same four files and offsets as the Arduino upload recipe. For ESP32 and ESP32-S2 use 0x1000 for the bootloader, for ESP32-C5 and ESP32-P4 0x2000. File names in the Arduino build folder end in .bootloader.bin, .partitions.bin and .bin.3

esptool --chip esp32s3 --port PORT --baud 921600 \
  --before default-reset --after hard-reset write-flash -z \
  --flash-mode keep --flash-freq keep --flash-size keep \
  0x0     bootloader.bin \
  0x8000  partitions.bin \
  0xe000  boot_app0.bin \
  0x10000 app.bin

Write only the app

Arduino's "program" recipe writes just the sketch at 0x10000.3

esptool --chip esp32s3 --port PORT write-flash -z 0x10000 app.bin

Merge into one image

Arduino builds a .merged.bin the same way, padded to the flash size. A raw merged image is written at 0x0 (unless built with --target-offset), whatever the bootloader offset: the gap before the bootloader is filled with 0xFF.3

esptool --chip esp32s3 merge-bin -o merged.bin --pad-to-size 4MB \
  0x0 bootloader.bin 0x8000 partitions.bin \
  0xe000 boot_app0.bin 0x10000 app.bin
esptool --port PORT write-flash 0x0 merged.bin

Old syntax (esptool v4)

esptool.py write_flash, merge_bin, erase_flash, read_mac, chip_id. In v5 these names and the .py script names are deprecated but still accepted with a warning; --before/--after values also changed to dashes (default-reset, hard-reset).9

esptool.py --chip esp32s3 --port PORT write_flash 0x10000 app.bin

Pitfalls

ESP32 image written at 0x0

A bootloader.bin written at 0x0 on ESP32 or ESP32-S2 (or at 0x1000 on ESP32-S3) is not where the ROM looks for it. Only a merged image goes at 0x0 on every chip.1

Moving the partition table

In ESP-IDF the partition table offset can be changed, but bootloader and app must be built with the same value. Arduino's upload and merge recipes write the table at a fixed 0x8000.2

Merged image erases the gaps

A raw merged image fills the gaps with 0xFF, so writing it also erases whatever was between the files. To keep data in those areas, write the files individually.8

Sources

Each number links here; open “What it confirms” for the exact quotes. Checked 2026-11-28.

  1. ESP-IDF v5.5.5: components/bootloader/Kconfig.projbuild primary
    What it confirms (12)
    • Flash offsets and esptool commands: in short “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 … default 0x2000 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32H4 … default 0x0 … The value is determined by the ROM bootloader. … It's not configurable in ESP-IDF.”
    • Flash offsets and esptool commands: ESP32 / Bootloader “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2”
    • Flash offsets and esptool commands: ESP32-S2 / Bootloader “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2”
    • Flash offsets and esptool commands: ESP32-S3 / Bootloader “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 … default 0x2000 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32H4 … default 0x0”
    • Flash offsets and esptool commands: ESP32-C2 / Bootloader “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 … default 0x2000 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32H4 … default 0x0”
    • Flash offsets and esptool commands: ESP32-C3 / Bootloader “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 … default 0x2000 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32H4 … default 0x0”
    • Flash offsets and esptool commands: ESP32-C5 / Bootloader “default 0x2000 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32H4”
    • Flash offsets and esptool commands: ESP32-C6 / Bootloader “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 … default 0x2000 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32H4 … default 0x0”
    • Flash offsets and esptool commands: ESP32-C61 / Bootloader “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 … default 0x2000 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32H4 … default 0x0”
    • Flash offsets and esptool commands: ESP32-H2 / Bootloader “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 … default 0x2000 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32H4 … default 0x0”
    • Flash offsets and esptool commands: ESP32-P4 / Bootloader “default 0x2000 if IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32H4”
    • Flash offsets and esptool commands: pitfall: ESP32 image written at 0x0 “default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 … The value is determined by the ROM bootloader. … This file can be later written to flash with ``esptool write-flash 0x0 merged-flash.bin``.”
  2. ESP-IDF v5.5.5: components/partition_table/Kconfig.projbuild primary
    What it confirms (12)
    • Flash offsets and esptool commands: in short “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32-S2 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32-S3 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32-C2 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32-C3 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32-C5 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32-C6 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32-C61 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32-H2 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: ESP32-P4 / Partition table “config PARTITION_TABLE_OFFSET … default 0x8000”
    • Flash offsets and esptool commands: pitfall: Moving the partition table “Note that the bootloader and app will both need to be compiled with the same PARTITION_TABLE_OFFSET value. … 0x8000 "{build.path}/{build.project_name}.partitions.bin"”
  3. arduino-esp32 3.3.12: platform.txt primary
    What it confirms (26)
    • Flash offsets and esptool commands: in short “0x8000 "{build.path}/{build.project_name}.partitions.bin" 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32-S2 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32-S2 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32-S3 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32-S3 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32-C2 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32-C2 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32-C3 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32-C3 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32-C5 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32-C5 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32-C6 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32-C6 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32-C61 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32-C61 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32-H2 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32-H2 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: ESP32-P4 / Partition table “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: ESP32-P4 / App (app0) “0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: 0x0 / 0x1000 / 0x2000 “{build.bootloader_addr} "{build.path}/{build.project_name}.bootloader.bin"”
    • Flash offsets and esptool commands: 0x8000 “0x8000 "{build.path}/{build.project_name}.partitions.bin"”
    • Flash offsets and esptool commands: Write an Arduino build (ESP32-S3) “--before default-reset --after hard-reset write-flash {upload.erase_cmd} -z --flash-mode keep --flash-freq keep --flash-size keep {build.bootloader_addr} … esp32s3.build.bootloader_addr=0x0 … esp32s3.menu.UploadSpeed.921600.upload.speed=921600”
    • Flash offsets and esptool commands: Write only the app “write-flash -z --flash-mode keep --flash-freq keep --flash-size keep 0x10000 "{build.path}/{build.project_name}.bin"”
    • Flash offsets and esptool commands: Merge into one image “merge-bin -o "{build.path}/{build.project_name}.merged.bin" --pad-to-size {build.flash_size} … This file can be later written to flash with ``esptool write-flash 0x0 merged-flash.bin``. … gaps between individual files will be filled with `0xFF` bytes … The ``--target-offset 0xNNN`` option will create a merged binary that should be flashed at the specified offset, instead of at offset 0x0.”
  4. arduino-esp32 3.3.12: package/package_esp32_index.template.json primary
    What it confirms (1)
    • Flash offsets and esptool commands: in short “esptool-v5.3.1-linux-amd64.tar.gz … All the commands and options have been renamed to use ``-`` instead of ``_`` as a separator (e.g., ``write_flash`` -> ``write-flash``). … Old command and option names are **deprecated**, meaning they will work for now with a warning”
  5. arduino-esp32 3.3.12: boards.txt primary
    What it confirms (10)
    • Flash offsets and esptool commands: ESP32 / Bootloader “esp32.build.bootloader_addr=0x1000”
    • Flash offsets and esptool commands: ESP32-S2 / Bootloader “esp32s2.build.bootloader_addr=0x1000”
    • Flash offsets and esptool commands: ESP32-S3 / Bootloader “esp32s3.build.bootloader_addr=0x0”
    • Flash offsets and esptool commands: ESP32-C2 / Bootloader “esp32c2.build.bootloader_addr=0x0”
    • Flash offsets and esptool commands: ESP32-C3 / Bootloader “esp32c3.build.bootloader_addr=0x0”
    • Flash offsets and esptool commands: ESP32-C5 / Bootloader “esp32c5.build.bootloader_addr=0x2000”
    • Flash offsets and esptool commands: ESP32-C6 / Bootloader “esp32c6.build.bootloader_addr=0x0”
    • Flash offsets and esptool commands: ESP32-C61 / Bootloader “esp32c61.build.bootloader_addr=0x0”
    • Flash offsets and esptool commands: ESP32-H2 / Bootloader “esp32h2.build.bootloader_addr=0x0”
    • Flash offsets and esptool commands: ESP32-P4 / Bootloader “esp32p4.build.bootloader_addr=0x2000”
  6. arduino-esp32 3.3.12: tools/partitions/default.csv primary
    What it confirms (16)
    • Flash offsets and esptool commands: ESP32 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: ESP32-S2 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: ESP32-S3 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: ESP32-C2 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: ESP32-C3 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: ESP32-C5 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: ESP32-C6 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: ESP32-C61 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: ESP32-H2 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: ESP32-P4 / App (app0) “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: 0x9000 “nvs, data, nvs, 0x9000, 0x5000,”
    • Flash offsets and esptool commands: 0xe000 “otadata, data, ota, 0xe000, 0x2000, … 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin"”
    • Flash offsets and esptool commands: 0x10000 “app0, app, ota_0, 0x10000, 0x140000,”
    • Flash offsets and esptool commands: 0x150000 “app1, app, ota_1, 0x150000,0x140000,”
    • Flash offsets and esptool commands: 0x290000 “spiffs, data, spiffs, 0x290000,0x160000,”
    • Flash offsets and esptool commands: 0x3F0000 “coredump, data, coredump,0x3F0000,0x10000,”
  7. esptool v5.3.1: esptool/__init__.py primary
    What it confirms (1)
    • Flash offsets and esptool commands: Chip, flash and MAC “@cli.command("chip-id") … Print the device chip ID. … esptool flash-id … Detected flash size: 4MB … esptool read-mac”
  8. esptool v5.3.1: docs/en/esptool/basic-commands.rst primary
    What it confirms (2)
    • Flash offsets and esptool commands: Erase “To erase the entire flash chip (all data replaced with 0xFF bytes): … esptool erase-flash … The address and length must both be multiples of the SPI flash erase sector size. This is 0x1000 (4096) bytes for supported flash chips.”
    • Flash offsets and esptool commands: pitfall: Merged image erases the gaps “Because gaps between the input files are padded with `0xFF` bytes, when the merged binary is written then any flash sectors between the individual files will be erased. To avoid this, write the files individually.”
  9. esptool v5.3.1: docs/en/migration-guide.rst primary
    What it confirms (1)
    • Flash offsets and esptool commands: Old syntax (esptool v4) “``esptool.py`` → ``esptool`` … Scripts with ``.py`` suffix are still available for backward compatibility, but they will produce deprecation warning … Old command and option names are **deprecated**, meaning they will work for now with a warning … Choices for the ``--before`` and ``--after`` options have been renamed to use ``-`` instead of ``_`` as a separator (e.g., ``default_reset`` -> ``default-reset``).”