I have an Espruino WiFi flashed with 2v06.
I have been experimenting with using it for data logging and have been thinking about how to persist the data log into flash so that it will survive powering on and off.
I'm having trouble writing files to flash. Specifically, I've been trying to append a file as recommended on the page Data Collection.
However, the second write always throws an error. I've reduced the code to this:
const storage = require('Storage');
const testFile = storage.open('test', 'a');
It always results in an error:
>Uncaught Error: File already written with different data
at line 5 col 25
Storage.compact(). There are no other files in my Flash storage.
I noticed this quote from Gordon in this comment:
The Espruino WiFi is a bit oddball in that it only has one page for storage - a 64kB one - so there are no 'unused' pages it can free. If it can't get the contents of that page temporarily into RAM then it can't compact it.
Not sure if that makes any difference.
Am I doing something wrong? Is it simply a bad idea to be using the flash storage on an Espruino WiFi to store a data log? The specs say it has 512kB of flash, I guess the missing 448KB is storing the firmware?