Wemos D1 mini boot.py bricked (ESP8266)

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
nissene99
Posts: 5
Joined: Sun Apr 25, 2021 12:47 pm

Wemos D1 mini boot.py bricked (ESP8266)

Post by nissene99 » Sun Apr 25, 2021 12:59 pm

Since I accidentally have an error in my boot.py, the ESP8266 does not boot anymore. I already tried to reset it via pin D3 -> GND, D8 -> GND or D4 -> 3.3V, but it didn't work. Therefore the ESP is not recognized when connecting to the PC. Neither from Linux nor from Windows.

boot.py:

Code: Select all

#import esp
#esp.osdebug(None)
import uos, machine, gc, webrepl
try:
    import usocket as socket
except:
    import socket
try:
    import ustruct as struct
except:
    import struct
NTP_DELTA = 3155673600
host = "pool.ntp.org"
#uos.dupterm(None, 1) # disable REPL on UART(0)
webrepl.start()
gc.collect()

def time():
    NTP_QUERY = bytearray(48)
    NTP_QUERY[0] = 0x1B
    addr = socket.getaddrinfo(host, 123)[0][-1]
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        s.settimeout(1)
        res = s.sendto(NTP_QUERY, addr)
        msg = s.recv(48)
    finally:
        s.close()
    val = struct.unpack("!I", msg[40:44])[0]
    return val - NTP_DELTA
def settime():
    t = time()
    import machine, utime
    tm = utime.localtime(t)
    machine.RTC().datetime((tm[0], tm[1], tm[2], tm[6] + 1, tm[3], tm[4], tm[5], 0))
    print("Date\t",tm[2],".",tm[1],".",tm[0]"\n\nTime:\t", tm[6] + 1,":",tm[3])

def connect_wifi():
    import network
    ap = network.WLAN(network.AP_IF)
    sta = network.WLAN(network.STA_IF)
    ap.active(False)
    if not sta.isconnected():
        sta.active(True)
        sta.connect('#####','#####')
        while not sta.isconnected():
            pass
    else:
        settime()
        pass
    sta.ifconfig(('192.168.188.18', '255.255.255.0', '192.168.188.1', '192.168.188.1'))
connect_wifi()

Is there a way to clear the memory of the ESP manually or another way to overwrite the firmware?

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

Re: Wemos D1 mini boot.py bricked (ESP8266)

Post by Roberthh » Sun Apr 25, 2021 1:29 pm

You can clear the memory using esptool.py and the option erase_flash:

python3 esptool.py -p <uart_port_name> erase_flash

or with the Makefile from the repository, calling

make erase

which in turn calls esptool.py. Then you can start over by uploading the firmware and setting up the file system#s content.
But in any case, the esp's UART should be detected.

nissene99
Posts: 5
Joined: Sun Apr 25, 2021 12:47 pm

Re: Wemos D1 mini boot.py bricked (ESP8266)

Post by nissene99 » Sun Apr 25, 2021 2:27 pm

Roberthh wrote:
Sun Apr 25, 2021 1:29 pm
You can clear the memory using esptool.py and the option erase_flash:

python3 esptool.py -p <uart_port_name> erase_flash

or with the Makefile from the repository, calling

make erase

which in turn calls esptool.py. Then you can start over by uploading the firmware and setting up the file system#s content.
But in any case, the esp's UART should be detected.
I tried, but the device is not recognized by the system. (No uart_port_name is found)

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

Re: Wemos D1 mini boot.py bricked (ESP8266)

Post by Roberthh » Sun Apr 25, 2021 2:56 pm

That's bad. There are a few options:

a) The USB cable broke. Try another cable
b) The device switched to another COM port. Did you look into the device manager, if there are any changes when you plug and unplug the board?
c) Try anther USB port on the PC
d) reboot the PC (unlikely to help, but ....)

Since the Wemos D1 Mini USB is provided by the separate CH340G chip, the state of the ESP8266 does not affect the visibility by the PC. Only hard fails of the board or the connection can stop that. If there was a short in the USB power section, the PC may disable that port temporarily. A re-boot helps in that case.

nissene99
Posts: 5
Joined: Sun Apr 25, 2021 12:47 pm

Re: Wemos D1 mini boot.py bricked (ESP8266)

Post by nissene99 » Sun Apr 25, 2021 4:28 pm

Roberthh wrote:
Sun Apr 25, 2021 2:56 pm
That's bad. There are a few options:

a) The USB cable broke. Try another cable
b) The device switched to another COM port. Did you look into the device manager, if there are any changes when you plug and unplug the board?
c) Try anther USB port on the PC
d) reboot the PC (unlikely to help, but ....)

Since the Wemos D1 Mini USB is provided by the separate CH340G chip, the state of the ESP8266 does not affect the visibility by the PC. Only hard fails of the board or the connection can stop that. If there was a short in the USB power section, the PC may disable that port temporarily. A re-boot helps in that case.
a) I have already tried various cables.
b) I searched for the ESP in the device manager, but it is not listed.
c) I have now also tried every USB port, with the same result.
d) Unfortunately did not help.

Apparently I either completely destroyed the ESP and have to get a new one or I'm out of luck. :lol:

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

Re: Wemos D1 mini boot.py bricked (ESP8266)

Post by Roberthh » Sun Apr 25, 2021 4:39 pm

Yup. If it does not turn up as USB device, there is little you can do with software. So it looks like a hardware fault. The Wemos D1 Mini is generally pretty robust. You definitely cannot break it with wrong code. But that does not mean it cannot break. Checking the USB connector on the board is may be out of your reach. If you have a USB current monitor, can you check it if consumes current? Otherwise getting a new one is mostly a time constraint, not so much a matter of costs.

nissene99
Posts: 5
Joined: Sun Apr 25, 2021 12:47 pm

Re: Wemos D1 mini boot.py bricked (ESP8266)

Post by nissene99 » Sun Apr 25, 2021 4:42 pm

Roberthh wrote:
Sun Apr 25, 2021 4:39 pm
Yup. If it does not turn up as USB device, there is little you can do with software. So it looks like a hardware fault. The Wemos D1 Mini is generally pretty robust. You definitely cannot break it with wrong code. But that does not mean it cannot break. Checking the USB connector on the board is may be out of your reach. If you have a USB current monitor, can you check it if consumes current? Otherwise getting a new one is mostly a time constraint, not so much a matter of costs.
When I press the reset button on the ESP, the LED flashes briefly. From this I conclude that it is still working.

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

Re: Wemos D1 mini boot.py bricked (ESP8266)

Post by Roberthh » Sun Apr 25, 2021 5:13 pm

Does the device manager show some unknown devices? In that case re-installing the ch340 device driver could help.

nissene99
Posts: 5
Joined: Sun Apr 25, 2021 12:47 pm

Re: Wemos D1 mini boot.py bricked (ESP8266)

Post by nissene99 » Sun Apr 25, 2021 6:11 pm

Roberthh wrote:
Sun Apr 25, 2021 5:13 pm
Does the device manager show some unknown devices? In that case re-installing the ch340 device driver could help.
Did not find any unknown devices.

SuMeRbOaRd
Posts: 1
Joined: Tue Oct 05, 2021 4:12 pm

Re: Wemos D1 mini boot.py bricked (ESP8266)

Post by SuMeRbOaRd » Tue Oct 05, 2021 4:16 pm

Roberthh wrote:
Sun Apr 25, 2021 4:39 pm
Yup. If it does not turn up as USB device, there is little you can do with software. So it looks like a hardware fault. The Wemos D1 Mini is generally pretty robust. You definitely cannot break it with wrong code. But that does not mean it cannot break. Checking the USB connector on the board is may be out of your reach. If you have a USB current monitor, can you check it if consumes current? Otherwise getting a new one is mostly a time constraint, not so much a matter of costs.
Looking for some help here too, I have a board that shows no LEDs anymore for some reason but it does show up as a USB device with no errors, I just can't seem to program anything to it. Any help? Wemos D1 R2... LEDs were working until I think I put a CNC Shield on it, I thought it was just not enough power but seems like I potentially killed it?

Post Reply