Using a ESP32-S3-DevKitC-1-N32R8V, that uses a ESP32-S3-WROOM-2-N32R8V module, that is a ESP32-S3R8V, 32MB Octal SPI Flash, 8MB Octal SPI PSRAM, 1.8V SPI.
Programming a Flash size of 32MB results in esp_image: Segment 3 0x3fce3810-0x3fce4f9c invalid: overlaps bootloader stack and OTA app partition slot 1 is not bootable.
There is no specific board type for ESP32-S3-WROOM-2-N32R8V / ESP32-S3-DevKitC-1-N32R8V, the closest is esp32-s3-devkitc-1 but that is for 8MB flash and no PSRAM.
To my knowledge there is no way to use custom board layouts from ESPHome (ref, ref), and I modified the esp32-s3-devkitc-1 board configuration via platformio_options and sdkconfig_options to account for 32MB Octal Flash and 8MB Octal PSRAM.
I also had to use the ESP-IDF framework, not Arduino, and change the espressif32 and esp-idf versions to the latest released versions, else even setting 32MB size would not compile and / or create a boot loop.
It appears that using ESP-IDF the Arduino partition table layout is ignored (I was not sure if any Arduino options are required), and the tooling creates its own partition layout.
Write firmware over USB-UART, esphome run .\n32r8v-ota-test.yaml.
Set boot LED color to Green in YAML.
Connect Serial Monitor to USB-UART, press reset button to capture boot.
Apply firmware update OTA, esphome run .\n32r8v-ota-test.yaml and capture UART output.
Observe that no OTA errors were reported on the client OTA uploader.
Observe that the UART log output reported an OTA failure after OTA reboot.
Observe that the LED color remained Blue, i.e. new firmware is not running.
Repeat test with 16MB Flash settings in YAML:
OTA works as expected.
Which version of ESPHome has the issue?
2024.5.0
What type of installation are you using?
pip
Which version of Home Assistant has the issue?
NA
What platform are you using?
ESP32-IDF
Board
ESP32-S3-DevKitC-1-N32R8V
Component causing the issue
OTA
Example YAML snippet
# Config for ESP32-S3-DevKitC-1-N32R8V (32MB OT Flash, 8MB OT PSRAM)
# TODO: Boot log warnings
# "spi_flash: Octal flash chip is using but dio mode is selected, will automatically swich to Octal mode"
# "tsens: legacy driver is deprecated, please migrate to `driver/temperature_sensor.h`"
# "rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`"
# TODO: OTA does not work, succeeds but does not actually update the firmware, only USB programming works
esphome:
name: n32r8v-ota-test
comment: "ESP32-S3-DevKitC-1-N32R8V Test Device"
on_boot:
then:
# Change boot up LED colors to test if firmware changed
- light.turn_on:
id: rgb_led
red: 0%
green: 100%
blue: 0%
brightness: 25%
effect: none
# Modify default esp32-s3-devkitc-1 (8MB Flash, no PSRAM) board configuration for ESP32-S3-DevKitC-1-N32R8V (32MB Flash, 8MB PSRAM)
platformio_options:
# TODO: Are any Arduino options used when using ESP-IDF?
# Largest "default" partition type is 16MB default_16MB.csv, no default 32MB partition, closest matching in layout is large_littlefs_32MB.csv
# https://github.com/espressif/arduino-esp32/tree/master/tools/partitions
board_build.arduino.partitions: large_littlefs_32MB.csv
# board_build.arduino.partitions: default_16MB.csv
# Octal memory type for Flash and PSRAM
board_build.arduino.memory_type: opi_opi
# TODO: How to add vs. replace?
board_build.extra_flags:
- "-DARDUINO_ESP32S3_DEV"
# Has PSRAM
- "-DBOARD_HAS_PSRAM"
- "-DARDUINO_USB_MODE=1"
- "-DARDUINO_RUNNING_CORE=1"
- "-DARDUINO_EVENT_RUNNING_CORE=1"
# Octal memory type for PSRAM
board_build.psram_type: opi
board_name: "Espressif ESP32-S3-DevKitC-1-N32R8V (32MB OT Flash, 8MB OT PSRAM)"
# TODO: Error when setting flash size in board config?
# "Please specify flash_size within esp32 configuration only.""
#board_upload.flash_size: 32MB
# 32MB
board_upload.maximum_size: 33554432
esp32:
# Platformio config changes will modify esp32-s3-devkitc-1 base configuration
board: esp32-s3-devkitc-1
# TODO: Why can't we set flash size in board config?
flash_size: 32MB
# flash_size: 16MB
framework:
type: esp-idf
# Using latest versions to get the 32MB flash size compiling without boot loops
# There is no "latest" option
platform_version: 6.7.0
# Using latest only brings in 5.2.0 that fails to compile, while latest released is 5.2.1?
version: 5.2.1
# TODO: https://github.com/esphome/issues/issues/5404
# Warning! Flash memory size mismatch detected. Expected 32MB, found 2MB!
sdkconfig_options:
CONFIG_ESPTOOLPY_FLASHSIZE_32MB: "y"
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB: "y"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
domain: !secret wifi_domain
reboot_timeout: 5min
logger:
level: debug
hardware_uart: UART0
ota:
password: !secret ota_password
debug:
update_interval: 60s
light:
- platform: esp32_rmt_led_strip
id: rgb_led
disabled_by_default: true
entity_category: config
rgb_order: GRB
pin: GPIO38
num_leds: 1
rmt_channel: 0
chipset: WS2812
psram:
mode: octal
speed: 80MHz
Anything in the logs that might be useful for us?
OTA Programming:
[D][ota:154]: Starting OTA Update from 192.168.1.15...
[W][component:157]: Component ota set Warning flag: unspecified
[D][ota:330]: OTA in progress: 0.1%
[D][ota:330]: OTA in progress: 33.7%
[D][ota:330]: OTA in progress: 66.1%
[D][ota:330]: OTA in progress: 99.4%
[I][ota:363]: OTA update finished!
[W][component:170]: Component ota cleared Warning flag
[I][app:132]: Rebooting safely...
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
UART Log:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40376d89
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3810,len:0x178c
load:0x403c9700,len:0x4
load:0x403c9704,len:0xcbc
load:0x403cc700,len:0x2da0
entry 0x403c990c
I (37) boot: ESP-IDF 5.2.1 2nd stage bootloader
I (38) boot: compile time May 19 2024 17:42:54
I (38) boot: Multicore bootloader
I (41) boot: chip revision: v0.1
I (44) boot.esp32s3: Boot SPI Speed : 80MHz
I (49) boot.esp32s3: SPI Mode : SLOW READ
I (54) boot.esp32s3: SPI Flash Size : 32MB
I (59) boot: Enabling RNG early entropy source...
I (65) boot: Partition Table:
I (68) boot: ## Label Usage Type ST Offset Length
I (76) boot: 0 otadata OTA data 01 00 00009000 00002000
I (83) boot: 1 phy_init RF data 01 01 0000b000 00001000
I (90) boot: 2 app0 OTA app 00 10 00010000 00fc0000
I (98) boot: 3 app1 OTA app 00 11 00fd0000 00fc0000
I (105) boot: 4 nvs WiFi data 01 02 01f90000 0006d000
I (113) boot: End of partition table
I (117) esp_image: segment 0: paddr=00fd0020 vaddr=3c090020 size=25904h (153860) map
I (162) esp_image: segment 1: paddr=00ff592c vaddr=3fc98600 size=04904h ( 18692) load
I (168) esp_image: segment 2: paddr=00ffa238 vaddr=40374000 size=05de0h ( 24032) load
I (175) esp_image: segment 3: paddr=01000020 vaddr=3fce3810 size=0178ch ( 6028) load
E (177) esp_image: Segment 3 0x3fce3810-0x3fce4f9c invalid: overlaps bootloader stack
E (185) boot: OTA app partition slot 1 is not bootable
I (191) esp_image: segment 0: paddr=00010020 vaddr=3c090020 size=25904h (153860) map
I (236) esp_image: segment 1: paddr=0003592c vaddr=3fc98600 size=04904h ( 18692) load
I (241) esp_image: segment 2: paddr=0003a238 vaddr=40374000 size=05de0h ( 24032) load
I (248) esp_image: segment 3: paddr=00040020 vaddr=42000020 size=87b58h (555864) map
I (382) esp_image: segment 4: paddr=000c7b80 vaddr=40379de0 size=0e7b0h ( 59312) load
I (407) boot: Loaded app from partition at offset 0x10000
I (407) boot: Disabling RNG early entropy source...
I (419) cpu_start: Multicore app
Additional information
Other anomalies:
Why is it not possible to set the flash size in the board configuration?
When setting board_upload.flash_size: 32MB get error Please specify flash_size within esp32 configuration only..
Get errorWarning! Flash memory size mismatch detected. Expected 32MB, found 2MB!
Must set sdkconfig_optionsCONFIG_ESPTOOLPY_FLASHSIZE_32MB: "y" or CONFIG_ESPTOOLPY_FLASHSIZE_16MB: "y", the tooling should do this if not allowing the board config to be used for the correct flash size.
OTA update succeeded, expected some form of error and or validation before or during OTA.
There is no "latest" option for Espressif32 platform_version, must be manually changed, wish there was.
When using "latest" for ESP-IDF version, and older 5.2.0 is used that fails to compile, while the latest release in the repo is 5.2.1, why?
OTA Logs:
> esphome run .\n32r8v-ota-test.yaml
INFO ESPHome 2024.5.0
INFO Reading configuration .\n32r8v-ota-test.yaml...
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
INFO Generating C++ source...
INFO Updating https://github.com/espressif/esp-protocols.git@mdns-v1.2.5
INFO Compiling app...
Processing n32r8v-ota-test (board: esp32-s3-devkitc-1; framework: espidf; platform: platformio/espressif32@6.7.0)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1.html
PLATFORM: Espressif 32 (6.7.0) > Espressif ESP32-S3-DevKitC-1-N32R8V (32MB OT Flash, 8MB OT PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 32MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-espidf @ 3.50201.240515 (5.2.1)
- tool-cmake @ 3.16.4
- tool-esptoolpy @ 1.40501.0 (4.5.1)
- tool-idf @ 1.0.1
- tool-mconf @ 1.4060000.20190628 (406.0.0)
- tool-ninja @ 1.9.0
- tool-riscv32-esp-elf-gdb @ 11.2.0+20220823
- tool-xtensa-esp-elf-gdb @ 11.2.0+20230208
- toolchain-esp32ulp @ 2.35.0-20220830
- toolchain-riscv32-esp @ 13.2.0+20230928
- toolchain-xtensa-esp-elf @ 13.2.0+20230928
Reading CMake configuration...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ off, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pioenvs\n32r8v-ota-test\firmware.elf
Checking size .pioenvs\n32r8v-ota-test\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 11.3% (used 36964 bytes from 327680 bytes)
Flash: [ ] 4.9% (used 811501 bytes from 16515072 bytes)
==================================================================================================================================== [SUCCESS] Took 5.63 seconds ====================================================================================================================================
INFO Successfully compiled program.
Found multiple options for uploading, please choose one:
[1] COM9 (Silicon Labs CP210x USB to UART Bridge (COM9))
[2] Over The Air (n32r8v-ota-test.home.insanegenius.net)
(number): 2
INFO Resolving IP address of n32r8v-ota-test.home.insanegenius.net
INFO -> 192.168.1.129
INFO Uploading .\.esphome\build\n32r8v-ota-test\.pioenvs\n32r8v-ota-test\firmware.bin (811872 bytes)
Uploading: [============================================================] 100% Done...
INFO Upload took 3.03 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from COM9 with baud rate 115200
ERROR Could not connect to serial port COM9
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The problem
Using a ESP32-S3-DevKitC-1-N32R8V, that uses a ESP32-S3-WROOM-2-N32R8V module, that is a ESP32-S3R8V, 32MB Octal SPI Flash, 8MB Octal SPI PSRAM, 1.8V SPI.
Programming a Flash size of 32MB results in
esp_image: Segment 3 0x3fce3810-0x3fce4f9c invalid: overlaps bootloader stack
andOTA app partition slot 1 is not bootable
.There is no specific board type for ESP32-S3-WROOM-2-N32R8V / ESP32-S3-DevKitC-1-N32R8V, the closest is
esp32-s3-devkitc-1
but that is for 8MB flash and no PSRAM.To my knowledge there is no way to use custom board layouts from ESPHome (ref, ref), and I modified the
esp32-s3-devkitc-1
board configuration viaplatformio_options
andsdkconfig_options
to account for 32MB Octal Flash and 8MB Octal PSRAM.I also had to use the ESP-IDF framework, not Arduino, and change the espressif32 and esp-idf versions to the latest released versions, else even setting 32MB size would not compile and / or create a boot loop.
It appears that using ESP-IDF the Arduino partition table layout is ignored (I was not sure if any Arduino options are required), and the tooling creates its own partition layout.
large_littlefs_32MB.csv
:From log output:
Test setup:
pip install --upgrade setuptools wheel platformio esphome
.> python --version Python 3.12.3
.> esphome version Version: 2024.5.0
.> pio --version PlatformIO Core, version 6.1.15
.esphome run .\n32r8v-ota-test.yaml
.esphome run .\n32r8v-ota-test.yaml
and capture UART output.Repeat test with 16MB Flash settings in YAML:
Which version of ESPHome has the issue?
2024.5.0
What type of installation are you using?
pip
Which version of Home Assistant has the issue?
NA
What platform are you using?
ESP32-IDF
Board
ESP32-S3-DevKitC-1-N32R8V
Component causing the issue
OTA
Example YAML snippet
Anything in the logs that might be useful for us?
OTA Programming:
UART Log:
Additional information
Other anomalies:
board_upload.flash_size: 32MB
get errorPlease specify flash_size within esp32 configuration only.
.Warning! Flash memory size mismatch detected. Expected 32MB, found 2MB!
sdkconfig_options
CONFIG_ESPTOOLPY_FLASHSIZE_32MB: "y"
orCONFIG_ESPTOOLPY_FLASHSIZE_16MB: "y"
, the tooling should do this if not allowing the board config to be used for the correct flash size.platform_version
, must be manually changed, wish there was.version
, and older5.2.0
is used that fails to compile, while thelatest
release in the repo is5.2.1
, why?OTA Logs:
UART logs attached. COM9_2024_05_19.17.46.46.427.txt