Question

I have a program that generates a .axf file of size about 800KB and my microcontroller seems to execute the code with perfection. But I was wondering why it's possible to store a .axf file bigger than 800KB to a Cortex-M3 microcontroller that has a specified internal flash memory of 256KB. That doesn't make much sense to me. The .axf file has something to do with the microcontroller internal flash memory, right? If so, why does my program work?

Was it helpful?

Solution

axf, elf, coff, exe, intel hex (ihex), motorola s record (srec) and a whole bunch of other "binary" file formats contain both the binary and other stuff like where that code gets loaded. Rarely do we work with simple binary images of a program. there is still a lot of work in microcontroller land where the raw binary image is used. But more and more flash programmers are accepting these other file formats (intel hex and s record being ones that have been supported for a really long time). Your toolchain might have tools that can convert between formats axf to ihex or the one of interest is ihex to raw binary. If it were an elf file and you were using gnu tools then

arm-none-eabi-objcopy file.axf -O binary file.bin

Now that might backfire on you, but if it does you probably dont have a valid program. If for example your flash is at 0x10000000 and you have less program than flash but your ram is at 0x80000000 and you have N bytes of .data and the linker script didnt account for placing that in flash (so your bootstrap code could copy it) then you could end up with padding in the .bin file to have everything relatively in the right place, so those N bytes of .data would need to be 0x80000000-0x10000000 bytes after the start of flash, so your .bin file would be almost 2 gigabytes. A large binary for a tiny microcontroller. Yet another reason to not work with raw binary images but instead file formats that mix your binary blobs with extra information as to where those binary blobs go... I have N bytes of .text that start at 0x10000000 I have Y bytes of .data that start at 0x80000000 and so on...

OTHER TIPS

.axf files contains more information than simply the flash image, like data to help the debugger.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top