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.

RTOS/AM5728: Linking problem with ti.osal package

Other Parts Discussed in Thread: SYSBIOS

Tools & Env:

  • CCS 7.4
  • SYSBIOS 6.52
  • XDCTOOLS 3.50.4
  • GCC (the version that is shipped with CCS)
  • Processor-SDK-RTOS-am57xx 4.02

Problem Brief:

    To build a Cortex-A15 SYSBIOS project in which at least calls once to runtime interfaces implemented by module 'ti.drv.uart', the linker complains about the undefined reference to the functions that are defined in module 'ti.osal' whose library is already included.

Problem Details:

  • main.c:(Note that I only listed the essential part of codes, as I only concern about the linking problem so the runtime validation or initialization is omitted.)
  • app.cfg:

var CSL = xdc.useModule('ti.csl.Settings');
CSl.deviceType = "am572x";
var UART = xdc.useModule('ti.drv.uart.Settings');
UART.socType = "am572x";
var OSAL = xdc.useModule('ti.osal.Settings');
OSAL.socType = "am572x";
OSAL.osType = "tirtos";


  • Debug/linker.cmd: In the generated linker script, I can see the correct osal & uart libraries are included, and osal library appears before uart lib in the statement 'INPUT()'.
  • At linking stage of CCS project, the linker complains that "undefined reference to Osal_getThreadType", "undefined reference to SemaphoreP_pend" and "undefined reference to SemaphoreP_post".

Problem Workaround:

Workaround 1:

Manually adding some function call, and make main.c look like this:

After adding some calls to the 'undefined' osal interfaces, the linking problem is gone. Please note that the added codes don't have any runtime logic, it just provide a way to prove the problem is definitely a linking problem.

Workaround 2:

After the first problematic linking stage is finished with undefined reference errors, open the file 'linker.cmd', change 'INPUT' to 'GROUP', and problem will be gone.

In the Binutils LD documentation, the explaination of GROUP is "The GROUP command is like INPUT, except that the named files should all be archives, and they are searched repeatedly until no new undefined references are created". So the GROUP is more suitable than INPUT when linking libraries.

Workaround 3:

Modify app.cfg to make code "var OSAL = xdc.useModule('ti.osal.Settings');" appear before "xdc.useModule('ti.csl.Settings');" and "xdc.useModule('ti.drv.uart.Settings');". Then, in the generated linker.cmd, the osal's library will appear after the libraries of CSL & UART LLD. Then the linking stage is running good, because the linker resolves references when osal library is loaded.

My Personal Conclusion:

     The "Workaround 2" is the best. But it requires some improvement work for xdctools I guess.

     I guess this problem can be considered as a bug of  RTSC development tools. I hope xdctools can distinguish object files and archives by using both INPUT() and GROUP() commands in the linker script.

  • The RTOS team have been notified. They will comment here.
  • Hi, I am still editing my post. I am having some problem when posting with codes pasted inside.

    I had to take screenshots for the codes, or the post cannot be successfully edited, which is very strange.

  • The issue that you are running into is caused due to ARM linker behavior where it scans for symbols in the libraries in a paritcular order. We ran into this issue when we were testing the setup described here:

    processors.wiki.ti.com/.../Processor_SDK_RTOS_FAQ

    The right work around would be to force the linker to try to locate the symbols in a circular order so if it doesn`t find the symbols it wraps around and re-scans some of the libraries that were previously scanned for symbols in the link order. you can do this using your work around 2 or linker flags --start-group and --end-group as shown below:

    --start-group -lgcc -lc -lrdimon $(BOARD_LIB) $(PERIPHERAL_LIB) -Wl,--end-group

    I will try to bring this up with the XDC team and see if there is some fix that they can provide when linking all the modules.

    Regards,
    Rahul