OTA and SPIFFS?

Started by Humancell, June 07, 2016, 01:53:59 AM

Humancell

I'm new to the Moteino, and so I might not be using the correct terminology, but I'll give it a shot ...

I want to configure my Moteinos to support OTA, but I also need some local flash storage for configuration data.  When I have been programming the ESP8266 modules I can configure the 4MB of Flash to split between OTA storage, and some SPIFFS file system space.  Is there a similar capability/example of how to do this with a Moteino?

Can I split the flash in a way and use it for both purposes?

Thanks in advance!

pedro.albuquerque

Hello Humancel,

I have used flash memory to make a log of my data (received from a remote station).
for that I used the SPIFlash lib.

that lib allow you to write and read on any address, erase 4k blocks and a few more related functions.

I believe you can build your own lib based on this basic function to avoid writing on a reserved area for the OTA.

Not sure to be the answer you expected, but this was my approach.

Felix

The SPIFlash lib allows you to write  bytes or byte streams to the FLASHMEM chip at any address via writeByte() / writeBytes().
The OTA lib does just that (see the WirelessHEX code. It starts at address 0. You can manipulate your data into a byte stream (from a struct or whatever it is) and write it to a predefined address that is above 32K in the SPIFlash (or 64k for MoteinoMEGA).
Also mind that this memory has to be erased before it can be written, you cannot write 0s over previously written data, use the blockErase() functions instead.

Humancell

Thanks for the input here ... from what I am understanding:


  • OTA is using the first 32K of flash?
  • I can use the flash above 32K, but have to read/write in my own blocks?
  • I have to always erase a block before I can write a block?

Felix

1. Yes, for OTA first 32K for the atmega328p based Moteinos. You can actually change that if you really want to but you have to recompile the bootloader to look at your new address for the expected signature.
2. Yes the rest of the chip is free to use in whatever way you want.
3. The chip is erased from the factory. If you write data then want to reuse that space, you have to block-erase it between writes.

nzfarmer

A little off topic, but has anyone ported spiffs to compile and run on the Moteino? thx.

Humancell

This is exactly what I was thinking also ... I've been buried with customer projects lately, but was thinking of giving it a try when I come up for air.

I'm using SPIFFS extensively on the ESP8266, and it would be SO nice to have it here!

Felix

What exactly is SPIFFS?
Google doesn't help.

perky


Felix

Quote from: perky on November 15, 2016, 09:15:13 AM
You didn't look too hard Felix :-)
Obviously!
Or maybe I was expecting to see something else and gave up too soon :P

So this is a file system for the SPIFlash, looking briefly it supports a generic SPIFLASH driver, if the one used is slightly different then a new driver needs integration.
I don't know how this would be compatible with the RFM69 OTA protocol.

The OTA protocol I've developed uses the first 32K block of the SPIFlash MEM chip for storing the new OTA FLASH image. It does not use any kind of fs (file system). In fact the SPIF protocol itself its so compact that it fits in less than 512bytes in the upper portion of the bootloader (DualOptiboot). That portion checks the 32K block for the FLXIMG signature, and transfers the new FLASH HEX image into the AVR internal flash, deletes the FLASH-MEM image when done, and jumps to the new program.
I am pretty sure SPIFFS is too large and is not tailored towards something like that.

I can see how one can use SPIFFS for general file management on the FLASH-MEM otherwise, this would make a lot of things easy for folks who just want to use the FLASH-MEM for logging or other storage. In that case my SPIFlash library probably needs adjustments to integrate with the SPIFFS hal layer.