esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

ESP32-S3-WROOM-2 / ESP32-S3-DevKitC-1-N32R8V - 32MB flash causes boot loop when using esp-idf #4966

Closed evlo closed 11 months ago

evlo commented 11 months ago

The problem

I was bored and stared updating all the things I run for no reason really, not a great practice, but I ended up with two boards not wanting to boot after updating, This issue is about ESP32-S3-WROOM-2 that ends in boot loop.

It was working before, so definitely there is a way to build, but weirdly even using original config does not work.

spi_flash: Detected size(512k) smaller than the size in the binary image header(8192k). Probe failed.

is the error message

Which version of ESPHome has the issue?

2023.9.3

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.10.1

What platform are you using?

ESP32-IDF

Board

ESP32-S3-DevKitC-1-N32R8V

Component causing the issue

No response

Example YAML snippet

esphome:
  name: ${hostname}
  comment: ${comment}
  platformio_options:
    #board_build.flash_mode: OPI
    board_build.extra_flags:
      - "-DARDUINO_USB_MODE=0"
      - "-DARDUINO_USB_CDC_ON_BOOT=1"  
    board_upload.flash_size: 32MB 
    #board_upload.flash_size: 16MB
    board_upload.maximum_ram_size: 524288

esp32:
  #variant: esp32s3
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
      CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y
      CONFIG_ESPTOOLPY_OCT_FLASH: y
      CONFIG_ESPTOOLPY_FLASHSIZE_32MB: y
      CONFIG_SPIRAM_SPEED: SPIRAM_SPEED_80M

logger:
  level: VERBOSE
  logs:
    bluetooth_proxy: DEBUG
    esp32_ble: DEBUG
    json: DEBUG
    sensor: DEBUG
    web_server_idf: WARN
    mdns: DEBUG
    esp-idf: DEBUG
    esp32_ble_client: DEBUG

### Anything in the logs that might be useful for us?

```txt
Processing eh-btproxy-02 (board: esp32-s3-devkitc-1; framework: espidf; platform: platformio/espressif32@5.4.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
 - framework-espidf @ 3.40405.230623 (4.4.5) 
 - tool-cmake @ 3.16.9 
 - tool-ninja @ 1.10.2 
 - toolchain-esp32ulp @ 2.35.0-20220830 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
======================== [SUCCESS] Took 501.59 seconds ========================
INFO Successfully compiled program.
esptool.py v4.6.2
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 68:b6:b3:3c:d5:7c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 32MB
WARNING: Flasher stub doesn't fully support flash size larger than 16MB, in case of failure use --no-stub.
Flash will be erased from 0x00010000 to 0x00133fff...
Flash will be erased from 0x00000000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x00009000 to 0x0000afff...
Compressed 1194960 bytes to 764303...
Wrote 1194960 bytes (764303 compressed) at 0x00010000 in 20.4 seconds (effective 469.4 kbit/s)...
Hash of data verified.
Warning: Image file at 0x0 is protected with a hash checksum, so not changing the flash size setting. Use the --flash_size=keep option instead of --flash_size=32MB in order to remove this warning, or use the --dont-append-digest option for the elf2image command in order to generate an image file without a hash checksum
Compressed 21104 bytes to 13242...
Wrote 21104 bytes (13242 compressed) at 0x00000000 in 0.6 seconds (effective 297.3 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 134...
Wrote 3072 bytes (134 compressed) at 0x00008000 in 0.0 seconds (effective 511.5 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 31...
Wrote 8192 bytes (31 compressed) at 0x00009000 in 0.1 seconds (effective 701.9 kbit/s)...
Hash of data verified.

(I'm build on HA yellow, so 10 minutes per try really)

Boot loop on

Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB0 with baud rate 115200
[03:40:05]xx\x80\x80 \x80 \x80 \x80 x \xf8xxx\xf8x\xf8\x80 \x80 x \x80\x80\xf8\x80\x80\x80\x80\xf8 x\xf8 \x80x \xeb+\x91\xe90x403c9700,len:0xbcc
[03:40:05]load:0x403cc700,len:0x3024
[03:40:05]entry 0x403c9954
[03:40:05]I (32) boot: ESP-IDF 4.4.5 2nd stage bootloader
[03:40:05]I (32) boot: compile time 03:38:34
[03:40:05]I (33) boot: chip revision: v0.1
[03:40:05]I (34) boot.esp32s3: Boot SPI Speed : 80MHz
[03:40:05]I (39) boot.esp32s3: SPI Mode       : SLOW READ
[03:40:05]I (44) boot.esp32s3: SPI Flash Size : 8MB
[03:40:05]I (49) boot: Enabling RNG early entropy source...
[03:40:05]I (54) boot: Partition Table:
[03:40:05]I (58) boot: ## Label            Usage          Type ST Offset   Length
[03:40:05]I (65) boot:  0 otadata          OTA data         01 00 00009000 00002000
[03:40:05]I (73) boot:  1 phy_init         RF data          01 01 0000b000 00001000
[03:40:05]I (80) boot:  2 app0             OTA app          00 10 00010000 001c0000
[03:40:05]I (88) boot:  3 app1             OTA app          00 11 001d0000 001c0000
[03:40:05]I (95) boot:  4 nvs              WiFi data        01 02 00390000 0006d000
[03:40:05]I (103) boot: End of partition table
[03:40:05]I (107) boot: No factory image, trying OTA 0
[03:40:06]I (112) esp_image: segment 0: paddr=00010020 vaddr=3c0e0020 size=33510h (210192) map
[03:40:06]I (170) esp_image: segment 1: paddr=00043538 vaddr=3fc98120 size=04350h ( 17232) load
[03:40:06]I (175) esp_image: segment 2: paddr=00047890 vaddr=40374000 size=08788h ( 34696) load
[03:40:06]I (185) esp_image: segment 3: paddr=00050020 vaddr=42000020 size=d81ech (885228) map
[03:40:06]I (394) esp_image: segment 4: paddr=00128214 vaddr=4037c788 size=0b990h ( 47504) load
[03:40:06]I (415) boot: Loaded app from partition at offset 0x10000
[03:40:06]I (438) boot: Set actual ota_seq=1 in otadata[0]
[03:40:06]I (438) boot: Disabling RNG early entropy source...
[03:40:06]I (449) cpu_start: Pro cpu up.
[03:40:06]I (449) cpu_start: Starting app cpu, entry point is 0x40375d30
[03:40:06]I (0) cpu_start: App cpu up.
[03:40:06]I (463) cpu_start: Pro cpu start user code
[03:40:06]I (463) cpu_start: cpu freq: 160000000
[03:40:06]I (463) cpu_start: Application information:
[03:40:06]I (466) cpu_start: Project name:     eh-btproxy-02
[03:40:06]I (471) cpu_start: App version:      2023.9.3
[03:40:06]I (477) cpu_start: Compile time:     Oct 10 2023 03:33:54
[03:40:06]I (483) cpu_start: ELF file SHA256:  6cd8647b29abbb6f...
[03:40:06]I (489) cpu_start: ESP-IDF:          4.4.5
[03:40:06]I (493) cpu_start: Min chip rev:     v0.0
[03:40:06]I (498) cpu_start: Max chip rev:     v0.99 
[03:40:06]I (503) cpu_start: Chip rev:         v0.1
[03:40:06]I (508) heap_init: Initializing. RAM available for dynamic allocation:
[03:40:06]I (515) heap_init: At 3FCA3B38 len 00045BD8 (278 KiB): D/IRAM
[03:40:06]I (521) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DIRAM
[03:40:06]I (528) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
[03:40:06]I (534) heap_init: At 600FE000 len 00002000 (8 KiB): RTCRAM
[03:40:06]I (541) spi_flash: detected chip: mxic
[03:40:06]I (545) spi_flash: flash io: dio
[03:40:06]E (549) spi_flash: Detected size(512k) smaller than the size in the binary image header(8192k). Probe failed.
[03:40:06]
[03:40:06]assert failed: do_core_init startup.c:328 (flash_ret == ESP_OK)
[03:40:06]
[03:40:06]
[03:40:06]Backtrace: 0x40376692:0x3fceb170 0x4037f199:0x3fceb190 0x4038542d:0x3fceb1b0 0x42062dfa:0x3fceb2d0 0x40376003:0x3fceb310 0x403cd95c:0x3fceb340 0x403cdda5:0x3fceb380 0x403c99bd:0x3fceb4b0 0x40045c01:0x3fceb570 |<-CORRUPTED
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x40376692: panic_abort at /data/cache/platformio/packages/framework-espidf@3.40405.230623/components/esp_system/panic.c:408
WARNING Decoded 0x4037f199: esp_system_abort at /data/cache/platformio/packages/framework-espidf@3.40405.230623/components/esp_system/esp_system.c:137
WARNING Decoded 0x4038542d: __assert_func at /data/cache/platformio/packages/framework-espidf@3.40405.230623/components/newlib/assert.c:85
WARNING Decoded 0x42062dfa: do_core_init at /data/cache/platformio/packages/framework-espidf@3.40405.230623/components/esp_system/startup.c:320
 (inlined by) start_cpu0_default at /data/cache/platformio/packages/framework-espidf@3.40405.230623/components/esp_system/startup.c:441
WARNING Decoded 0x40376003: call_start_cpu0 at /data/cache/platformio/packages/framework-espidf@3.40405.230623/components/esp_system/port/cpu_start.c:630
[03:40:07]
[03:40:07]
[03:40:07]
[03:40:07]
[03:40:07]ELF file SHA256: 6cd8647b29abbb6f
[03:40:07]
[03:40:07]Rebooting...

Additional information

Maybe something related Octal SPI espressif mentions?

I started without all the sdkconfig_options and platformio_options in the config, these I added in attempts to fix

_test for searching "spiflash: Detected size smaller than the size in the binary image header. Probe failed."

evlo commented 11 months ago

I found this https://github.com/esphome/issues/issues/4072#issuecomment-1402916231 comment by me, which made it seem that the fix it is to add platfrom_version: 5.3.0.

I was probably missing some of the when building

    sdkconfig_options:
      CONFIG_ESPTOOLPY_OCT_FLASH: y
      CONFIG_ESPTOOLPY_FLASHSIZE_32MB: y
      CONFIG_SPIRAM_SPEED: SPIRAM_SPEED_80M

I'm leaving this for me, so I can find this issue next time and not create new one, or others might find this useful

both usb and ota does upload

evlo commented 11 months ago

aithinker-s3-12k (esp-s3-12k) issue very similar

  platformio_options:
    board_build.flash_mode: dio
    board_build.extra_flags:
      - "-DARDUINO_USB_MODE=0"
      - "-DARDUINO_USB_CDC_ON_BOOT=1"

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
      CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y

both usb and ota does upload, but if I do OTA, sometimes esphome does not boot up after the restart - possibly some hw/wifi isssue

maybe this message in verbose log 12:05:58 [V] [api.connection:1116] Cannot send message because of TCP buffer space

Maybe adding psram: would somehow help aithinker-s3-12k (esp-s3-12k) board