Can't flash an ESP32-S2

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Can't flash an ESP32-S2

Post by pythoncoder » Sat Mar 12, 2022 4:45 pm

I have an Espressif development board as per https://docs.espressif.com/projects/esp ... -1-v1.html (the version with the PCB antenna).

I erased flash and loaded https://micropython.org/resources/firmw ... -v1.18.bin which appeared to proceed normally. Unfortunately I can't get a REPL. If I connect with a terminal and press reset, this is the outcome:

Code: Select all

$ mtusb
--- Miniterm on /dev/ttyUSB0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0xe70
load:0x4004c000,len:0x8ac
load:0x40050000,len:0x2a78
entry 0x4004c190
I repeated the erase/flash sequence with the latest daily build with the same outcome.
Here is the output from esptool.py

Code: Select all

$ esptool.py --chip esp32s2 --port /dev/ttyUSB0 write_flash -z 0x1000 GENERIC_S2-20220312-unstable-v1.18-212-geec07332b.bin 
esptool.py v3.3-dev
Serial port /dev/ttyUSB0
Connecting......
Chip is ESP32-S2FNR2
Features: WiFi, Embedded Flash 4MB, Embedded PSRAM 2MB, ADC and temperature sensor calibration in BLK2 of efuse V1
Crystal is 40MHz
MAC: 7c:df:a1:94:a7:c4
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00001000 to 0x0012bfff...
Compressed 1222880 bytes to 806262...
Wrote 1222880 bytes (806262 compressed) at 0x00001000 in 71.3 seconds (effective 137.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
[adminpete@capybara]: ~/Downloads
Any thoughts?
Peter Hinch
Index to my micropython libraries.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Can't flash an ESP32-S2

Post by Roberthh » Sun Mar 13, 2022 7:15 am

is that a genuine espressif board? are the two transistors for mode switch assembled on the board? Is there eventually a REPL prompt on the serial interface?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Can't flash an ESP32-S2

Post by pythoncoder » Sun Mar 13, 2022 5:40 pm

I believe it is genuine. It came from a reputable supplier, has the Espressif logo and has very high quality silk screening on a black PCB. There are two transistors on the board. Note that firmware loading and hash checking were OK, but no REPL even after a hard reset.
Peter Hinch
Index to my micropython libraries.

ash10
Posts: 11
Joined: Tue Mar 08, 2022 1:43 pm

Re: Can't flash an ESP32-S2

Post by ash10 » Mon Mar 14, 2022 9:22 am

I also had this problem, the REPL becomes available on the USB-OTG port after flashing.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Can't flash an ESP32-S2

Post by pythoncoder » Mon Mar 14, 2022 11:23 am

How can I access the USB-OTG port? I can't see a reference to it in the module data.
Peter Hinch
Index to my micropython libraries.

ash10
Posts: 11
Joined: Tue Mar 08, 2022 1:43 pm

Re: Can't flash an ESP32-S2

Post by ash10 » Mon Mar 14, 2022 11:48 am

It's GPIO 19 (USB_D+) and 20(USB_D-), those are the pins that I have used on a board in development, which work.

Have a look at the ESP32-S2-MINI-1 & ESP32-S2-MINI-1U Datasheet in section 6, the schematic shows the OTG port connected to GPIO19 and 20.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Can't flash an ESP32-S2

Post by pythoncoder » Tue Mar 15, 2022 9:07 am

If you look at the schematics for my Espressif board https://dl.espressif.com/dl/schematics/ ... matics.pdf it seems that these pins are brought out to the USB connector. So I'm puzzled why I'm not getting a REPL.
Peter Hinch
Index to my micropython libraries.

ash10
Posts: 11
Joined: Tue Mar 08, 2022 1:43 pm

Re: Can't flash an ESP32-S2

Post by ash10 » Tue Mar 15, 2022 10:35 am

I think the problem is that GPIO19 and 20 are not connected to the micro USB port because R2, R3, C4 and C5 are not populated.

I think that the USB bridge is communicating the on USB_DP and USB_DN lines and the USB-OTG is communicating on GPIO 19 and 20.

If this is the case then I think the fix would be to remove R1 and R4, which would disconnect the USB bridge from the micro-USB port. Solder on R2, R3, C4 and C5 and you should be able to access the USB-OTG port via the micro-USB port and see the REPL.

Or you could connect pins 19 and 20 on the dev boards J3 header to D- and D+ on a USB breakout board and Vbus to the 5V (J1 header pin 20) and ground and that should also work.

I think the confusion may be arising from the naming conventions on the schematic and the datasheet. USB_DN and GPIO 19 on the schematic are not the same but on the datasheet GPIO19 and USB_D- are the same. Likewise with USB_DP and GPIO20 on the schematic and GPIO20 and USB_D+ in the datasheet.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Can't flash an ESP32-S2

Post by pythoncoder » Tue Mar 15, 2022 1:29 pm

Thanks for that - it makes sense. The breakout seems the more practical option. But...

It does seem to imply a firmware bug. Surely the REPL should be emitted from the same port as is used for firmware loading (and for the initial messages which appear after a hard reset)? I'm puzzled how anyone is using this firmware on a commercially available board.

If you agree, one of us should raise a ticket.
Peter Hinch
Index to my micropython libraries.

ash10
Posts: 11
Joined: Tue Mar 08, 2022 1:43 pm

Re: Can't flash an ESP32-S2

Post by ash10 » Tue Mar 15, 2022 2:07 pm

I definitely agree, like you said, you would expect the REPL to appear on the same interface you flashed on or at least an indicator of where it has moved to.

Made me question a few life choices :lol:

If you could raise a ticket please, that would be great!
I think you carry more sway :)

Post Reply