Reading FLASH arrays?
Reading FLASH arrays?
Postby scargill » Wed Jul 01, 2015 8:15 am
Does anyone have a simple example of reading data from a FLASH array - that is without having to hard code locations etc....
As a pseudo example (which clearly is fictional)
uint8_t fred[10]={ 1,2,3,4,5,6,7,8,9,10 }
a=fred[6];
but any array I've seen - event with CONST written all over it, still ends up using RAM! what C code would we need in order to create and access a similar array that never leaves FLASH and could hence be quite big.
??
Pete.
p.s. clarly it can be done - as there are routines in the SDK (and TUANPM wrote some) to store information in FLASH and bring it back... but it would be nice if somehow one could make something simple that doesn't involve knowing the exact location of the array in FLASH beforehand.
As a pseudo example (which clearly is fictional)
uint8_t fred[10]={ 1,2,3,4,5,6,7,8,9,10 }
a=fred[6];
but any array I've seen - event with CONST written all over it, still ends up using RAM! what C code would we need in order to create and access a similar array that never leaves FLASH and could hence be quite big.
??
Pete.
p.s. clarly it can be done - as there are routines in the SDK (and TUANPM wrote some) to store information in FLASH and bring it back... but it would be nice if somehow one could make something simple that doesn't involve knowing the exact location of the array in FLASH beforehand.
Re: Reading FLASH arrays?
Postby ESP8266Fan » Wed Jul 01, 2015 10:31 am
You could try to define it like this
Flash is 4 bytes aligned, so your array has to be "uinit32" , read and write every 4 bytes.
Code: Select all
static const char XXXX[] ICACHE_RODATA_ATTR = { ........ }
Flash is 4 bytes aligned, so your array has to be "uinit32" , read and write every 4 bytes.
Re: Reading FLASH arrays?
Postby scargill » Wed Jul 01, 2015 5:04 pm
Good idea ... but I think maybe you have to force the 4-byte alignment or something? It crashes the processor every time you try to access it..
static const uint32_t petes[] ICACHE_RODATA_ATTR = {
55,45,66,77,88,12,76,23,45,67,34,65,25,74,234,67,3,643,646,
55,45,66,77,88,12,76,23,45,67,34,65,25,74,234,67,3,643,646,
55,45,66,77,88,12,76,23,45,67,34,65,25,74,234,67,3,643,646};
iprintf is just a macro for a normal printf function...
iprintf("Data= %ld",petes[37]);
Immediate reboot....
Ideas?
static const uint32_t petes[] ICACHE_RODATA_ATTR = {
55,45,66,77,88,12,76,23,45,67,34,65,25,74,234,67,3,643,646,
55,45,66,77,88,12,76,23,45,67,34,65,25,74,234,67,3,643,646,
55,45,66,77,88,12,76,23,45,67,34,65,25,74,234,67,3,643,646};
iprintf is just a macro for a normal printf function...
iprintf("Data= %ld",petes[37]);
Immediate reboot....
Ideas?
Re: Reading FLASH arrays?
Postby scargill » Sat Jul 04, 2015 3:06 pm
Well Well, it turns out after all of that - that it was just a silly typo - but here's the point, I've then gone on to do further tests with 8 bit arrays in FLASH and you can read individual bytes successfully - that came as a surprise. So now it would seem it is possible not only to move much of our code into FLASH without TOO bad an overhead but also lookup tables (I tried a very big table)! That should save some RAM.
Who is online
Users browsing this forum: No registered users and 1 guest
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.