Interrupt

How to Dig into Firmware Code Size

Every firmware engineer has run out of code space at some point or another. Whether they are trying to cram in another feature, or to make enough space for A/B firmware updates more code space is always better.


This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/best-firmware-size-tools

Hi,

First of all, thanks a lot for this article, it’s very helpful!
My question is - does the pacover tool works also on axf files? if yes, how do I need to prepare my codebase?

Hi @ngotes

The puncover tool works on any file that was built with debug information and stored in the ELF file format.

.axf (and .out) files usually use the ELF format so you should just be able to follow the instructions as is.

You can easily check to see if the file is in the ELF format by checking to see if the file starts with the EI_MAG header which is 0x7F followed by ‘E’, ‘L’, ‘F’. For example, here’s an axf file I generated recently using the NXP MCUXpressoIDE:

xxd lpcxpresso55s69_freertos_blinky_s.axf  | head -1
00000000: 7f45 4c46 0101 0100 0000 0000 0000 0000  .ELF............

You can use a tool like readelf to check and see if the ELF was compiled with debug information. If it was there will be debug_* sections in the file, i.e

arm-none-eabi-readelf -S lpcxpresso55s69_freertos_blinky_s.axf | grep debug
  [10] .debug_info       PROGBITS        00000000 02fe60 01dab9 00      0   0  1
  [11] .debug_abbrev     PROGBITS        00000000 04d919 003287 00      0   0  1
  [12] .debug_aranges    PROGBITS        00000000 050ba0 0009d8 00      0   0  1
  [13] .debug_ranges     PROGBITS        00000000 051578 000948 00      0   0  1
  [14] .debug_macro      PROGBITS        00000000 051ec0 01a019 00      0   0  1
  [15] .debug_line       PROGBITS        00000000 06bed9 008c00 00      0   0  1
  [16] .debug_str        PROGBITS        00000000 074ad9 0d42f3 01  MS  0   0  1
  [19] .debug_frame      PROGBITS        00000000 148ef8 002a44 00      0   0  4
  [20] .debug_loc        PROGBITS        00000000 14b93c 0009d1 00      0   0  1

Hi @chrisc

Thanks a lot for the detailed answer.
It works fine on both files!

Great! Glad to hear it!