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 编译器&Code Composer Studio (&CMake)

Guru**** 1112110 points
Other Parts Discussed in Thread: CC1310
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1340171/cc1310-ticlang-compiler-code-composer-studio-cmake

器件型号:CC1310

使用 clang 编译器(v3.2.1.LTS)时、在编译任何基于 CC1310的示例代码时遇到一些问题。 由于 Alan Phipps 在 TI 最近新增了内容(在此处增加了 CMake)、因此我的最终目标是使用 CMake 来构建我的代码。 我认为 CCS 和 CMake 之间存在相同的错误、但现在我们可以忽略 CMake 部分。

在 CCS 中打开`rfPacketRx`演示时、我最初可以使用 TI v20.2.7LTS 编译器毫无问题地进行编译、但是、如果我转到工程属性并更新编译器以使用 TI Clang v3.2.1.LTS、我开始收到错误消息、说不允许`naked`函数中的参数引用。 (也通过 CMake 调用编译时会出现相同的错误)

/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))

在挖入文件时、很明显未定义或使用`__TI_Compiler_version__`宏。  

//*****************************************************************************
//
//! \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

我可以自行手动定义版本宏(yikes)、再进一步一点、但随后有编译器警告、说明示例源代码中使用了非 ticlang 支持的传统 pragma。 我将在开始时解决这个问题、但我想弄清楚为什么编译器版本未设置。

非常感谢任何帮助。 谢谢!

-斯蒂芬

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我应该添加说明、在进一步调试之后、我发现也可以使用 ARM GCC 工具链、并且 SimpleLink SDK 中提供了使用 make 的示例。 这意味着、为了让 CMake 项目正常工作、这应该是一个相对较短的推送。 我没见过这是可能的,我现在将潜水到这条路。 不过、我仍想知道在 CCS 中使用 CLANG 有什么问题。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Stephen:

    我对您看到的情况并不感到惊讶、因为我认为我们从未为 CC1310示例项目添加过对 LLVM/TI CLANG 的支持。

    因此、如果要在 CC1310上支持 CMake、GCC 是更优选择。

    如果您想要获得一些灵感、请查看 Github 上的 LOWPOWER-F2 (cc13x2_cc26x2) SDK、它还启用了 CMake。

    此致、

    亚瑟

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢 Arthur! 在最后一条消息之后、我能够移植适用于其他 ARM 工程的现有模板、并使用 Makefile 作为填写指南。 它看上去工作得很好、我在两个板上运行 TX 和 RX 示例、可实现相互通信。  

    `S奇怪的是、在 ARM clang 下载页面的"支持的硬件`支持"下、CC1310列为支持的硬件。

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

    不管怎样,我会把这个标记为已解决。 不怎么样 有趣的是、即使该器件不受支持、也会因为未定义__TI_Compiler_version__宏而失败。

    再次感谢!