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

Hi
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
Mahendra

Parents
  • Hi Mahendra

    Do you get any warnings during the build? If yes, can you include the build output?

    It could also be interesting to see your crash log, if you can ensure that logging is enabled and provide the crash log here? 

    0x100 is the start of the code area (.text), and it shouldn't be any problem if your function ends up here, as long as there is no conflict with other symbols. 

    Best regards
    Torbjørn

Reply
  • Hi Mahendra

    Do you get any warnings during the build? If yes, can you include the build output?

    It could also be interesting to see your crash log, if you can ensure that logging is enabled and provide the crash log here? 

    0x100 is the start of the code area (.text), and it shouldn't be any problem if your function ends up here, as long as there is no conflict with other symbols. 

    Best regards
    Torbjørn

Children
Related