-->
Page 1 of 3

Application Size in Flash

PostPosted: Mon Nov 15, 2021 11:17 am
by Inq720
Brief - At run time is there some way to get or calculate the amount of space used by the application under the native NonOS?

Detail - I know the application (user1.bin) is uploaded to 0x1000. I have my test app scanning the flash for blank sectors and can see the following on a freshly erased and flashed ESP8266 WeMos 4MB board.
empty sectors 8 - 15
empty sectors 84 - 1017
empty sectors 1022 - 1022
I'm not sure what the big hole is between 8 and 15, but the app resides in 16 to 83 taking up 272KB.
Since scanning and inferring the end of the app is unreliable, is there a way via the SDK to calculate the size?

Thanks for your help.

Re: Application Size in Flash

PostPosted: Mon Nov 15, 2021 5:30 pm
by davydnorris
There's SDK functions that can help

void system_print_meminfo (void);
uint32 system_get_free_heap_size(void);

Re: Application Size in Flash

PostPosted: Tue Nov 16, 2021 10:41 am
by Inq720
davydnorris wrote:There's SDK functions that can help

void system_print_meminfo (void);
uint32 system_get_free_heap_size(void);


Thank you for responding, and I wasn't clear in what I asked. I use those already and they just show runtime ram usage.

data : 0x3ffe8000 ~ 0x3ffe837d, len: 893
rodata: 0x3ffe8380 ~ 0x3ffe9758, len: 5080
bss : 0x3ffe9758 ~ 0x3ffefb30, len: 25560
heap : 0x3ffefb30 ~ 0x3fffc000, len: 50384

I'm looking for a runtime method to show or let me calculate flash memory usage of the application. For instance, my test application scans ALL 4MB of the flash sectors 0-1023 and just checks for something besides 0xFF in a byte. If the entire sector is 0xFF, it's considered empty. This is what I get:

empty sectors 8 - 15
empty sectors 84 - 1017
empty sectors 1022 - 1022

The app is stored in flash sectors starting at 1. From my scanning app, it appears the app is done by sector 83. What I want is for some method or methodology to calculate that app length without having to do this brute force scan.

Thanks

Re: Application Size in Flash

PostPosted: Wed Nov 17, 2021 7:02 pm
by davydnorris
Ah OK, this really isn't a runtime type of thing - you should be able to explicitly determine and define your flash usage when you create your application.

Firstly, what SDK are you using? The NonOS SDK requires you to set up a partition table in your code, and this data can then be accessed via runtime functions. You would then define your boot partition, application code partition, SDK internal partition, and any other ones you like. Whatever is left over is then theoretically completely free, but I define and allocate this free area explicitly for use in my code.

So then your setup code contains everything you need to manage free space in flash