mbed binary file size

26 May 2012

How does the memory mapping between flash and RAM happen as far as code goes? I am writing a code for a scheduler program where I do make use of an external matrix library. This results in the size of my binary to go upto 160 KB. Just the schedule part of my source code runs perfectly fine when I run it on the mbed and the binary file created is around 158KB. How is a 158 KB binary file able to run on the mbed???

26 May 2012

Don't confuse the bin file size as shown in the operating system file manager with the actual size it occupies when the content of the file is written in the flash of a microcontroller. The flash size for the compiled code is reported in the compiler tool.

Alex

27 May 2012

The mbed has 512k of FLASH and 32k of RAM in the lower bank and another 32K of RAM in the upper banks. A 158KB binary will have no problem fitting in the 512k FLASH of the LPC1768 based mbed. The bulk of your 158k binary will be code and literals which will never use any RAM. Only your non-constant globals, heap, and stack allocations need to be allocated within the lower 32K of RAM. After you compile your program, you can click on the root node for you project in the "Program Workspace" and then in the rightmost "Program Details" pane there will be a "Build" tab that when selected will show the actual FLASH and RAM usage of your program.

The size of the resulting binary file IS the size of the program that is loaded into the FLASH of the LPC1768 device but your RAM usage will typically be much less.

27 May 2012

Adam you are absolutely right. I'm used in working with the hex files where the file size is much larger than the actual data size but this is not the case with bin files as you correctly point.

Alex

09 Dec 2012

Thanks for clarifying the basics.