Page 1 of 1

How to use ESPTool to setup ESP32 chip from fresh

Posted: Tue Oct 27, 2020 1:29 am
by zjustin
Hi Gurus

right now, I am using Arduino to do the first time flash of the ESP32 chip on my board.
after that, all future flashing of my own firmware, I am using Esptool directly to do the work (I am on a Mac)

esptool.py --port /dev/cu.usbserial-AC01WJQX -b 921600 write_flash 0x10000 ./my_firmware.bin


However, if I have a brand new ESP chip, and if I do the Esptool flashing directly, the chip won't even run the firmware at all. I figure that, arduino does some magic when I use it to do the firs time flashing. Since Arduino is using Esptool underlying to flash ESP32 too. it must have run some command with Esptool to configure/format the ESP32.

Now, question, how do I using Esptool on command line directly to configure/format ESP32, then flash my own proper firmware ?

below are actually the output in the arduino app, I can see Arduino seems using Esptool to flash location: 0x0000e000 first with some stub.. or boot loader?

Code: Select all

esptool.py v2.6
Serial port /dev/cu.usbserial-AC01WJQX
Connecting........_
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
MAC: d8:a0:1d:51:5f:c8
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...

Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 4160.5 kbit/s)...
Hash of data verified.
Compressed 15856 bytes to 10276...

Writing at 0x00001000... (100 %)
Wrote 15856 bytes (10276 compressed) at 0x00001000 in 0.1 seconds (effective 997.0 kbit/s)...
Hash of data verified.
Compressed 208592 bytes to 105371...

Writing at 0x00010000... (14 %)
Writing at 0x00014000... (28 %)
Writing at 0x00018000... (42 %)
..
below are the configuration on my Arduino IDE for the ESP chip I am using.
Board: esp32 pico kit
upload speed: 921600
partition scheme: minimum spiffs (large OTA)
core debug level: debug.

Re: How to use ESPTool to setup ESP32 chip from fresh

Posted: Tue Oct 27, 2020 4:31 am
by ESP_Sprite
There indeed is a bootloader and a partition table binary that Arduino also flashes and that you need in your ESP32 for it to start correctly. Unfortunately I don't know enough about Arduino to tell you where you might find those.

Re: How to use ESPTool to setup ESP32 chip from fresh

Posted: Wed Oct 28, 2020 4:38 am
by zjustin
I found them guided by a friend , if you just enable verbose output in the Arduino IDE, it will print out the esptool command it used to do everything