Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By martinayotte
#32122 Hi Ray,

Of course, there are mechanics to let sketches been aware of the SPIFFS area, using _SPIFFS_start address provide by the linker, in Esp.cpp, the EspClass::getFreeSketchSpace() use that so that Updater becomes aware of it.

But Mmiscool is asking if there is a way to have "universal" binary for all Flash sizes, so, this is a bit more challenging.
User avatar
By igrr
#32137 This is possible, basically this works in three steps:

- implement a procedure to detect flash size. It works by trying to read last dword of 512k, 1M, 2M, 4M regions (0x7ffffc, 0xfffffc, 0x1fffffc, 0x3fffffc). Each time it sets appropriate field in FlashChip structure used by the SDK to the size of flash being probed. The last size which was read successfully is the real flash size.

- add "auto" flash size build option and wire it to some #define which will cause this auto detection procedure to run

- initialize SPIFFS using the value obtained from auto detection procedure

This gets a bit tricky for 1M and 512k flash sizes, where you have a trade of between code size and SPIFFS size. Code size has to be known at link time, so if you want this "auto" option to work, you have to limit yourself to the smallest code size (512k-64k-4k-20k=424k) for all the chip sizes.