Post Go back to editing

FreeRTOS port for BF70x and multi-threading C standard library (libcmt): linker error

Hi all,

in another CCES project for BF70x we're also using FreeRTOS.

However, when activating the linker switch "-threads" ("Link against thread-safe run-time libraries") the linker fails:

[Error li1021]  The following symbols referenced in processor 'P0' could not be resolved:
        'adi_osal_ThreadEnableCycleCounting [_adi_osal_ThreadEnableCycleCounting]' referenced from 'libcmt.dlb[osal_thread_cycles.doj]'
        'adi_osal_ThreadGetCycleCount [_adi_osal_ThreadGetCycleCount]' referenced from 'libcmt.dlb[osal_thread_cycles.doj]'

I could not find the two functions being defined in the ADI OSAL for FreeRTOS.

Any ideas?

Is using the "-threads" switch wrong/unneccessary?

Best regards,

  • Hi Matthias,

    The -threads switch is necessary for proper support in the ADI provided libraries; it links against a version of the libraries which calls into thread safe routines to deal with Mutexes, thread local storage, etc.

    These API's are required for the instrumented profiling feature (the -p switch, or "Enable compiler instrumented profiling (-p) in the Compiler settings under "Processor"), which isn't currently supported in under FreeRTOS.

    We'll revisit the issue to see if we can provide meaningful thread timing information here or better diagnostics. In the mean time, disabling the instrumented profiling should avoid the link error.



  • Hi Murray,

    thank you for your reply.

    I do not see the swithc you have mentioned neither in the compiler nor in the linker options listed in the project settings:


    -c -file-attr ProjectName="${ProjName}" -proc ADSP-BF707 -flags-compiler --no_wrap_diagnostics -si-revision 1.1 -O -Ov100 -g -D__ADI_FREERTOS -DADI_FREERTOS_NOTRACING @includes-5b2b872a1533122962211552ddd2fbd4.txt -structs-do-not-overlap -no-const-strings -no-multiline -warn-protos -threads -double-size-32 -decls-strong -cplbs -sdram -no-utility-rom


    -proc ADSP-BF707 -si-revision 1.1 -TZ:/somedir/system/startup_ldf/app.ldf -no-mem -map -LZ:/somedir/system/startup_ldf -LZ:/somedir/libs ../libs/somelib.a -flags-link -MD__ADI_FREERTOS -flags-link -e -flags-link -ev -add-debug-libpaths -threads -flags-link -MDNO_LIBDRV -flags-link -MDUSE_SDRAM -no-utility-rom

    Are there any implicit settings that lead to this incompatibility?

    We also detected another incompatibility:

    [Error li1050]  '_cplb_mgr' ('cplb_mgr'): Multiply defined symbol in processor 'P0'.
            Initial definition:     'libevent.dlb[cplbmgr.doj]'
            Attempted redefinition: 'libeventmt.dlb[cplbmgr.doj]'

    Best regards,

  • Hi Matthias,

    For the profiling, the original error message indicates they are being referenced by osal_thread_cycles.doj. The source of which contains 2 API's:


    Can you check if you are referencing them from somewhere, or linking against the osal_thread_cycles.doj object?
    If the -p switch was used previously, then there may be a call to them in an intermediate file but a clean should take care of that.

    For the cplb_mgr link error, it looks like you are linking against both the threaded (libeventmt.dlb) and the non-threaded (libevent.dlb) version of the same library, which means most symbols will conflict. Since you are using threads, you should not be linking against the non "mt" version for libevent.