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

Flash your first ESP32-S3

In this tutorial, you build ESP-IDF’s hello_world example, describe the flash of an ESP32-S3-DevKitC-1 in a layout file, write a board manifest, and flash the board with nanoflash. At the end, the board prints Hello world! and you see it in the serial monitor.

What you need

  • An ESP32-S3-DevKitC-1 (or another ESP32-S3 board with 8 MiB of flash), connected through its USB port (USB-Serial-JTAG, USB identity 303a:1001).
  • ESP-IDF installed, with IDF_PATH set.
  • The nanoflash command. See Install nanoflash.
  • On Linux, access to serial ports (the dialout group).

1. Build the firmware

Build hello_world for the ESP32-S3:

$ cd $IDF_PATH/examples/get-started/hello_world
$ idf.py set-target esp32s3 build

Leave the default console configuration: the USB-Serial-JTAG secondary console must stay enabled, or the text Hello world! never reaches the port.

Create a directory for the project and copy the two images into it:

$ mkdir -p ~/esp32-s3-hello/firmware
$ cp build/bootloader/bootloader.bin build/hello_world.bin ~/esp32-s3-hello/firmware/
$ cd ~/esp32-s3-hello

2. Describe the flash

Create layout.toml:

[flash]
size = "8 MiB"
alignment = "4 KiB"
base-address = 0x0

[[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" }

[[partition]]
name = "phy_init"
role = "custom"
size = "4 KiB"
espressif = { type = "data", subtype = "phy" }

[[partition]]
name = "application"
role = "firmware"
offset = 0x10000
size = "1 MiB"
alignment = "64 KiB"

This is the partition table of ESP-IDF’s default single-application layout.

3. Check the layout

$ nanoflash layout check layout.toml --image application=firmware/hello_world.bin

The table shows each partition with its offset and size. The application line shows the size of hello_world.bin and the headroom left in its partition. If the image does not fit, nanoflash stops here, before any device is involved.

4. Write the board manifest

Create manifest.toml:

[[board]]
identifier = "esp32-s3-devkitc-1"
name = "ESP32-S3-DevKitC-1"
protocol = "espressif"
chip = "esp32-s3"
layout = "layout.toml"
reset = "espressif-usb-serial-jtag"
application-devices = [{ vendor = 0x303a, product = 0x1001 }]
bootloader-devices = [{ vendor = 0x303a, product = 0x1001 }]

[[board.image]]
partition = "bootloader"
path = "firmware/bootloader.bin"

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

The manifest does not list the partition table: nanoflash generates it from the layout.

5. Flash the board

Connect the board and run:

$ nanoflash flash --board manifest.toml
connecting
writing at 0x0
writing at 0x8000
writing at 0x10000
verifying
resetting
flashed esp32-s3-devkitc-1 (esp32-s3, 8 MiB)
...
verified

nanoflash found the port from the USB identity of the board, reset the chip into its ROM loader, wrote the bootloader, the partition table and the application, checked them with MD5, and reset the chip into the application.

6. See the output

$ nanoflash monitor --board manifest.toml --reset

The board restarts and prints Hello world!. Press Ctrl-C to quit.

What you learned

  • A layout file describes the flash once, and layout check shows the headroom of every image.
  • A board manifest names the layout and the images. nanoflash generates the partition table.
  • flash checks everything before it erases, then writes and verifies.

Next steps