Move a file's compiled contents to end of a binary

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Move a file's compiled contents to end of a binary

Jump to solution
1,108 Views
gertvb
Contributor III

Good day Everyone!

I am working on the LPC55S69 (OKDO E1) with MCUXpresso 11.4, SDK 2.10.0 and Gui-Guider 1.3.1.

Clocks, Pins, ADC, DMA and SPI configuration was done with Configtools from within McuXpresso, and all are working fine - compliments to the guys who built the whole IDE & Toolchain, a nice environment to work and develop in!!

My Question is this:

From my main function I mainly call functions in 2 files, eg mathematical_calculations.c and events_init.c

How do I modify the linker to place the compiled contents of these 2 files at the end of the .axf file?

The reason I want to do this, is to speed up my development cycle, as it takes a while to write the complete binary to the LPC55S69's flash everytime I change something like the initial value of a variable.

My logic tells me that if I can have the binary contents of the file I work on placed at the end of the .axf binary, that the debugger will then just overwrite the last portion of the chip's flash memory every time I make a small change.

On the AtSAMD51 ages ago Ive worked with having the linker move the whole binary to allow for the bossac bootloader placed at the beginning of flash, but in this case I want to reorder the internal stuff in the binary and am a bit unsure of how to go about it

Kind Regards

Gert

A TechExplorer working with Embedded Software and Electronics in Agriculture and Alternative Energy
0 Kudos
1 Solution
1,089 Views
ErichStyger
Senior Contributor V

Using the section attribute allows you to put things into a dedicated section, so this very well will work for your case. Another thing you could consider if you really want to keep the code 'static' is to use ROM libraries, see https://mcuoneclipse.com/2022/06/21/tutorial-creating-and-using-rom-libraries-with-gnu-build-tools/

Erich

View solution in original post

2 Replies
1,092 Views
gertvb
Contributor III

What I've figured so far:

Ive changed the function declarations in the header files from

void Init_fft_stuff(void);
void Calculate_fft_stuff(void);

to 

void Init_fft_stuff(void) __attribute__ ((section(".my_memory_section")));
void Calculate_fft_stuff(void) __attribute__ ((section(".my_memory_section")));

And the functions now show up in the .map file at higher addresses next to each other, looks like just after the .text section which is at least far better than having them right at the beginning of the program .

Added bonus is that this is the ONLY change I have to do, and I dont have to go and edit the linker file by hand, which can become messy, as it is auto generated, as the MCUXpresso build process picks up the attribute change automatically and links the files to higher addresses

A TechExplorer working with Embedded Software and Electronics in Agriculture and Alternative Energy
0 Kudos
1,090 Views
ErichStyger
Senior Contributor V

Using the section attribute allows you to put things into a dedicated section, so this very well will work for your case. Another thing you could consider if you really want to keep the code 'static' is to use ROM libraries, see https://mcuoneclipse.com/2022/06/21/tutorial-creating-and-using-rom-libraries-with-gnu-build-tools/

Erich