STORAGE vs Flash

Posted on
  • I've compiled a firmware with STORAGE enabled, but putting more and more pages on the ESP8266 it seems like there's not even 1 MB of free storage available while flash is almost 2 MB:

    /*
    >require("Storage").getFree();
    =196608
    >require("ESP8266").getFreeFlash()
    =[
      { addr: 2097152, length: 1048576 },
      { addr: 3145728, length: 262144 },
      { addr: 3407872, length: 262144 },
      { addr: 3670016, length: 262144 },
      { addr: 3932160, length: 241664 }
     ]
    */
    >
    

    Somehow I expected the STORAGE module to use all available flash storage, not just the block where the program and wifi data is stored. Is it the intended behavior, or a bug in my build?

  • Just a hunch: ESP8266's flash is divided to multiple parts: Running code, SPIFS, OTA partition, etc. My guess is that's why you only see that much free flash.
    There are compiler flags to set flash partition on the ESP8266, and I think separate compiler options to reserve space for Espruino's storage.

  • Hi @maze1980,

    Storage is using save pages in the memory mapped area.
    A 4MB build will give you 48x4096 bytes, which is exactly 196608 byte.

    require("ESP8266").getFreeFlash() returns all other memory areas as defined in source code. For working with those areas use the build in Flash Library and the FlashEEPROM module.

  • Thanks for the info.
    Is is theoretically possible to extend the Storage module to use all available flash areas, or are there technical limitations?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

STORAGE vs Flash

Posted by Avatar for maze1980 @maze1980

Actions