BootLoader and Application memory size in AVR

1k views Asked by At

I searched a lot a bout this question and I did not find any clear answer yet. As you know, AVR microcontrollers e.g. Atmega128 have a Flash memory which can be divided into Bootloader and Application memory. I've adjusted the parameters of each one and loaded my boot and application load. Is there any way (using code or from terminal) to know the exact size of each memory and the available bytes????

Some people may be mention avr-size command. This command give me the size of the whole flash memory. I want to distinguish between boot and application memory.

Thanks in Advance

3

There are 3 answers

2
old_timer On

Just read the manual:

The actual address of the start of the Boot Flash section is deter- mined by the BOOTSZ fuses

and you will find your answer.

0
Felipe Lavratti On

You have two firmwares, the bootloader and application, each will have its own size.

For each build, add the linker flag to your linking command line -print-memory-usage to make it print how much flash and RAM is used. (This flag is not supported by every tool-chain, but AVR might support it)

More info: https://stackoverflow.com/a/41389481/2002198

Or, you can get the memory usage with avr-size:

avr-size -C --mcu=atmega168 project.elf

Reference: http://www.avrfreaks.net/forum/know-code-size-and-data-size

There's other detail you have to be aware: Depending the way you are loading your application (flash writing vs bootload loading) you will align the application with FLASH blocks (usually 2 kibs). Depending the way you are doing you will have smaller available flash memory to the application.

0
David Grayson On

If you have already built your bootloader then you should be able to tell how big it is either by looking carefully at the steps you performed to build it, or by examining the HEX file for the bootloader. The HEX file says exactly what addresses the code in it are written to.