[SOLVED] Use GNU linker with Nordic nRF5340 build

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Use GNU linker with Nordic nRF5340 build

    Hello,

    I'd like to use GNU linker in order to build a firmware for Nordic nRF. In SES, My goal is to be able to configure a Non-Secure Callable region to place secure code there, that can be called from a non secure image. The problem with the SEGGER linker is that it doesn't support the "--out-implib" like the GNU linker.
    I already tried to switch my project to the GNU linker and to specify a flash placement XML file but the section definitions doesn't corresponds to the ones expected by the nRF startup assembly code. I also tried to setup a bare CortexM33 application with the GNU Linker but in this case the application simply doesn't work.

    Do you have samples available for writing an nRF application using the GNU Linker rather than the SEGGER one? Or do you have future plans to add support for the --out-implib option in SEGGER Linker?

    Thanks

    Alex

    The post was edited 1 time, last by aabadie ().

  • My initial goal was to be able to boot from a secure image that afterwards jumps to another non secure image placed right after the initial secure one. My problem was that jumping to the non secure was triggering a hard fault. I also wanted to be able to call secure code (placed in a NSC flash area) from the non secure application.

    I found the solution to my problem: for some reason, when using "thumb_crt0.s" (required when using the GNU linker) instead of the "SEGGER_THUMB_Startup.s" (required when using the SEGGER linker) boot sequence, the reset handler callback must be declared static.

    Here are the project configurations I use to be able build my firmware with TrustZone and Non Secure Callable code available:
    - Use GNU linker with the NSC memory segment that is defined for both the secure and non secure image (in MemoryMap.xml) along with specific flash placement xml files (specified using "linker_section_placement_file" option).
    - In the secure application, the following options must be set:
    - arm_linker_cmse_import_library_file_name="$(OutDir)/cmse_implib$(LIB)". This option doesn't work the SEGGER linker, that's why I have to use the GNU linker.
    - arm_v8M_has_cmse=Yes
    - In the non secure applicaiton, to link agains the cmse import lib, I used: linker_additional_files="$(ProjectDir)/Output/s/$(Configuration)/Exe/cmse_implib$(LIB)"

    The rest is done in the firmware code to configure access to the flash/ram and to required peripherals from non secure code and to jump to the non secure image.