Commit 8394333c authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Pull in upstream fixes for getting board into flash mode.

parent 125d2173
...@@ -128,30 +128,20 @@ class ESPROM: ...@@ -128,30 +128,20 @@ class ESPROM:
def connect(self): def connect(self):
print 'Connecting...' print 'Connecting...'
# RTS = CH_PD (i.e reset) for _ in xrange(4):
# DTR = GPIO0 # issue reset-to-bootloader:
# self._port.setRTS(True) # RTS = either CH_PD or nRESET (both active low = chip in reset)
# self._port.setDTR(True) # DTR = GPIO0 (active low = boot to flasher)
# self._port.setRTS(False)
# time.sleep(0.1)
# self._port.setDTR(False)
# NodeMCU devkit
self._port.setRTS(True)
self._port.setDTR(True)
time.sleep(0.1)
self._port.setRTS(False)
self._port.setDTR(False) self._port.setDTR(False)
time.sleep(0.1)
self._port.setRTS(True) self._port.setRTS(True)
time.sleep(0.1) time.sleep(0.05)
self._port.setDTR(True) self._port.setDTR(True)
self._port.setRTS(False) self._port.setRTS(False)
time.sleep(0.3) time.sleep(0.05)
self._port.setDTR(True) self._port.setDTR(False)
self._port.timeout = 0.5 self._port.timeout = 0.3 # worst-case latency timer should be 255ms (probably <20ms)
for i in xrange(10): for _ in xrange(4):
try: try:
self._port.flushInput() self._port.flushInput()
self._port.flushOutput() self._port.flushOutput()
...@@ -159,7 +149,11 @@ class ESPROM: ...@@ -159,7 +149,11 @@ class ESPROM:
self._port.timeout = 5 self._port.timeout = 5
return return
except: except:
time.sleep(0.1) time.sleep(0.05)
# this is a workaround for the CH340 serial driver on current versions of Linux,
# which seems to sometimes set the serial port up with wrong parameters
self._port.close()
self._port.open()
raise Exception('Failed to connect') raise Exception('Failed to connect')
""" Read memory address in target """ """ Read memory address in target """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment