Microcontroller – Will My HEX File Fit in My Microcontroller?

microcontrollerprogramming

I have a hex file with a size of 42 kB. Does the size matter while loading it in a microcontroller? Can I load 42 kB hex file in a ATMEGA32 chip which has a memory of 32 kB?

Best Answer

You can use avr-size to check the real size of your program:

[jpc@jpc sepack] avr-size sepack.elf 
   text    data     bss     dec     hex filename
   4396       6     277    4679    1247 sepack.elf
[jpc@jpc sepack] avr-size sepack.hex 
   text    data     bss     dec     hex filename
      0    4402       0    4402    1132 sepack.hex

As you can see it works better with .elf files since it can also show you both how much ram you need (data+bss) and how much flash will be used (text+data). With the .hex file only shows you the second figure (labeling it data)