Where ESP32 firmware goes: 0x0, 0x1000 or 0x10000

A perfectly good ESP32 image written at the wrong address gives you a board that does not boot and an esptool that reports success. Here is the offset for every chip, quoted from that chip's own ESP-IDF startup guide, how to tell the three image shapes apart from their first bytes, and why the command is called write_flash on one machine and write-flash on the next.

Last checked against the source code on 2026-11-14.

The offsets, per chip

An ESP32’s first-stage ROM bootloader loads the second-stage bootloader from a fixed address, and that address is not the same on every chip in the family. Each row below is quoted from that chip’s own ESP-IDF startup guide:

ChipBootloader-first imageChip id in the header
ESP320x10000x0000
ESP32-S20x10000x0002
ESP32-S30x00x0009
ESP32-C20x00x000c
ESP32-C30x00x0005
ESP32-C60x00x000d
ESP32-H20x00x0010
ESP32-C50x20000x0017
ESP32-C610x20000x0014
ESP32-P40x20000x0012

ESP-IDF for the classic ESP32: “Second stage bootloader binary image is loaded from flash starting at address 0x1000” (startup guide). For the S3 and the C3 the same sentence reads “from the start of flash at offset 0x0”, and for the C5 “from flash offset 0x2000”. So ESP32 and ESP32-S2 sit at 0x1000; ESP32-S3, ESP32-C2, ESP32-C3, ESP32-C6, ESP32-H2 at 0x0; and ESP32-C5, ESP32-C61, ESP32-P4 at 0x2000.

Above that: the partition table at 0x8000, and the app itself at 0x10000. ESP-IDF’s partition-tables guide states both — the table is flashed “to the default offset 0x8000 in the flash”, and “In both cases the factory app is flashed at offset 0x10000”.

0x0000  +-------------------------------+  <- S3 / C3 / C6 / C2 / H2 bootloader
0x1000  +-------------------------------+  <- ESP32 / S2 bootloader
0x2000  +-------------------------------+  <- C5 / C61 / P4 bootloader
0x8000  +-- partition table ------------+
0x10000 +-- factory app ----------------+  <- an app-only .bin goes HERE

Which of the three shapes is your file?

You do not have to remember what produced a file; the file says so. ESP-IDF defines ESP_IMAGE_HEADER_MAGIC 0xe9 and puts the two-byte esp_chip_id_t at byte offset 12 of esp_image_header_t (esp_app_format.h); an application image carries esp_app_desc_t, whose ESP_APP_DESC_MAGIC_WORD is 0xabcd5432 (esp_app_desc.h), at file offset 0x20.

write_flash or write-flash? Ask the installed esptool

esptool v5 renamed every command and option from underscores to hyphens. Espressif’s v5 migration guide says “All the commands and options have been renamed to use - instead of _ as a separator” and tells readers to replace them in scripts and CI pipelines. The trap is that it is not one-way compatible in practice: v5 accepts the old form with a deprecation warning, while v4 rejects the new one outright — measured here on v4.12.0, which answers invalid choice: 'write-flash'.

esptoolWriteErase
v4write_flasherase_flash
v5write-flasherase-flash

So a script that hard-codes either spelling is broken on half the machines it runs on. The only portable answer is to read esptool version first and pick, which is exactly what this server does.

What the MCP server does with all of this

flash_firmware reads the image header, classifies the file as one of the three shapes above, looks up the chip’s offset from the same table this page prints, and spells the verb for the installed esptool:

flash_firmware { "family": "esp32", "path": "COM5",
                 "firmwarePath": "ESP32_GENERIC-20250809-v1.26.0.bin" }

-> bootloader-first image for ESP32 (the MicroPython download shape);
   belongs at 0x1000
-> esptool --port COM5 write-flash 0x1000 ESP32_GENERIC-...bin

And when the file is none of the three, it stops. The old behaviour was to write every ESP32 image at 0x0 — correct for an S3 or a merge-bin output, and wrong for the classic ESP32 that most people own, which left a board that silently would not boot. Now an unplaceable file comes back with the reason and the name of the flashOffset argument that would override it, because a refusal costs you a minute and a wrong offset costs you an afternoon.

Proof level: the offsets and the header classification are unit-tested against the first bytes of the real MicroPython ESP32_GENERIC, ESP32_GENERIC_S3 and ESP32_GENERIC_C3 images, and calibrated against both esptool v4.12.0 and v5.5.0 image_info output. The flash path itself has run on physical silicon once: an Arduino Nano ESP32, 2026-10-31, through the built server over real stdio.

Have your agent do this for you

Hand your agent the .bin and the port; it reads the header, writes it at the right address, and tells you whether the board came back.

Install the server (macOS or Linux; Node.js 20 or newer, installs under your home directory, no root):

curl -fsSL https://mcuport.com/install.sh | sh

Windows PowerShell: irm https://mcuport.com/install.ps1 | iex

Then register it with Claude Code:

claude mcp add mcuport -- ~/.local/bin/mcuport

No board on the desk right now? The same server runs three simulated boards on the real MicroPython interpreter, so you can see the tool calls before you own anything: claude mcp add mcuport -e MCUPORT_SIMULATOR=1 -- ~/.local/bin/mcuport

No account, no sign-up and no upload: it is a local process that talks to your board over USB. The desktop server is free with unlimited boards — see pricing for the one thing that is not — and the quickstart has the Claude Desktop and Cursor config.

Frequently asked questions

Should I flash my ESP32 image at 0x0 or 0x1000?
It depends on the chip and on which kind of image you have, and getting it wrong gives you a board that does not boot with no error from esptool. A bootloader-first image -- the shape of the official MicroPython downloads -- goes at the chip's bootloader offset: 0x1000 on a classic ESP32 and on the S2, 0x0 on the S3, C3, C6, C2 and H2, and 0x2000 on the C5, C61 and P4. An app-only .bin from ESP-IDF or the Arduino core goes at the app partition, 0x10000. An "esptool merge-bin" output is padded from zero and goes at 0x0 whatever the chip.
Why is the app at 0x10000 and not right after the bootloader?
Because the partition table sits between them. ESP-IDF's partition-tables guide says the table is flashed to the default offset 0x8000, and that with either built-in layout "the factory app is flashed at offset 0x10000". That gap is why writing an app-only binary at the bootloader offset bricks the boot: you have overwritten the bootloader with something that is not one.
How can I tell which kind of .bin I have?
From its first bytes. ESP-IDF defines ESP_IMAGE_HEADER_MAGIC as 0xe9, so byte 0 of any ESP32-family image is 0xe9; the 16-bit chip id sits at byte offset 12 (ESP32 = 0x0000, ESP32-S3 = 0x0009, ESP32-C3 = 0x0005); and an application image carries an esp_app_desc_t whose magic word is 0xabcd5432 at file offset 0x20, which a bootloader-first image does not have. A merge-bin output starts with 0xFF padding instead of a header, with the real header at the chip's bootloader offset. Those three tests tell the three shapes apart with no guessing.
Why does esptool say invalid choice: 'write-flash'?
Because you are on esptool v4 and using the v5 spelling. esptool v5 renamed every command from underscores to hyphens -- its migration guide says "All the commands and options have been renamed to use - instead of _ as a separator" and tells you to update scripts and CI. v4 only accepts write_flash; v5 documents write-flash and still accepts the old form with a deprecation warning. So the only spelling that works everywhere is the one you choose after reading "esptool version". The same rename hit erase_flash -> erase-flash, --before/--after values (no_reset -> no-reset), and merge-bin's --fill-flash-size -> --pad-to-size; --verify was removed from write-flash outright.
My board flashed fine and still does not boot. What now?
Read the ROM banner before you re-flash. A reset reason of rst:0x10 (RTCWDT_RTC_RESET) on a freshly flashed board most often means an incomplete image: the bootloader, partition table or app is missing, or the image went to the wrong offset. If you ran erase-flash and then wrote only the app, that is exactly this case. The boot-log guide on this site has the whole reset table.
Does MCUPort pick the offset for me?
Yes, and it refuses rather than guesses. flash_firmware reads the image header, decides whether it is a bootloader-first image, an app-only image or a merge-bin output, looks up the chip's bootloader offset from the table on this page, and runs esptool with the verb your installed version accepts. If the file is none of those three shapes it does not fall back to 0x0 -- it returns the reason and names the flashOffset argument, because guessing 0x0 was the actual bug this replaced: it is right for an S3 and wrong for the classic ESP32 that most people own.