What is the maximum size of an .elf file?
The elf files that result from compiling the default monomake project are 1.7Mb in size.
- How much built in flash memory does the Mono have and what is the maximum size of an .elf file for the Mono?
- Is there any way to reduce the size of the binary?
- If I don't need accelerometer and temperature, could I leave out that code?
I'm not a C++ programmer in my day job so I apologise in advance if this is a stupid question, ie. if the compiler strips unreferenced libs automatically :)
How much built in flash memory does the Mono have and what is the maximum size of an .elf file for the Mono?
Mono has 256 Kb of flash memory and 64 kb SRAM. The current toolchain allocate 16kb of the RAM for heap and 16 kb for the stack. That leaves 32 kb for
const's and global variables. If you need more heap/stack, you can change it by hacking the toolchains linker file:
/path/to/openmono/mono/include/mbed/target_cypress/cm3gcc.ld. But you should properly know what you are doing ;-)
There is not a maximum file size for the ELF file. The elf contains all kind of additional information, like debug symbols. Most of the content is not transferred to mono when programming. You can use a tool like
objdumpto examine the elf files.
The compiler will check if your application's code or memory usage is too large and produce an error. However, you can still get runtime memory faults like stack and heap overflows. So use
Is there any way to reduce the size of the binary?
Yes, you can set the optimization level on GCC by adding this line to your project's
OPTIMIZATION = -Os
All the pre-compiled libraries are already compiled with optimization for size. But your own app code is not (by default). This allows you to debug your code using a debugger.
If I don't need accelerometer and temperature, could I leave out that code?
All framework code is statically linked and contained in the files:
/path/to/openmono/mono/*.a. When you compile your project, GCC includes only the code segments that is needed from the static libraries.
Right now the framework does leave some room for dependency optimizations, such that the graphics system code can be excluded - when not referenced. But actually the accelerometer is not included in your binary, when you do not include
No apologies needed. The C and C++ toolchains feels quite old-school, when compared to more modern languages.