This is an issue when working with some devices which cannot self-reset successfully (e.g. Sonoff Touch switches). After each operation (original firmware backup, erase, flash), the device needs to be manually reset by power-cycling and bringing GPI00 to GND on boot. It is generally not possible to do while tasmotizer (underlying esptool) waits for connection, the timeout is not long enough and the app crashes instead of handling that gracefully. Also, if it involves power-cycling the usb dongle, the device gets destroyed/recreated and the app crashes again.
$ tasmotizer.py
esptool.py v2.8
Serial port /dev/tty.usbserial-1412210
Connecting....
Chip is ESP8285
Features: WiFi, Embedded Flash
Crystal is 26MHz
MAC: 2c:f4:32:aa:7d:57
Uploading stub...
Running stub...
Stub running...
Read 1048576 bytes at 0x0 in 95.7 seconds (87.7 kbit/s)...
Hard resetting via RTS pin...
esptool.py v2.8
Serial port /dev/tty.usbserial-1412210
Connecting........_____
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/serial/serialposix.py", line 493, in read
buf = os.read(self.fd, size - len(read))
OSError: [Errno 6] Device not configured
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/esptool.py", line 378, in command
p = self.read()
File "/usr/local/lib/python3.7/site-packages/esptool.py", line 323, in read
return next(self._slip_reader)
File "/usr/local/lib/python3.7/site-packages/esptool.py", line 2072, in slip_reader
read_bytes = port.read(1 if waiting == 0 else waiting)
File "/usr/local/lib/python3.7/site-packages/serial/serialposix.py", line 509, in read
raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: [Errno 6] Device not configured
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/serial/serialposix.py", line 323, in _reconfigure_port
orig_attr = termios.tcgetattr(self.fd)
termios.error: (6, 'Device not configured')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/tasmotizer.py", line 86, in execute
esptool.main(command)
File "/usr/local/lib/python3.7/site-packages/esptool.py", line 2931, in main
esp.connect(args.before)
File "/usr/local/lib/python3.7/site-packages/esptool.py", line 506, in connect
last_error = self._connect_attempt(mode=mode, esp32r0_delay=False)
File "/usr/local/lib/python3.7/site-packages/esptool.py", line 486, in _connect_attempt
self.sync()
File "/usr/local/lib/python3.7/site-packages/esptool.py", line 427, in sync
self.command()
File "/usr/local/lib/python3.7/site-packages/esptool.py", line 389, in command
self._port.timeout = saved_timeout
File "/usr/local/lib/python3.7/site-packages/serial/serialutil.py", line 368, in timeout
self._reconfigure_port()
File "/usr/local/lib/python3.7/site-packages/serial/serialposix.py", line 326, in _reconfigure_port
raise SerialException("Could not configure port: {}".format(msg))
serial.serialutil.SerialException: Could not configure port: (6, 'Device not configured')
Abort trap: 6
Also, at least on mac os, all tasmotizer exceptions are critical and bring up big system stack trace report windows, maybe it doesn't have to be so severe? Looks like this:
I'm not entirely sure it is possible, but an option to wait between operations (so that any manual connection/resets could be done) could solve this.