ESP-01 vs ESP-01S LED Flashing Issue

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
MMliam
Posts: 121
Joined: Mon May 07, 2018 1:08 pm

ESP-01 vs ESP-01S LED Flashing Issue

Post by MMliam » Thu Jul 14, 2022 3:09 pm

I've discovered an issue when flashing the LED on an ESP-01 vs an ESP-01S.
ESP-01: LED is connected to pin-1 (Tx).
ESP-01S: LED is connected to pin-2 (GPIO2).
Both the ESP-01 & ESP-01S have 1M flash-memory.
Using Thonny-IDE

Flashing the LED on an ESP-01S functions as expected; no issues.
However, running the same code on the ESP-01 (correcting for the pin difference) apparently affects the ability to return to REPL.
Used a simple code example in the ESP-01, to confirmed the issue.
Here's the simple code example:

Code: Select all

ledObj = Pin(1, Pin.OUT)
offState = 1
onState = 0
ledObj.value(offState)
TFlash = 0.3

while True:
    ledObj.value(onState)
    sleep(TFlash)
    ledObj.value(offState)
    sleep(TFlash)
After Reset-Boot the LED flashes, however, on "Interrupt execution" the flashing stops, but no REPL.
Trying "Stop/Restart backend" result in:
Device is busy or does not respond. Your options:

- wait until it completes current work;
- use Ctrl+C to interrupt current work;
- use Stop/Restart to interrupt more and enter REPL.
Rebooting LED starts flashing again; executing "Stop/Restart backend", stops LED, but no REPL.

Trying "Send EOF / Soft reboot" restarts the LED flashing, but again no means to stop, or interrupt returns REPL.
Any attempt to modify and load new code results in Thonny error saying the device is busy.

The only way to get back the REPL is to re-flash micropython v1.18.

Any thoughts as to what causing the issue?

Mike

MMliam
Posts: 121
Joined: Mon May 07, 2018 1:08 pm

Re: ESP-01 vs ESP-01S LED Flashing Issue

Post by MMliam » Fri Jul 15, 2022 1:32 am

I believe I know why the ESP-01 loses REPL after LED flashing.

Thanks Mike

krishnak
Posts: 3
Joined: Wed Aug 24, 2022 5:22 pm

Re: ESP-01 vs ESP-01S LED Flashing Issue

Post by krishnak » Wed Aug 24, 2022 5:31 pm

Hello

Can you please explain what is causing this, I am exactly stuck at this issue and I have spent a whole day unsuccessfully trying to resolve it .

I believe I am having ESP01s as the esptool.py tool prints the board as having 1MB flash, I flashed the micropython code

Code: Select all

$ esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x000000  esp8266-1m-20220618-v1.19.1.bin 
esptool.py v4.2.1
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 48:55:19:16:2f:1d
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00090fff...
Compressed 591476 bytes to 392426...
Wrote 591476 bytes (392426 compressed) at 0x00000000 in 9.6 seconds (effective 492.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin.
After this when I use thony or even putty (it kind of prints garbage with putty, it prints the following when connected with thony

Device is busy or does not respond. Your options:

- wait until it completes current work;
- use Ctrl+C to interrupt current work;
- use Stop/Restart to interrupt more and enter REPL.


Connection lost (device reports readiness to read but returned no data (device disconnected or multiple access on port?))

Use Stop/Restart to reconnect.

I am using a nodemcu as the USB to serial converter by following this
https://www.youtube.com/watch?v=zwp9E37ioVw

I have tried connecting the RESET pin to GND after the firmware has flashed but nothing works to get Micropython REPL.

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

Re: ESP-01 vs ESP-01S LED Flashing Issue

Post by Roberthh » Wed Aug 24, 2022 6:22 pm

Try to work with Putty first. Putty#s flow control setting must be 'None'.
The garbage at boot is normal, since the ESP8266 firmware starts with 74600 baud and switches later to 115200 baud.
The ESP01 flash size must match the firmware. The standard firmware requires at least 2 MB flash. If your device has less flash, then you have to use the matching firmware files, which are available for 512kB and 1MB boards.

krishnak
Posts: 3
Joined: Wed Aug 24, 2022 5:22 pm

Re: ESP-01 vs ESP-01S LED Flashing Issue

Post by krishnak » Thu Aug 25, 2022 12:13 am

Thanks for trying to help, all those have been done correctly - correct firmware etc. This is a specific issue with ESP01/ESP01s -as per the original thread.

I have micropython working on ESP8266 with 4MB flash on NodeMCU and also on Weimos D1 mini.

krishnak
Posts: 3
Joined: Wed Aug 24, 2022 5:22 pm

Re: ESP-01 vs ESP-01S LED Flashing Issue

Post by krishnak » Thu Aug 25, 2022 5:22 am

I figured out using picom by reducing the baud rate that it is a classic checksum error encountered by many. But why does it occur. The answer is pretty silly read below

Code: Select all

 picocom -b 74800 /dev/ttyUSB0
picocom v3.1

port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 74800
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 30720, room 16 
tail 0
chksum 0xef
load 0x00000000, len 0, room 8 
tail 0
chksum 0xef
load 0x00000000, len 0, room 0 
tail 0
chksum 0xef
csum 0xef
csum err
ets_main.c 
OK after wasting around 24 hours to resolve this, I figured out that I was flashing without --flash_mode=dout <--- this is important for ESP01

leaving out flash_mode for NodeMCU or Weimos D1 doesn't give this error, this is ESP01 specific.

The correct command is
esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_mode dout --flash_size=detect 0 esp8266-1m-20220618-v1.19.1.bin

This works!!!

domisol
Posts: 6
Joined: Mon Aug 02, 2021 7:46 am

Re: ESP-01 vs ESP-01S LED Flashing Issue

Post by domisol » Thu Jan 05, 2023 11:32 am

Thanks a lot!!!! You save my day (my night in this case). :-)

Post Reply