How to know amount of Binary image size that is running?

dhananjay.sutariya
Posts: 41
Joined: Thu Feb 28, 2019 12:21 pm

How to know amount of Binary image size that is running?

Postby dhananjay.sutariya » Tue Apr 30, 2019 2:57 pm

Hi everyone,
is there any API to know the size of my firmware size .Matter of fact is there any api to know the amount of portion written in a given partition.

Regards,
Dhananjay Sutariya

eagi223
Posts: 16
Joined: Fri Mar 02, 2018 4:46 pm

Re: How to know amount of Binary image size that is running?

Postby eagi223 » Tue Apr 30, 2019 7:52 pm

Running the command

Code: Select all

make size
will give you the entire size of your application and the output will look like:

Code: Select all

Total sizes:
 DRAM .data size:   14892 bytes
 DRAM .bss  size:   42664 bytes
Used static DRAM:   57556 bytes (  67024 available, 46.2% used)
Used static IRAM:  100377 bytes (  30695 available, 76.6% used)
      Flash code:  907603 bytes
    Flash rodata:  244904 bytes
Total image size:~1267776 bytes (.bin may be padded larger)
There is also the command

Code: Select all

make size-components
that will break your application size down by each used component from the idf, your main app, and any extra components you've added.

dhananjay.sutariya
Posts: 41
Joined: Thu Feb 28, 2019 12:21 pm

Re: How to know amount of Binary image size that is running?

Postby dhananjay.sutariya » Wed May 01, 2019 4:57 am

Hi eagi,
Thanks for the response. However are there any api's that do the same?

eagi223
Posts: 16
Joined: Fri Mar 02, 2018 4:46 pm

Re: How to know amount of Binary image size that is running?

Postby eagi223 » Thu May 02, 2019 5:11 pm

Ah, so you want to figure out the size of you firmware at runtime? It may be possible, but I'm not sure what the use case of that would be since you know it at compile time... You can read out the contents of a partition (though the factory partition may be protected in some way so you can't corrupt it) using the flash_partition api https://docs.espressif.com/projects/esp ... flash.html. That will definitely give you the size of the partition, but as for the actual size used by the firmware, I don't know of a way to do that besides manually reading the entire firmware from the flash until you get to the empty section (0xff or 0x00 repeated I think? can't remember). Maybe it would be helpful to know what you're trying to accomplish so someone can have a better idea of what you need. Sorry I couldn't be of more help!

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: How to know amount of Binary image size that is running?

Postby boarchuz » Fri May 03, 2019 2:17 am

It does seem to be possible. Try this: (it's also used in there to calculate hashes of the current program, which is a good example usage)
https://github.com/espressif/arduino-es ... p.cpp#L151
Looks like the real magic happens here, for interest:
https://github.com/espressif/esp-idf/bl ... mat.c#L158

dhananjay.sutariya
Posts: 41
Joined: Thu Feb 28, 2019 12:21 pm

Re: How to know amount of Binary image size that is running?

Postby dhananjay.sutariya » Tue May 07, 2019 10:59 am

eagi223 wrote:
Thu May 02, 2019 5:11 pm
Ah, so you want to figure out the size of you firmware at runtime? It may be possible, but I'm not sure what the use case of that would be since you know it at compile time... You can read out the contents of a partition (though the factory partition may be protected in some way so you can't corrupt it) using the flash_partition api https://docs.espressif.com/projects/esp ... flash.html. That will definitely give you the size of the partition, but as for the actual size used by the firmware, I don't know of a way to do that besides manually reading the entire firmware from the flash until you get to the empty section (0xff or 0x00 repeated I think? can't remember). Maybe it would be helpful to know what you're trying to accomplish so someone can have a better idea of what you need. Sorry I couldn't be of more help!
Hi eagi,
I want to know the amount of flash utilised at runtime.
Not only the amount of flash utilised by firmware but the amount of flash utilised in each partition (NVS,OTADATA,phy_init) etc.

Regards,
Dhananjay
Last edited by dhananjay.sutariya on Tue May 07, 2019 12:02 pm, edited 1 time in total.

dhananjay.sutariya
Posts: 41
Joined: Thu Feb 28, 2019 12:21 pm

Re: How to know amount of Binary image size that is running?

Postby dhananjay.sutariya » Tue May 07, 2019 12:02 pm

boarchuz wrote:
Fri May 03, 2019 2:17 am
It does seem to be possible. Try this: (it's also used in there to calculate hashes of the current program, which is a good example usage)
https://github.com/espressif/arduino-es ... p.cpp#L151
Looks like the real magic happens here, for interest:
https://github.com/espressif/esp-idf/bl ... mat.c#L158
Hi boarchuz,
seems like this will only provide the amount of flash utilised by firmware correct me if im wrong

Regards,
Dhananjay

Who is online

Users browsing this forum: YaCy [Bot] and 137 guests