Workaround for DIO mode leaving flash in write-protect.

This commit is contained in:
Johny Mattsson 2015-07-02 20:08:22 +10:00
parent 8394333cab
commit 9eda352e50
1 changed files with 13 additions and 1 deletions

View File

@ -262,6 +262,15 @@ class ESPROM:
return data
""" Abuse the loader protocol to force flash to be left in write mode """
def flash_unlock_dio(self):
# Enable flash write mode
self.flash_begin(0, 0)
# Reset the chip rather than call flash_finish(), which would have
# write protected the chip again (why oh why does it do that?!)
self.mem_begin(0,0,0,0x40100000)
self.mem_finish(0x40000080)
""" Perform a chip erase of SPI flash """
def flash_erase(self):
# Trick ROM to initialize SFlash
@ -560,7 +569,10 @@ if __name__ == '__main__':
seq += 1
print
print '\nLeaving...'
esp.flash_finish(False)
if args.flash_mode == 'dio':
esp.flash_unlock_dio()
else:
esp.flash_finish(False)
elif args.operation == 'run':
esp.run()