diff options
Diffstat (limited to 'esp8266/modules/flashbdev.py')
-rw-r--r-- | esp8266/modules/flashbdev.py | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/esp8266/modules/flashbdev.py b/esp8266/modules/flashbdev.py index e879895fb..8f8df0b64 100644 --- a/esp8266/modules/flashbdev.py +++ b/esp8266/modules/flashbdev.py @@ -3,8 +3,9 @@ import esp class FlashBdev: SEC_SIZE = 4096 - START_SEC = esp.flash_user_start() // SEC_SIZE - NUM_BLK = 0x6b + RESERVED_SECS = 0 + START_SEC = esp.flash_user_start() // SEC_SIZE + RESERVED_SECS + NUM_BLK = 0x6b - RESERVED_SECS def __init__(self, blocks=NUM_BLK): self.blocks = blocks @@ -26,40 +27,6 @@ class FlashBdev: if op == 5: # BP_IOCTL_SEC_SIZE return self.SEC_SIZE -def set_bl_flash_size(real_size): - if real_size == 256*1024: - code = 1 - elif real_size == 512*1024: - code = 0 - elif real_size == 1024*1024: - code = 2 - elif real_size == 2048*1024: - code = 3 - elif real_size == 4096*1024: - code = 4 - else: - code = 2 - buf = bytearray(4096) - esp.flash_read(0, buf) - buf[3] = (buf[3] & 0xf) | (code << 4) - esp.flash_erase(0) - esp.flash_write(0, buf) - -# If bootloader size ID doesn't correspond to real Flash size, -# fix bootloader value and reboot. -size = esp.flash_id() >> 16 -# Check that it looks like realistic power of 2 for flash sizes -# commonly used with esp8266 -if 22 >= size >= 18: - size = 1 << size - if size != esp.flash_size(): - import machine - import time - print("Bootloader Flash size appear to have been set incorrectly, trying to fix") - set_bl_flash_size(size) - machine.reset() - while 1: time.sleep(1) - size = esp.flash_size() if size < 1024*1024: bdev = None |