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.

CC1310: TICLANG Compiler & Code Composer Studio (& CMake)

Part Number: CC1310

I am having some issues getting any CC1310 based example code to compile when using the CLang compiler (v3.2.1.LTS). My end goal is to build my code using CMake thanks to a recent addition by Alan Phipps at TI (CMake addition here). I am to the point that I am getting identical errors between CCS and CMake, but for now we can ignore the CMake portion.

When opening the `rfPacketRx` demo within CCS, I can initially compile without issue using the TI v20.2.7LTS compiler, however if I go to the project properties and update the compiler to use TI Clang v3.2.1.LTS I start getting error saying that parameter references within a `naked` function are not allowed. (I'm getting the same errors when invoking the build via CMake as well)

/home/stephen/ti/simplelink_cc13x0_sdk_4_20_02_07/source/ti/devices/cc13x0/driverlib/cpu.h:373:28: error: parameter references not allowed in naked functions
                    : "r" (ui32NewBasepri)
                           ^
/home/stephen/ti/simplelink_cc13x0_sdk_4_20_02_07/source/ti/devices/cc13x0/driverlib/cpu.h:366:38: note: attribute is here
__STATIC_INLINE void __attribute__ ((naked))

When digging into the files, it then becomes apparent that the `__TI_COMPILER_VERSION__` macro is not being defined or used. 

//*****************************************************************************
//
//! \brief Update the interrupt priority disable level.
//!
//! Use this function to change the level of priority that will disable
//! interrupts with a lower priority level.
//!
//! \param ui32NewBasepri is the new basis priority level to set.
//!
//! \return None
//
//*****************************************************************************
#if defined(DOXYGEN)
__STATIC_INLINE void
CPUbasepriSet(uint32_t ui32NewBasepri)
{
    // This function is written in assembly. See cpu.h for compiler specific implementation.
}
#elif defined(__IAR_SYSTEMS_ICC__)
__STATIC_INLINE void
CPUbasepriSet(uint32_t ui32NewBasepri)
{
    // Set the BASEPRI register.
    __asm("    msr     BASEPRI, r0\n");
}
#elif defined(__CC_ARM) || defined(__ARMCC_VERSION)
__asm __STATIC_INLINE void
CPUbasepriSet(uint32_t ui32NewBasepri)
{
    // Set the BASEPRI register.
    msr     BASEPRI, r0;
    bx      lr
}
#elif defined(__TI_COMPILER_VERSION__)
__STATIC_INLINE void
CPUbasepriSet(uint32_t ui32NewBasepri)
{
    // Set the BASEPRI register.
    __asm("    msr     BASEPRI, r0\n");
}
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
__STATIC_INLINE void __attribute__ ((naked))
CPUbasepriSet(uint32_t ui32NewBasepri)
{
    // Set the BASEPRI register.
    __asm volatile ("    msr     BASEPRI, %0\n"
                    "    bx      lr\n"
                    : /* No output */
                    : "r" (ui32NewBasepri)
                   );
}
#pragma GCC diagnostic pop
#endif

I can manually define the version macro myself (yikes) and I get a bit further but then there are compiler warnings about legacy pragmas being used in the example source which are not supported in ticlang. I'll solve that when I get to it, but I'd like to figure out why the compiler version isn't being set.

Any help is greatly appreciated. Thanks!

-Stephen

  • I should add that after trying to debug this further I did just discover that the ARM GCC toolchain can also be used and there are examples provided in the SimpleLink SDK using Make. Which means it should be a relatively short putt for me to get a CMake project working. I hadn't seen that this was possible and I will be diving into this path now. I'm still curious to find what my problem is with using CLang in CCS though.

  • Hi Stephen,

    I am not surprised about what you are seeing, as I do not think we ever added support of LLVM/TI CLANG for the CC1310 example projects.

    Thus, if you want to support CMake on the CC1310, GCC would be the preferred way to go.

    If you want some inspiration, please have a look at our LOWPOWER-F2 (cc13x2_cc26x2) SDK on Github, it is also CMake enabled.

    Regards,

    Arthur

  • Thanks Arthur! After my last message I was able to port an existing template I have for other ARM projects and use the Makefile as a guide for filling it out. It looks to work great and I have the TX and RX examples running on two boards talking to one another. 

    It is curious though that under `Supported Hardware` on the ARM CLANG download page, it lists the CC1310 as supported hardware.

    https://www.ti.com/tool/download/ARM-CGT-CLANG/3.2.2.LTS

    Regardless, I'll mark this as solved.. Ish.. Even if the part isn't supported it's interesting that it failed because the __TI_COMPILER_VERSION__ macro wasn't being defined.

    Thanks again!