- Fri Oct 23, 2015 1:49 pm
#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.