How can I place code generated via add_library(mylib..) to a specific location in flash?

I have an application that I have started using the NUS template which will run in the nrf52840 devkit.

I also have some 'legacy' c files in a library folder that are included in the build using add_library() cmake statement.
For the same of this question let us assume that the library contains one file called legacy.c and it has a single function called my_legacy_func().

When I build the application i do get an .elf file.
However looking at the .map file it is showing me that the function my_legacy_func() has been placed at address 0x00000100 and then when i call it from main() of the zephyr i end up in a memfault exception.

Can you suggest how I  can solve this problem?

Note: That same function my_legacy_func(), if I copy to my main.c then there is no memfault.
Also note that my actual library is about 500 .c files and need to be compiled with a special set of compiler defines hence the add_library option

I thank you in advance

Kind regards

Parents Reply
  • Hi Torbjorn,

    I was at the Tech Tour in London last week and missed your persence :-)

    Let me try one more thing that Bell on Discord suggested and then I will get back to you.
    Last night I used zephyr extension cmake functions and I could build it and the map showed my function no longer at 0x100 and this evening I will try and run it to see it the problem disappears which means it will be one step in many that I have managed to conquer with an SDK that a major company has supplied which is pants.

    Kind regards