This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK 8.0.0 with IAR

I am trying to port the SDK 8.0.0 to use the IAR ARM tools and I am having a problem getting the linker to link the file system_nrf51.c that is called from iar_startup_nrf51.s. It keeps saying the that SystemInit appears to be uncalled. I have tired overriding the default entry point to beReset_Handler in iar_startup_nrf51.s but it doesn't seem to have an effect.

  • What level of optimization are you using while compiling the files?

  • Hi,

    IAR seems to be very trigger happy when "Multi-file Compilation" is checked under "Options for Node-> C/C++ Compiler".

    You can either uncheck this option, or declare SystemInit with __root:

    __root void SystemInit(void)
    

    __root keyword is IAR language for "please do not optimize this away". Here's the explanation from IAR:

    __root
    The __root attribute can be used on either a function or a variable to ensure that, when the module containing the function or variable is linked, the function or variable is also included, whether or not it is referenced by the rest of the program.
    
    By default only the part of the runtime library calling main and any interrupt vectors are root. All other functions and variables are included in the linked output only if they are referenced by the rest of the program.
    
    The __root keyword is placed in front of the type, for example to place settings in non-volatile memory:
    
    __root int settings[10];
    
    The #pragma object_attribute directive can also be used. The following declaration is equivalent to the previous one:
    
    #pragma object_attribute=__root
    int settings[10];
    
    Note: The __root keyword cannot be used in typedefs.
    

    Now, if you choose to move forward with Multi-file Compilation set, you must also note that all your interrupt service routines shall be declared with __root as well, if not you may hang in the start-up file in a asm-while-loop because your linker removed the function. I added full optimization to the beacon example and needed to add __root to both SystemInit and SWI1-handler in app_timer.c.This may vary from example-to-example.

    Cheers, Håkon

Related