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: Bug in exception decoders in ExceptionArmV8M.c

Part Number: CC3551E

Hi,

During my debugging sessions on the CC35x1 LaunchPad (Rev E3) with SimpleLink Wi-Fi SDK (9_19_00_02_ea), I've stumbled over the exception decoding in "\simplelink_wifi_sdk_9_19_00_02_ea\kernel\freertos\exception\ExceptionArmV8M.c" - e.g. 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)");
    }

The bfsr variable/value is extracted nicely, masked and shifted down. But all the if-else clauses below use masks, e.g. SCB_CFSR_STKERR_Msk, that include the same amount of masks and shifts which should be applied directly on the SCB->CFSR register instead:

#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]


That is, "bfsr" should be removed entirely and the if-else clauses should use SCB->CFSR directly:

/*
 *  ======== 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)");
    }

The same goes for Exception_decodeUsageFault().
(and just for symmetry, also for Exception_decodeMemFault(), but there the shifts are zero, so no harm done.)

Right?

  • Hi Martin,

    Thank you for pointing this out - the bits are indeed misaligned, especially when our code is comparing an 8-bit value (bfsr) and a 16-bit value (SCB_CFSR_XERR_Msk).

    A temporary solution is to turn bfsr into a 16-bit value and not shift it down, or keep the 8-bit value and shift down the mask. Your approach may work too.