Hi,
Sorry if this topic was already discussed... did not find it while searching the forums.
Before I start coding some useless tools, is there a way to:
- at compile time to show the RAM and Flash that will be allocated by the core and each module (kind of size mod....o ?)
- at runtime to monitor dynamic memory allocation (m_malloc) by module
Thanks!
shazz
Find out how much RAM will be used by MicroPython at compile the runtime
Find out how much RAM will be used by MicroPython at compile the runtime
8bits should be enough...
Re: Find out how much RAM will be used by MicroPython at compile the runtime
Do you mean at compile time of the C firmware?
Sent from my iPhone using Tapatalk Pro
Sent from my iPhone using Tapatalk Pro
Re: Find out how much RAM will be used by MicroPython at compile the runtime
By core I assume you mean MicroPython core (i.e. /py/*.c), not sure what you mean by module, but perhaps you mean a single translation unit (i.e. one .c file?). You can look at the size of each symbol in the corresponding object file.
e.g.
Code: Select all
nm --print-size --radix=d ports/stm32/build-PYBV11/modmachine.o
However you can use the same trick on the final firmware.elf file to look at the sizes of functions.
I'm not aware of a way to do this, but haven't looked sorry.
Re: Find out how much RAM will be used by MicroPython at compile the runtime
Thanks,
Yes, exactly. I meant
- core: py/*.c
- modules: extmod/*.c => so that in the board definition I can select/remove modules based on my RAM needs
I will play with nm and add a little script to generate those stats on demand, at least to keep track of the memory (flash and RAM) usage.
Yes, exactly. I meant
- core: py/*.c
- modules: extmod/*.c => so that in the board definition I can select/remove modules based on my RAM needs
I will play with nm and add a little script to generate those stats on demand, at least to keep track of the memory (flash and RAM) usage.
8bits should be enough...
Re: Find out how much RAM will be used by MicroPython at compile the runtime
The flash usage is trivial to discover: all the information is contained in the elf.
I think it’s easiest to transform the elf into a pure binary file and then take note of the size of said binary file.
Sent from my iPhone using Tapatalk Pro
I think it’s easiest to transform the elf into a pure binary file and then take note of the size of said binary file.
Sent from my iPhone using Tapatalk Pro
Re: Find out how much RAM will be used by MicroPython at compile the runtime
You cannot discover the RAM usage statically like with flash usage.
RAM usage depends on the code ie how much memory it Allocates.
But in general you can’t deduce that info just by searching for “malloc” within the code.
The number of mallocs could be dynamic, based on an input.
There could be complicated logic that determines how much memory a module maintains.
Sent from my iPhone using Tapatalk Pro
RAM usage depends on the code ie how much memory it Allocates.
But in general you can’t deduce that info just by searching for “malloc” within the code.
The number of mallocs could be dynamic, based on an input.
There could be complicated logic that determines how much memory a module maintains.
Sent from my iPhone using Tapatalk Pro