How to reset cycled ESP32? "Device or recource busy"...

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
propeller
Posts: 9
Joined: Thu Jun 04, 2020 2:52 am

How to reset cycled ESP32? "Device or recource busy"...

Post by propeller » Mon Aug 24, 2020 5:44 am

I was make mistake while programs ESP32 and now it cycles with no point to stop. Esptool and picocom says "Device or resource busy" and connection fails. Is it possible to reset it or fully erase flash in this case?

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

Re: How to reset cycled ESP32? "Device or recource busy"...

Post by Roberthh » Mon Aug 24, 2020 6:00 am

you can always use esptool.py to erase the flash.

esptool.py -p <port name> erase_flash

propeller
Posts: 9
Joined: Thu Jun 04, 2020 2:52 am

Re: How to reset cycled ESP32? "Device or recource busy"...

Post by propeller » Mon Aug 24, 2020 6:53 am

Code: Select all

vitaly@L521X:~$ esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py v2.8
Serial port /dev/ttyUSB0
Traceback (most recent call last):
  File "/usr/local/bin/esptool.py", line 3201, in <module>
    _main()
  File "/usr/local/bin/esptool.py", line 3194, in _main
    main()
  File "/usr/local/bin/esptool.py", line 2883, in main
    esp = ESPLoader.detect_chip(each_port, initial_baud, args.before, args.trace)
  File "/usr/local/bin/esptool.py", line 273, in detect_chip
    detect_port = ESPLoader(port, baud, trace_enabled=trace_enabled)
  File "/usr/local/bin/esptool.py", line 237, in __init__
    self._port = serial.serial_for_url(port)
  File "/home/vitaly/.local/lib/python2.7/site-packages/serial/__init__.py", line 88, in serial_for_url
    instance.open()
  File "/home/vitaly/.local/lib/python2.7/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0'
Tried. No luck.

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

Re: How to reset cycled ESP32? "Device or recource busy"...

Post by Roberthh » Mon Aug 24, 2020 7:03 am

You have to terminate all other programs which use that port. Eventually you have to restart you PC. And you could try to run that esptool.py command with sudo.

propeller
Posts: 9
Joined: Thu Jun 04, 2020 2:52 am

Re: How to reset cycled ESP32? "Device or recource busy"...

Post by propeller » Mon Aug 24, 2020 7:35 am

Oh, God! You're my savior! Thank you, it works!

simonW
Posts: 2
Joined: Sun Oct 10, 2021 3:03 pm

Re: How to reset cycled ESP32? "Device or recource busy"...

Post by simonW » Sun Oct 10, 2021 3:12 pm

Hi,
lets see if someone is answering after that long time.

I'm working with a es32 in thonny. when i upload the main.py i cant change it again. i must reflash the µP firmware. now i tried the "esptool.py -p <port name> erase_flash" command. now the esp is stuck in a restart-loop. i tried to flash the firmware with thonny again. now the REPL shows the following "error"

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:5656
load:0x40078000,len:13136
load:0x40080400,len:4356
entry 0x400806b0
E (682) psram: PSRAM ID read error: 0xffffffff
E (682) spiram: SPI RAM enabled but initialization failed. Bailing out.
E (683) spiram: SPI RAM not initialized
Re-enable cpu cache.

abort() was called at PC 0x400d48be on core 0

Backtrace:0x40094ec5:0x3ffe3b60 0x400954b5:0x3ffe3b80 0x400991a1:0x3ffe3ba0 0x400d48be:0x3ffe3c10 0x400d490f:0x3ffe3c30 0x40082856:0x3ffe3c50 0x40082037:0x3ffe3c70 0x40078fd0:0x3ffe3c90 |<-CORRUPTED


ELF file SHA256: b804787c441836c4


any ideas why?
THANK YOU!

divekr
Posts: 6
Joined: Tue Oct 05, 2021 8:02 am

Re: How to reset cycled ESP32? "Device or recource busy"...

Post by divekr » Sun Oct 10, 2021 5:36 pm

I think your ESP32 does not have PSRAM, and
flashed wrong type of firmware(GENERIC_SPIRAM)
Try the firmware, BOARD=GENERIC compile option, and flash it.

simonW
Posts: 2
Joined: Sun Oct 10, 2021 3:03 pm

Re: How to reset cycled ESP32? "Device or recource busy"...

Post by simonW » Sun Oct 10, 2021 9:34 pm

Yeah, thats it.
Thank you!
Do you have any idea, how i can stop the ESP32 (with main.py saved in it) so i can save a new code-file in it? the only solution, i found, is to reflash the µP firmware..
(at my other esp32 board it works if i press RUN->disconnect->START/STOP, on that board it doesnt)
Thanks again :)

Post Reply