This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Undefined symbols when including SafeTI library

Other Parts Discussed in Thread: HALCOGEN

I'm trying to include the SafeTI library in a project but I get an undefined symbols error when including sl_types.h, sl_api.h, sl_priv.h:

Error:

undefined first referenced
symbol in file
--------- ----------------
StackModeABT ./source/sl_asm_api.obj
StackModeFIQ ./source/sl_asm_api.obj
StackModeIRQ ./source/sl_asm_api.obj
StackModeSVC ./source/sl_asm_api.obj
StackModeSYS ./source/sl_asm_api.obj
StackModeUND ./source/sl_asm_api.obj

I tried following the instruction from an earlier posting which advised to add a call to SL_Init_StackPointers(); in the HL_sys_startup.c function but this didn't really solve the problem.

Any help would be appreciated.

  • Hello,

    These are global variables defined in the sl_asm_api.asm file and need to be defined by the application as the base addresses for the different stacks. The default stack sizes are defined in the sl_config.h header file.

    Regards,
    Sunil
  • Hi Sunil,

    Thank you for your reply. How and where in the code would I implement the definition of those global variables? If I call SL_Init_StackPointers in the main() function the linker still won't see it and fail linkage due to undefined symbols. I'm using Halcogen and CCS.

    Thanks for your help.

  • There are multiple ways you can do this. You can do simple #define to define each of these symbols. This has the limitation of the stack base addresses being hardcoded inside a source or header file. A better way to define these symbols is to use the linker command file.

    You need to define a STACKS region:
    STACKS (RW) : origin=0x08000000 length=0x00001800

    Then you can assign the stacks to this region as shown below (note the stack pointer assignments):

    .intvecs : {} > VECTORS
    .text align(8) : {} > FLASH0 | FLASH1
    .const align(8) : {} > FLASH0 | FLASH1
    .cinit align(8) : {} > FLASH0 | FLASH1
    .pinit align(8) : {} > FLASH0 | FLASH1
    .STACK_DATA_svc : {. += 1024;} > STACKS, RUN_START(StackModeSVC)
    .STACK_DATA_fiq : {. += 1024;} > STACKS, RUN_START(StackModeFIQ)
    .STACK_DATA_irq : {. += 1024;} > STACKS, RUN_START(StackModeIRQ)
    .STACK_DATA_abt : {. += 1024;} > STACKS, RUN_START(StackModeABT)
    .STACK_DATA_und : {. += 1024;} > STACKS, RUN_START(StackModeUND)
    .STACK_DATA_sys : {. += 1024;} > STACKS, RUN_START(StackModeSYS)
    .bss : {} > RAM
    .data : {} > RAM
    .sysmem : {} > RAM

    Regards,
    Sunil
  • Thanks Sunil, that worked. I have also tried to use the SafetyLib example that came with Halcogen. The code compiles and runs alright but no matter which test I turn on (e.g. SL_SelfTest_SRAM) it returns 0 which forces the code into a while(1) loop.
    I assume that is not the expected behavior. Is there a configuration I'm missing?
  • How is the SRAM region configured in the MPU? Can you configure this to be a write-through region? I think it is a write-back cacheable region by default (as configured by HALCoGen).
  • Region 3 seems to be the SRAM region as it extends from 0x08000000 to 0x0807FFFF. This region is of type: NORMAL_OIWBWA_NONSHARED
    and permission: PRIV_RW_USER_RW_NOEXEC. None of the sub-regions are disabled. I changed that to type NORMAL_OIWTNOWA_NONSHARED but the problem persists.
    I debugged this problem a little more and SL_SelfTest_SRAM() seems to return false because nERROR is active (SL_ESM_nERROR_Active() returns true). I could reset it by adding SL_Clear_nERROR() calls. What surprised me was that the esmCallBackFunction in the example never gets called, I had expected to see it executed during each test, is it normal that it doesn't?