2015-07-07 07:27 AM
My subject doesn't quite describe what I'm trying to do, but not quite sure how else to explain:
I have a bootloader stored at the start of flash in my STM32f415 (flash location 0x08000000), and my main application is stored further down the line (0x08010000). They both make use of several identical functions, and until now have I have just copied and pasted my C functions into each code base. What I'm now wondering though, is if I were to put these functions into a library file, could I store them at let's say 0x080A0000, and reference the library location to both files, thus saving me the space of including the library in both files? I've been looking into linker scripts and it looks like it might be right way to go (correct me if I'm wrong!) but I'm not quite sure how to implement it. Any help or suggestions or pointers in the right direction would be greatly appreciated!2015-07-07 07:56 AM
Not sure I'd make a system where the boot loader wasn't free standing. That's a recipe for failure.
In Boot ROM situations, you'd typically park all the library routines in the ROM, and provide a definition file to the linker. The .DEF file looking like an ASCII list of the function names, and addresses. Not sure if GNU has a way of doing that, or if it would be simple enough to create a library with the known addresses.Where things are more likely to move, you can use a table/structure of function pointers, accessed indirectly, or in a manner similar to qsort()