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.

TI-15.4-STACK-GATEWAY-LINUX-SDK: Doubled declaration of MT_DEVICE_version_info variable

Part Number: TI-15.4-STACK-GATEWAY-LINUX-SDK

Hi,

I'm trying to compile my own application using TI 15.4 Stack Linux SDK (version 4.40.00.03) with CMake build system. I've encountered a linking problem during building of component api.

Declaration of struct mt_version_info MT_DEVICE_version_info is doubled in files mt_msg.c (only declared, not used) and api_mac.c (declared and used), both without extern or static modifiers. What I don't understand is why build using plain Makefiles is completed successfully, but building with CMake fails. In both cases the same compiler is used underneath: GCC 11.2.0 for aarch64-linux-gnu. Is this some kind of bug or a residue from previous versions?

Second question: is there a way to install SDK natively on Arm architecture? Execution of downloaded .run file is impossible, probably due to the required x64 architecture.

Regards,

Paweł

Edit:

Found another problem. Two functions are declared in appsrv.h (appsrv_deviceSensorDataUpdate and appsrv_deviceConfigUpdate) but they aren't defined anywhere:

Again, building with CMake. Building using Makefile is not a problem.

  • Hi Paweł,

    Can you share the CMake configuration you are using?

    Regards,
    Nikolaj

  • Hi,

    Building ApiMac:

    set(TI154STACK_LINUX_SDK_PATH /opt/ti/ti154stack_linux_x64_4_40_00_03/)
    
    add_library(ti154stack_linux_component_api
        ${TI154STACK_LINUX_SDK_PATH}/components/api/src/api_mac.c
        ${TI154STACK_LINUX_SDK_PATH}/components/api/src/mt_msg.c
        ${TI154STACK_LINUX_SDK_PATH}/components/api/src/mt_msg_dbg_core.c
        ${TI154STACK_LINUX_SDK_PATH}/components/api/src/mt_msg_dbg_load.c
        ${TI154STACK_LINUX_SDK_PATH}/components/api/src/mt_msg_ini.c
    )
    target_include_directories(ti154stack_linux_component_api PUBLIC
        ${TI154STACK_LINUX_SDK_PATH}/components/api/inc
        ${TI154STACK_LINUX_SDK_PATH}/components/common/inc
    )
    target_link_libraries(ti154stack_linux_component_api PRIVATE
        ti154stack_linux_component_common
    )

    Building application:

    add_executable(coll_ti154stack
        appsrv.c
        cllc.c
        cllc_linux.c
        collector.c
        csf_linux.c
        linux_main.c
        mac_util.c
        oad_protocol.c
    )
    target_include_directories(coll_ti154stack PUBLIC
        .
    )
    target_link_libraries(coll_ti154stack PRIVATE
        ti154stack_linux_component_common
        ti154stack_linux_component_api
        ti154stack_linux_component_nv
        pthread
    )
    target_compile_definitions(coll_ti154stack
        PRIVATE AUTO_START
        PRIVATE NV_RESTORE
        PRIVATE PROCESS_JS
        PRIVATE OAD_BLOCK_SIZE=128
        PRIVATE NV_LINUX
        PRIVATE NVOCMP_NVPAGES=4
        PRIVATE IS_HEADLESS
    )
    target_compile_options(coll_ti154stack
        PRIVATE -include ti_154stack_features.h
        PRIVATE -std=gnu99
        PRIVATE -ffunction-sections
    )
    target_link_options(coll_ti154stack
        PRIVATE -Wl,--gc-sections
    )

    I tried adding additional linker (-Wl,--gc-sections) and compiler (-ffunction-sections) flags found in the front_matter.mk and that helped for declared but not defined functions from the appsrv.h but not for the MT_DEVICE_version_info variable. I also tried the -fdata-sections compiler switch but without success.

    Finding a solution for me is less important than pointing a potential bug which hopefully will be corrected in future versions of this SDK. Commenting out the declaration in mt_msg.c works fine as a workaround.

  • Hi Paweł,

    Thanks for the additional information. It could look like there might be an issue in the SDK, I will contact R&D regarding this to determine if this a problem with the SDK or something else. 

    I will get back to you, once I know more.

    Regards,
    Nikolaj

  • Hi Paweł,

    The two definitions of MT_DEVICE_version_info are "tentative definitions" and as mentioned here: https://stackoverflow.com/questions/67270121/why-can-i-define-a-variable-twice-in-c, this is not a problem for common compilers/linkers.

    In the CMake file, I see you are using -std=gnu99. In our make file, I do not see this option.

    Can you try to remove -std=gnu99 to see if you still get the linking errors?

    Also, I would suggest comparing the actual compiler commands generated by the Makefiles and by CMake, to see where they differ and it will make it easier for you to fix the linking issue. (Tip: if you change "HIDE ?= @" to "HIDE ?=" in front_matter.mak, then you will see the commands used to compile and link application/libraries.)

    This is not an issue in the SDK, this is just a compiler/linker issue.

    Regards,
    Nikolaj

  • Hi,

    Removing gnu99 standard didn't change anything. However "clean build" on "clean TI SDK", without any changes also led to problems with linkage (the same as above). I tried different SDKs - no difference. Then I tried different GCC versions - and here we have the guilty party: https://gcc.gnu.org/gcc-10/changes.html#:~:text=enabled%20by%20default.-,GCC,-now%20defaults%20to. Versions 9 and below works fine with this tentative declaration. 10 and above not, but adding -fcommon to the sources helps.

    Thanks for your response and explaination. For me leaving an unused declaration is still a bug and different behaviour on different GCC versions only confirms me in my opinion. I hope this information will help somebody in the future.