Page 1 of 1

ESPtool not releasing serial port

Posted: Wed Jun 08, 2022 2:52 pm
by PM-TPI
Flash with ESPtool no problem but mpremote won't run...
if I comment out ESPtool then mpremote runs fine.

ESPtool hangs on to COM Port , how to release ?

Code: Select all

import esptool, subprocess

print('mimic Flash')
arg1 = ['--port', 'COM13', 'flash_id']
esptool.main(arg1)

print('copy files')
arg2 = 'mpremote connect COM13 cp assets/boot.py assets/main.py :'
sub = subprocess.Popen(arg2, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

Close serial port before exit from main() #316
From <https://github.com/espressif/esptool/pull/316>

Release COM port when flash process is finished #37
From <https://github.com/marcelstoer/nodemcu- ... /issues/37>

Why is the serial port still open when killing a subprocess?
From <https://stackoverflow.com/questions/702 ... subprocess>

Updated from 3.1 to...
esptool.py v4.1 - Espressif chips ROM Bootloader Utility

no change