Total Flash storage available pixljs

Posted on
  • Hi there,

    I'm looking to store some data files on my pixljs (it's got 512 KB total flash - yay). However when I was doing some testing I found that the available flash storage is quite a bit lower. I ran the following code:

    //cleanup existing flash storage
    storage = require("Storage");
    // fill er up
    var i;
    var packages_written = 0;
    for (i = 0; i < 512; i++) {
      data = new Uint8Array(1000);
      storage.write(i.toString(), data);
      console.log("wrote: " + i);

    This ended up writing 33 files (so ~33KB of storage). I'm looking to store about 360KB of binary data files (though that seems to be doubtful at the moment).

    Anyone have pointers on optimizations I can do to increase the flash storage? I rather liked not having to use an SD card and holding everything on the device. Additionally is there an easy way to identify when the local flash storage is full (I was looking through the API and didn't see any good methods of doing that).

    Thanks in advance

  • Hi,

    A significant amount of flash memory is needed for the JavaScript interpreter and Bluetooth stack. Realistically that means around 40kB is available - for your code and any data. As far as I recall even if you got rid of Espruino completely that'll only free up around 350k - the Bluetooth stack takes the rest all by itself.

    To remove all files, just do require("Storage").eraseAll() and that'll reformat the storage which will free up as much memory as possible.

    storage.getFree() will tell you how much is available.

    You have a few options...

    But realistically you're not going to write 360kB of data onto Pixl.js as-is, however if it's easily compressable there's some possibility you could get close with a customised firmware

  • I'll give the compression a try and see how much that helps before I head down either the custom firmware route or SD card route



Total Flash storage available pixljs

Posted by Avatar for cozezien @cozezien