-
• #2
Sorry for the delay, I was away last week.
I've just looked into this and you're right, it's an issue with the page size on Espruino WiFi, but it was just a bug in the StorageFile implementation (trying to use a StorageFile size that'd fit in a page, even when the page was too big). I've just fixed this (it'll now work in 'cutting edge' builds) but it does expose some issues with the WiFi's storage compaction (when storage gets full) due to some changes since 2v06 - I'll try and get those sorted in the next few days.
So I'd hope that in 2v07 (when released) this'll work great.
As you say there's 512k of flash though. The issue is that the page sizes on the STM32F4 chip used are 16,16,16,16,64,128,128,128 - I just checked and there's around 50k of flash left at the end after Espruino, but it's in a 128k page, so you could never erase it because you'd end up erasing Espruino.
You could however use a custom build for Espruino WiFi that cut out some features you weren't using and got the firmware size down enough that you could use the last page, but that's a bit extreme.
So right now, with the current 2v06 firmware, you could use the standard 'Storage.write' as in the example at: http://www.espruino.com/Reference#l_Storage_write
Eg:
var storage = require("Storage"); var storageOffset = 0; // create file storage.write("log","",0,16384); function log(msg) { storage.write("log",msg,storageOffset); storageOffset += msg.length; // check for end of log... } log("Hello"); log("World");
As long as you're not storing too much program code in flash then Espruino 2v06 should be able to compact everything properly when the log files are all erased and you'll be fine.
But this should all be fixed properly in 2v07.
-
• #3
Ok, it's all fixed now. If you do
Flash From URL
in the Web IDE and enter:https://www.espruino.com/binaries/travis/33da4460e885aa61484c8bfe4c1d86f2fc4e5985/espruino_2v06.124_wifi.bin
(or just choose the latest wifi build from https://www.espruino.com/binaries/travis/master/)
Then everything should work out great for you.
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:
It always results in an error:
I've tried
Storage.eraseAll()
andStorage.compact()
. There are no other files in my Flash storage.I noticed this quote from Gordon in this comment:
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?