Skip to content

Commit

Permalink
Workaround write-protected flash when DIO mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johny Mattsson committed Jul 3, 2015
1 parent a0c18ea commit 9e5dff1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion esptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,15 @@ def flash_read(self, offset, size, count = 1):

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
Expand Down Expand Up @@ -563,7 +572,10 @@ def arg_auto_int(x):
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()
Expand Down

0 comments on commit 9e5dff1

Please sign in to comment.