ESP32 Atom Lite BTProxy / esp-idf build failure / boot loop

I’m using an esp32 atom lite as BT proxy with the following config

esphome:
  name: atomlite
  friendly_name: AtomLite

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret enc_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Atomlite Fallback Hotspot"
    password: !secret fallback_hotspot_password

captive_portal:

esp32_ble_tracker:
  scan_parameters:
    active: true

  on_ble_advertise: 
    then:
      - lambda: |-
            ESP_LOGD("ble_adv", "New BLE device");
            ESP_LOGD("ble_adv", "  address: %s", x.address_str().c_str());
            ESP_LOGD("ble_adv", "  name: %s", x.get_name().c_str());
            ESP_LOGD("ble_adv", "  Advertised service UUIDs:");
            for (auto uuid : x.get_service_uuids()) {
                ESP_LOGD("ble_adv", "    - %s", uuid.to_string().c_str());
            }
            ESP_LOGD("ble_adv", "  Advertised service data:");
            for (auto data : x.get_service_datas()) {
                ESP_LOGD("ble_adv", "    - %s: (length %i)", data.uuid.to_string().c_str(), data.data.size());
            }
            ESP_LOGD("ble_adv", "  Advertised manufacturer data:");
            for (auto data : x.get_manufacturer_datas()) {
                ESP_LOGD("ble_adv", "    - %s: (length %i)", data.uuid.to_string().c_str(), data.data.size());
                }


bluetooth_proxy:
  active: true
  cache_services: true


When I build the firmware with

framework:
  type: arduino

everything seems ok, however the documentation says I shoul use instead esp-idf, but when I try building firmware with this, it seems I have some kind of boot loop.

Any idea how to fix this?

INFO ESPHome 2024.9.2
INFO Reading configuration /config/esphome/atomlite.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing atomlite (board: esp32-s3-devkitc-1; framework: espidf; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
 - framework-espidf @ 3.40407.240606 (4.4.7) 
 - tool-cmake @ 3.16.4 
 - tool-ninja @ 1.7.1 
 - toolchain-esp32ulp @ 2.35.0-20220830 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
Reading CMake configuration...
Generating assembly for certificate bundle...
Dependency Graph
|-- noise-c @ 0.1.6
Compiling .pioenvs/atomlite/src/esphome/components/api/api_connection.o
.
.
.

Linking .pioenvs/atomlite/firmware.elf
RAM:   [=         ]  14.8% (used 48464 bytes from 327680 bytes)
Flash: [=======   ]  69.2% (used 1270005 bytes from 1835008 bytes)
Building .pioenvs/atomlite/firmware.bin
Creating esp32s3 image...
Successfully created esp32s3 image.
esp32_create_combined_bin([".pioenvs/atomlite/firmware.bin"], [".pioenvs/atomlite/firmware.elf"])
Wrote 0x146260 bytes to file /data/build/atomlite/.pioenvs/atomlite/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/atomlite/firmware.bin"], [".pioenvs/atomlite/firmware.elf"])
======================== [SUCCESS] Took 483.47 seconds ========================
INFO Successfully compiled program.
esptool.py v4.7.0
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-S3 (QFN56) (revision v0.2)
Features: WiFi, BLE, Embedded Flash 8MB (GD)
Crystal is 40MHz
MAC: 24:58:7c:5c:f4:f4
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 8MB
Flash will be erased from 0x00010000 to 0x00146fff...
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 1270368 bytes to 825150...
Wrote 1270368 bytes (825150 compressed) at 0x00010000 in 8.6 seconds (effective 1185.1 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=8MB 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 20848 bytes to 13064...
Wrote 20848 bytes (13064 compressed) at 0x00000000 in 0.3 seconds (effective 476.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 134...
Wrote 3072 bytes (134 compressed) at 0x00008000 in 0.0 seconds (effective 549.6 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 31...
Wrote 8192 bytes (31 compressed) at 0x00009000 in 0.1 seconds (effective 896.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyACM0 with baud rate 115200
[14:08:13]ESP-ROM:esp32s3-20210327
[14:08:13]Build:Mar 27 2021
[14:08:13]rst:0x7 (TG0WDT_SYS_RST),boot:0x28 (SPI_FAST_FLASH_BOOT)
[14:08:13]Saved PC:0x400454d5
[14:08:13]SPIWP:0xee
[14:08:13]mode:QIO, clock div:1
[14:08:13]load:0x3fce3808,len:0x16c4
[14:08:13]ets_loader.c 78 

Have you verified that Atom Lite use S3 chip? M5 site says Esp32-pico.

No, it is not

ERROR Running command failed: This chip is ESP32-S3 not ESP32. Wrong --chip argument?
ERROR Please try running esptool.py --before default_reset --after hard_reset --baud 460800 --port /dev/ttyACM0 --chip esp32 write_flash -z --flash_size detect 0x10000 /data/build/atomlite/.pioenvs/atomlite/firmware.bin 0x1000 /data/build/atomlite/.pioenvs/atomlite/bootloader.bin 0x8000 /data/build/atomlite/.pioenvs/atomlite/partitions.bin 0x9000 /data/build/atomlite/.pioenvs/atomlite/ota_data_initial.bin locally.
INFO Upload with baud rate 460800 failed. Trying again with baud rate 115200.
esptool.py v4.7.0
Serial port /dev/ttyACM0
Connecting...
ERROR Running command failed: This chip is ESP32-S3 not ESP32. Wrong --chip argument?
ERROR Please try running esptool.py --before default_reset --after hard_reset --baud 115200 --port /dev/ttyACM0 --chip esp32 write_flash -z --flash_size detect 0x10000 /data/build/atomlite/.pioenvs/atomlite/firmware.bin 0x1000