-->
Page 1 of 1

esptool fails with SerialTimeoutException

PostPosted: Fri Dec 03, 2021 10:44 am
by BillAnderson
I have been working on a project that involves controlling a 4 channel relay using micropython on a esp8266 nodeMCU board. I have been using esptool to flash the latest micropython firmware bin file to the board. Everything went well at first, and I continued to upload my code file to the board. Things started going sideways on me at that point. I issue had to do with the com3 port being busy. So, I again used esptool to erase the original flash, and then reflash the board. But this time I received a serial timeout exception several seconds after esptool started to write to the board. I tried again with two other identical (and brand new) boards, but I still get the same error every time. Below is the esptool output starting from the command line arguments.

(base) PS C:\development\python> esptool --port com3 --baud 9600 write_flash --flash_size detect --flash_mode dio -z 0x0000 esp8266-20210902-v1.17.bin
esptool.py v3.2
Serial port com3
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.
.
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.
.
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 44:17:93:0d:50:04
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00000000 to 0x0009afff...
Flash params set to 0x0240
Compressed 633688 bytes to 416263...
Writing at 0x00000000... (3 %)Traceback (most recent call last):
File "c:\users\billa\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\billa\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\billa\Anaconda3\Scripts\esptool.exe\__main__.py", line 7, in <module>
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 5136, in _main
main()
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 4602, in main
operation_func(esp, args)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 3873, in write_flash
esp.flash_defl_block(block, seq, timeout=timeout)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 154, in inner
return func(*args, **kwargs)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 919, in flash_defl_block
self.ESP_FLASH_DEFL_DATA, struct.pack('<IIII', len(data), seq, 0, 0) + data, self.checksum(data), timeout=timeout)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 495, in check_command
val, data = self.command(op, data, chk, timeout=timeout)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 458, in command
self.write(pkt)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 421, in write
self._port.write(buf)
File "c:\users\billa\anaconda3\lib\site-packages\serial\serialwin32.py", line 323, in write
raise writeTimeoutError
serial.serialutil.SerialTimeoutException: Write timeout
(base) PS C:\development\python> esptool --port com3 --baud 9600 erase_flash
esptool.py v3.2
Serial port com3
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.
.
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.
.
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 44:17:93:0e:3f:ce
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 4.7s
Hard resetting via RTS pin...
(base) PS C:\development\python> esptool --port com3 --baud 9600 write_flash --flash_size detect --flash_mode dio -z 0x0000 esp8266-20210902-v1.17.bin
esptool.py v3.2
Serial port com3
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.
.
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.
.
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 44:17:93:0e:3f:ce
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00000000 to 0x0009afff...
Flash params set to 0x0240
Compressed 633688 bytes to 416263...
Writing at 0x00000000... (3 %)Traceback (most recent call last):
File "c:\users\billa\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\billa\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\billa\Anaconda3\Scripts\esptool.exe\__main__.py", line 7, in <module>
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 5136, in _main
main()
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 4602, in main
operation_func(esp, args)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 3873, in write_flash
esp.flash_defl_block(block, seq, timeout=timeout)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 154, in inner
return func(*args, **kwargs)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 919, in flash_defl_block
self.ESP_FLASH_DEFL_DATA, struct.pack('<IIII', len(data), seq, 0, 0) + data, self.checksum(data), timeout=timeout)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 495, in check_command
val, data = self.command(op, data, chk, timeout=timeout)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 458, in command
self.write(pkt)
File "c:\users\billa\anaconda3\lib\site-packages\esptool.py", line 421, in write
self._port.write(buf)
File "c:\users\billa\anaconda3\lib\site-packages\serial\serialwin32.py", line 323, in write
raise writeTimeoutError
serial.serialutil.SerialTimeoutException: Write timeout
(base) PS C:\development\python>

I have re-downloaded the firmware bin file just incase it had become corrupt somehow. I also attempted the same process on three different esp8266nodeMCU boards, and a RPI Pico. But I get the same result. I have also tried rebooting windows, switching usb cables, and trippel verified the com port is correct, and working OK.

I also ran esptool with the --trace option and pipped it to a file. Nothing in the file jumps out at me as a clue.

Thanks,
Bill

Re: esptool fails with SerialTimeoutException

PostPosted: Fri Dec 10, 2021 7:34 am
by rpiloverbd
Hello, does this problem only occur when you try to upload your 4-channel relay controlling code? Or it occurs every time? Even when you try to blink an LED?