So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By RexBrown
#58919 Not sure if this is the right place for this but if not let know and I will try another area.
I have a need to be able to store configuration data in flash. I also have a need to be able to do updates via a web server (i.e.ESPhttpUpdate.update()) . I have written code to manage the flash which works and finally got the OTA update to work. However, the update seems to be overwriting at least part of the area where my configuration data is stored.
I read another post where the 0x80 - 4 sector was used. That is near the top of the 512 K boundary and I expect it would get overwritten. However in the esp12e we are using there is 4 Meg of flash, where the top 3 meg is used by SPIFFS. I don't need the SPIFFS and my code is below the 512K boundary. I tried setting the flash area at the 4 Meg - 4 sector location but it seems to be getting overwritten when I do an OTA update using ESPhttpUpdate.update(). Is there a place where I can locate the config data that will not be overwritten? (I have allocated 512 bytes because that is the size of the RTC user mem which I use for dynamic storage of the config data).
Thanks for your help.
User avatar
By martinayotte
#58942 This doc should help : http://esp8266.github.io/Arduino/versio ... ystem.html

Assuming you choose 4M/1M config, since the OTA will use location just below SPIFFS and sketch size is limited, knowing that Flash start at 0x40200000 and SPIFFS at 0x40500000, I would presume that 0x40300000 is the best location where nothing will overwrite your configs.
User avatar
By RexBrown
#58946 Thanks. Actually I had selected the 4M/3M option, not really knowing which was better. According to the doc you referenced the SPIFFS part of the FLASH is not modified during an OTA update which is a little confusing since the configuration space I chose should have been just below the WiFi config (4 sectors down) at the top of the FLASH (highest location) just above the SPIFFS.

However, I will use your recommendation to set the configuration to 4M/1M and locate my configuration information at the 4030 0000 address. Thanks very much for your help! :D
User avatar
By RexBrown
#58948 I need to clarify one additional point related to writing to Flash. In my code I use the following to access FLASH:
piFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);

where I expected the src_addr parameter to be the byte address in the FLASH (i.e. not offset from 0x40200000).
for instance the address I used for a byte at the beginning of the second sector would be 4096 since the sector size is 4096. So, which is the correct method of specifying the address?

NOTE: Using the method I gave above I have been able to read and write the flash successfully up to now.
Thanks again for your help.