micropython / micropython-esp32

Old port of MicroPython to the ESP32 -- new port is at https://github.com/micropython/micropython
MIT License
678 stars 218 forks source link

Cannot flash_erase #139

Closed LupascuAndrei closed 5 years ago

LupascuAndrei commented 7 years ago

Using the following code:

from esp import * 
def test(st, end):
  for i in range(st, end, 4096):
    try:
      flash_erase(i)
      print('working for ' + str(i))
    except:
      print('not working for ' + str(i))
test(0, 0x400000)

I can see that only a small amount of sectors ( < 5 ) can be erased from the whole flash memory. I'm new to micropython-esp32, is this an intended flash protection? If so, is there a straightforward way to disable it? Thank you.

dpgeorge commented 7 years ago

The esp.flash_erase() function takes an argument which is the sector number, not the address.