Skip to content

fix: honor ESP32-C6 4MB flash size and avoid deploy hang #357

Closed

Description

@zackees

Context

While validating FastLED AutoResearch on an attached ESP32-C6 DevKitC target, fbuild appears to ignore the configured ESP32-C6 flash size and its deploy path can hang during flashing.

Environment:

  • Repo: FastLED/FastLED workspace at C:\Users\niteris\dev\fastled7
  • Tool: fbuild 2.2.12
  • Target command: bash autoresearch esp32c6 --simd --skip-lint --timeout 180
  • Underlying fbuild deploy command emitted by AutoResearch: .venv\Scripts\fbuild.exe . deploy -e esp32c6 -p COM9
  • Attached chip on COM9: ESP32-C6FH4, 4MB flash, confirmed by uv run python -m esptool --chip esp32c6 --port COM9 chip-id

The FastLED-side configuration asks for 4MB flash:

[env:esp32c6]
board = esp32-c6-devkitc-1
board_build.flash_size = 4MB
board_upload.flash_size = 4MB

ci/boards.py also declares:

ESP32_C6_DEVKITC_1 = Board(
    board_name=esp32c6,
    real_board_name=esp32-c6-devkitc-1,
    platform=ESP32_IDF_5_5_1_PIOARDUINO,
    board_build_flash_size=4MB,
    board_partitions=huge_app.csv,
)

Despite that, fbuild's generated firmware still has an 8MB image header:

$ uv run python -m esptool image-info .fbuild\build\esp32c6\release\firmware.bin
ESP32-C6 Image Header
=====================
Flash size: 8MB
Flash freq: 80m
Flash mode: DIO

The fbuild cache file agrees that 8MB was used:

{
  version: 2,
  flash_mode: dio,
  flash_freq: 80m,
  flash_size: 8MB
}

On the 4MB ESP32-C6FH4, flashing/booting that image causes a boot failure:

E (...) spi_flash: Detected size(4096k) smaller than the size in the binary image header(8192k). Probe failed.
assert failed: __esp_system_init_fn_init_flash startup_funcs.c:118 (flash_ret == ESP_OK)

There is also a deploy hang. fbuild/espflash reports the bootloader write as complete and starts the partitions region, then makes no further progress until the outer AutoResearch timeout expires:

native write: writing region port=COM9 region=Bootloader offset=0x0 size=20144
native write: region complete ... bootloader
Binary successfully written to flash!
native write: writing region port=COM9 region=Partitions offset=0x8000 size=3072

A direct esptool flash of the same fbuild artifacts succeeds when the flash size is overridden to 4MB:

uv run python -m esptool --chip esp32c6 --port COM9 --baud 921600 --before default-reset --after hard-reset write-flash --flash-size 4MB `
  0x0 .fbuild\build\esp32c6\release\bootloader.bin `
  0x8000 .fbuild\build\esp32c6\release\partitions.bin `
  0xe000 .fbuild\build\esp32c6\release\boot_app0.bin `
  0x10000 .fbuild\build\esp32c6\release\firmware.bin

That direct command rewrites the image header to 4MB and the board boots.

Proposal

Make fbuild's ESP32 image generation/deploy path honor the effective PlatformIO/FastLED board flash-size setting for esp32c6, and investigate why the native/espflash deploy path stalls after the bootloader region on this USB-Serial-JTAG C6 board.

Acceptance criteria

  • fbuild build -e esp32c6 produces .fbuild\build\esp32c6\release\firmware.bin with Flash size: 4MB when board_build.flash_size = 4MB is configured.
  • fbuild deploy -e esp32c6 -p COM9 completes on an ESP32-C6FH4 USB-Serial-JTAG board without hanging at the partitions write.
  • A firmware built and deployed by fbuild boots without the ESP-IDF Detected size(4096k) smaller than ... header(8192k) failure.
  • The selected flash size is visible in fbuild's generated metadata/cache/logs so this can be diagnosed without inspecting the binary manually.

Open questions

  • The wrong 8MB image header and the deploy hang may be separate bugs. They were observed through the same fbuild deploy -e esp32c6 -p COM9 workflow.
  • The PlatformIO board package may default esp32-c6-devkitc-1 to 8MB, but fbuild should still let board_build.flash_size = 4MB override that default for FH4 parts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions