Dienstag, 11. Juli 2023

Using the Arduino IDE to flash an ESP32 with a CP2102 serial adapter after you did not do that in a LONG time

Currently trying to run the openDTU project on one of my ESP32. But well, how to get it on there...

 

The programming command the openDTU docs state:

 

 esptool.py --port /dev/ttyUSB0 --chip esp32 --before default_reset --after hard_reset write_flash --flash_mode dout --flash_freq 40m --flash_size detect 0x0 opendtu-generic.factory.bin


Playing around with the ArduinoIDE this is one of the programming commands from the extended serial output there:


 
"C:\Users\user\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.5.1/esptool.exe" --chip esp32 --port "COM4" --baud 115200  --before default_reset --after hard_reset write_flash  -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 "C:\Users\user\AppData\Local\Temp\arduino\sketches\507DD89FBC5B73B753AA5D4AE9A38EF2/WiFiScan.ino.bootloader.bin" 0x8000 "C:\Users\user\AppData\Local\Temp\arduino\sketches\507DD89FBC5B73B753AA5D4AE9A38EF2/WiFiScan.ino.partitions.bin" 0xe000 "C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.9/tools/partitions/boot_app0.bin" 0x10000 "C:\Users\user\AppData\Local\Temp\arduino\sketches\507DD89FBC5B73B753AA5D4AE9A38EF2/WiFiScan.ino.bin"
esptool.py v4.5.1



The command I derived from the two above:


C:\Users\user\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.5.1/esptool.exe --chip esp32 --port "COM4" --before default_reset --after hard_reset write_flash --flash_mode dout --flash_freq 40m --flash_size detect 0x0 opendtu-generic.factory.bin

A successfull programming run looks like this. You still have to unplug and replug the CP2102 with the ESP32 attached while pressing the "right" button:


C:\Users\user\Downloads>C:\Users\user\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.5.1/esptool.exe --chip esp32 --port "COM4" --before default_reset --after hard_reset write_flash --flash_mode dout --flash_freq 40m --flash_size detect 0x0 opendtu-generic.factory.bin
esptool.py v4.5.1
Serial port COM4
Connecting....
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: cc:50:e3:8b:c9:18
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00000000 to 0x00186fff...
Compressed 1598240 bytes to 1022460...
Wrote 1598240 bytes (1022460 compressed) at 0x00000000 in 92.1 seconds (effective 138.8 kbit/s)...
Hash of data verified.

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

C:\Users\user\Downloads>