D1 mini32 boot loop after first flash

Hi, trying to flash a D1 mini32 V1.0.0 (probably clone) via USB the first time.

I used the config

esphome:
  name: atc_002

esp32:
  board: wemos_d1_mini32
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  password: ""

wifi:
  ssid: "b9svc"
  password: "***"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Atc 002 Fallback Hotspot"
    password: "***"

flashed it with:

/venv/bin/esptool.py -b 115200 -p /dev/ttyACM0 write_flash 0x00000 ./var/firmware.bin
esptool.py v4.6.2
Serial port /dev/ttyACM0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting.....
Detecting chip type... ESP32
Chip is ESP32-D0WD (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 78:21:84:33:73:bc
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x000c0fff...
Compressed 787792 bytes to 515475...
Wrote 787792 bytes (515475 compressed) at 0x00000000 in 45.1 seconds (effective 139.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

But it does not work, the serial log outputs:

./venv/bin/pyserial-miniterm /dev/ttyACM0 115200
--- Miniterm on /dev/ttyACM0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

What’s wrong?

Why would esptool.py erase only ~800kB of flash.

What is the flash size of ESP32? (run esptool.py flash_id)

Why are you using esptool?

./venv/bin/esptool.py -b 115200 -p /dev/ttyACM0 flash_id
esptool.py v4.6.2
Serial port /dev/ttyACM0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting.....
Detecting chip type... ESP32
Chip is ESP32-D0WD (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 78:21:84:33:73:bc
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin..

It has a 4MB flash. Tried to flash a blank_4mb.bin then the firmware again (which is ~780K), still get that same boot loop.

Well it was handy and the esphome-flasher repo is archived…

Any way, using esphome-flasher did the job. It apparently uses esptool, but does something differently.

thanks for the hint

ohh did not notice that esphome run can write via SUB serial… turns out I had a broken USB cable at first