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.