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.

[参考译文] CC3551E:ExceptionArmV8m.c 中异常解码器中的错误

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

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1594568/cc3551e-bug-in-exception-decoders-in-exceptionarmv8m-c

器件型号: CC3551E

您好、

就可以在 CC35x1 LaunchPad 上的调试会话中看到  (Rev E3) 使用 SimpleLink Wi-Fi SDK (9_19_00_02_ea)、我无意中发现了“\simplelink_wifi_sdk_9_19_00_02_ea\kernel\freertos\exception\ExceptionArmV8m.c"中“中的中的异常解码 — 例如,exception_decodeBusFault:

/*
 *  ======== Exception_decodeBusFault ========
 */
static void Exception_decodeBusFault(Exception_ExceptionContext *exceptionContext)
{
    uint8_t bfsr = (SCB->CFSR & SCB_CFSR_BUSFAULTSR_Msk) >> SCB_CFSR_BUSFAULTSR_Pos;

    /* Decode BFSR to determinte what kind of MemFault it is. */
    if (bfsr & SCB_CFSR_STKERR_Msk)
    {
        Log_printf(LogModule_Exception,
                   Log_ERROR,
                   "Exception_decodeBusFault: BusFault caused by stack push. (STKERR)");
    }

BFSR 变量/值被很好地提取、被屏蔽并向下移动。 但下面的所有 if-else 子句都使用掩码、例如 SCB_CFSR_STKERR_MSK、其中包含应直接应用于 SCB->CFSR 寄存器的相同数量掩码和移位:

#define SCB_CFSR_BUSFAULTSR_Pos             8U                                            /*!< SCB CFSR: Bus Fault Status Register Position */
#define SCB_CFSR_BUSFAULTSR_Msk            (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos)            /*!< SCB CFSR: Bus Fault Status Register Mask */

#define SCB_CFSR_STKERR_Pos               (SCB_CFSR_BUSFAULTSR_Pos + 4U)                  /*!< SCB CFSR (BFSR): STKERR Position */
#define SCB_CFSR_STKERR_Msk               (1UL << SCB_CFSR_STKERR_Pos)                    /*!< SCB CFSR (BFSR): STKERR Mask */

[simplelink_wifi_sdk_9_19_00_02_ea\source\ti\devices\cc35xx\cmsis\core\core_cm33.h]


也就是说、应完全删除“BFSR",“,if-else、if-else 子句应直接使用 SCB->CFSR:

/*
 *  ======== Exception_decodeBusFault ========
 */
static void Exception_decodeBusFault(Exception_ExceptionContext *exceptionContext)
{
    /* Decode BFSR to determinte what kind of MemFault it is. */
    if (SCB->CFSR & SCB_CFSR_STKERR_Msk)
    {
        Log_printf(LogModule_Exception,
                   Log_ERROR,
                   "Exception_decodeBusFault: BusFault caused by stack push. (STKERR)");
    }

exception_decodeUsageFault () 也是如此。
(而且只是为了对称,也对于 exception_decodeMemFault(),但是移位为零,所以没有造成伤害。

对吗?

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

    尊敬的 Martin:

    感谢您指出这一点 — 位确实未对齐,尤其是在我们的代码比较 8 位值 (BFSR) 和 16 位值 (SCB_CFSR XERR_MSK) 时。

    临时解决方案是将 BFSR 转换为 16 位值而不是将其向下移位、或者保留 8 位值并向下移位掩码。 您的方法也可能起作用。