Help flashing ESP-01

#1

Hello all! I’m trying to flash an ESP-01 and having connection issues. To flash the board I’m using the MOS UI running on my Mac. If I try to flash the same program on a NodeMCU type board I have no problems. Below is the log from when I try to flash. Any advice would be great.

Loaded mongoose-os-apps-hello-world/esp8266 version 1.0 (20201030-011902)
Opening /dev/cu.usbserial-1420 @ 115200…
Connecting to ESP8266 ROM, attempt 1 of 10…
Connected, chip: ESP8266EX
Running flasher @ 921600…
E1029 21:19:32.044726 22515 common.go:73] failed to run flasher @ 921600, falling back to ROM baud rate…
Opening /dev/cu.usbserial-1420 @ 115200…
Connecting to ESP8266 ROM, attempt 1 of 10…
Connecting to ESP8266 ROM, attempt 2 of 10…
Connecting to ESP8266 ROM, attempt 3 of 10…
Connecting to ESP8266 ROM, attempt 4 of 10…
Connecting to ESP8266 ROM, attempt 5 of 10…
Connecting to ESP8266 ROM, attempt 6 of 10…
Connecting to ESP8266 ROM, attempt 7 of 10…
Connecting to ESP8266 ROM, attempt 8 of 10…
Connecting to ESP8266 ROM, attempt 9 of 10…
Connecting to ESP8266 ROM, attempt 10 of 10…
Error: /private/tmp/mos-20200820-97577-jfaujm/mos-1ec85951e77649f1151bc06a12901faa784a991a/cli/flash/esp/rom_client/rom_client.go:172: failed to connect to ESP8266 ROM
/private/tmp/mos-20200820-97577-jfaujm/mos-1ec85951e77649f1151bc06a12901faa784a991a/cli/flash/esp/rom_client/rom_client.go:124: failed to connect to ROM
/private/tmp/mos-20200820-97577-jfaujm/mos-1ec85951e77649f1151bc06a12901faa784a991a/cli/flash/esp/rom_client/rom_client.go:110: failed to create ROM client
/private/tmp/mos-20200820-97577-jfaujm/mos-1ec85951e77649f1151bc06a12901faa784a991a/cli/flash/esp/flasher/common.go:59: Failed to talk to bootloader.
See https://github.com/espressif/esptool/wiki/ESP8266-Boot-Mode-Selection
for wiring instructions or pull GPIO0 low and reset.
/private/tmp/mos-20200820-97577-jfaujm/mos-1ec85951e77649f1151bc06a12901faa784a991a/cli/flash/esp/flasher/flash.go:76:
/private/tmp/mos-20200820-97577-jfaujm/mos-1ec85951e77649f1151bc06a12901faa784a991a/cli/flash.go:231:
/private/tmp/mos-20200820-97577-jfaujm/mos-1ec85951e77649f1151bc06a12901faa784a991a/cli/main.go:198: flash failed
exit status 1
Command completed.

#2

To confirm that the hardware is working I just flashed the board using the same programmer from the Arduino IDE. This worked fine. I thought I should confirm that this was all working correctly.

#3

Well, what I see is that mos tool is not able to connect to your hardware.
If we assume your hardware is OK, then the problem can be your hardware not being supported or the serial port not being correctly specified.
The log has a link to a page specifying how to properly connect RTS and DTR pins in order to reset the chip and enter bootloader; I assume your hardware has that already solved for you.
Finally, the serial interface is usually guessed by mos tool unless you specify it via the --port parameter option (see mos docs). I don’t know about usual serial port names on a Mac, /dev/cu.usbserial-1420 may or may not be correct. If you just type mos alone, you should get a navigator window where you can manually choose a serial port (at least on Windoze and Linux), or perhaps check what serial name your Arduino IDE uses.

#4

The programmer I’m using has a small switch on it to handle how the pins need to be setup for programming vs running. This will take care of the wiring mention in the logs.

The logs also show the it does seem to connect and then disconnect which I find odd and cannot explain.

As for the port, I’m using the full UI opened after typing mos in a terminal and I’m using the port it shows.

I’ve also done a ls /dev in the terminal to confirm the port is correct.

For a final test I have downloaded ESPEasy and flashed it with the same programmer and board without any issues. I used the same port that was referred to in the Mongoose UI.

So at this point I’m stumped. The hardware is good. The ports and process I’m using are good. I can basically do the same thing in another firmware and I’ve seen this board flashed in a YouTube video.

I’m not sure what to try next? I’d really like to use this board with Mongoose because of it’s small foot print and power consumption.

#5

There is no indication that it seems to connect. It gives up after 10 attempts.
This is my log in Linux with an empty USB serial port:

$ mos flash
Loaded somecode/esp32 version 1.0 (20201030-230731)
Using port /dev/ttyUSB0
Opening /dev/ttyUSB0 @ 115200...
Connecting to ESP32 ROM, attempt 1 of 10...
Connecting to ESP32 ROM, attempt 2 of 10...
Connecting to ESP32 ROM, attempt 3 of 10...
Connecting to ESP32 ROM, attempt 4 of 10...
Connecting to ESP32 ROM, attempt 5 of 10...
Connecting to ESP32 ROM, attempt 6 of 10...
Connecting to ESP32 ROM, attempt 7 of 10...
Connecting to ESP32 ROM, attempt 8 of 10...
Connecting to ESP32 ROM, attempt 9 of 10...
Connecting to ESP32 ROM, attempt 10 of 10...
Error: /src/cli/flash/esp/rom_client/rom_client.go:172: failed to connect to ESP32 ROM
/src/cli/flash/esp/rom_client/rom_client.go:124: failed to connect to ROM
/src/cli/flash/esp/rom_client/rom_client.go:110: failed to create ROM client
/src/cli/flash/esp/flasher/common.go:59: Failed to talk to bootloader.
See https://github.com/espressif/esptool/wiki/ESP8266-Boot-Mode-Selection
for wiring instructions or pull GPIO0 low and reset.
/src/cli/flash/esp/flasher/flash.go:76: 
/src/cli/flash.go:231: 
/src/cli/main.go:198: flash failed
$ 

You should put an oscilloscope and see if RTS and DTR are moving, and if data comes out of TD.
Then you should confirm movement of RTS and DTR causes the microcontroller to reset… that is, it moves the proper pin (I don’t remember if the 8266 has a reset or an enable or both…) and puts GPIO0 low.
As GPIO0 is usually tied to a push button, you could get by with keeping the button pressed while manually forcing a reset by also pressing the reset button on your board or just keeping the button pressed while powering it up (connecting)(that is the way to reflash some ESP8266-based commercial products like Sonoff)

#6

i’m not sure of the reason, but I’ve also noticed some differences between flashing with other tools (eg Arduino) vs mos. The most annoying thing for me is flash speed. Arduino flashes fine at 921600 kbps but mos will fail back to 115200.

Few of things I’d check:

  1. Try all the different ports on the Mac. I’ve flashes successfully in the past with a macbook pro
  2. Flash something in arduino that writes out the serial port at 115200, then check the mos console. You should see the messages just as your would in arduino serial console
  3. Try another USB cable
#7

I thought this log entry would mean that it did connect?

Loaded mongoose-os-apps-hello-world/esp8266 version 1.0 (20201030-011902)
Opening /dev/cu.usbserial-1420 @ 115200…
Connecting to ESP8266 ROM, attempt 1 of 10…
Connected, chip: ESP8266EX
Running flasher @ 921600…
E1029 21:19:32.044726 22515 common.go:73] failed to run flasher @ 921600, falling back to ROM baud rate…
#8

Looks like you are right… then the serial port is the right one, sorry I missed that.
Since it is performing a fallback I would guess that your serial can’t support that speed (921600).
Since it is not connecting again I would guess that your hardware is not resetting again. You could then try the manual reset during the 115200 phase as I suggested. earlier.