进入休眠后一段时间触发DBG_Trigger_IRQHandler中断断言卡死

sf32lb52锂电池供电版本的模组,sdk版本: v2.4

问题描述:挂起所有线程和定时器后进入deepsleep,一段时间后十分钟到几时分钟后有概率触发DBG_Trigger_IRQHandler断言卡死。

下面是串口log

[07/09/2025 13:42:22.675] [7194082] D/NO_TAG power_mb: [APP][POWER] Received power message: type=0
[07/09/2025 13:42:22.678] [7194111] I/APP.FWK.PM power_mb: fsm:Cur[GUI_STATE_ACTIVE],Action[GUI_PM_ACTION_SLEEP]
[07/09/2025 13:42:22.678] [7194147] I/APP.FWK.PM power_mb: change_gui_state:[GUI_STATE_ACTIVE]->[GUI_STATE_INACTIVE_PENDING]
[07/09/2025 13:42:22.678] [7194189] I/NO_TAG power_mb: GUI_PM_EVT_SUSPEND
[07/09/2025 13:42:22.679] [7194210] I/NO_TAG power_mb: [APP][SLEEP] Processing sleep en[07/09/2025 13:42:22.680] 
                          [07/09/2025 13:42:22.680] [7194482] I/NO_TAG power_mb: [APP][SLEEP] Sleep enter successfully
[07/09/2025 13:42:22.710] [7194511] I/APP.FWK.PM main: change_gui_state:[GUI_STATE_INACTIVE_PENDING]->[GUI_STATE_INACTIVE]
[07/09/2025 13:42:22.710] [7194550] I/APP.FWK.PM main: gui_suspend
[07/09/2025 13:42:22.710] [7194570] I/drv.lcd lcd_task: Power off
[07/09/2025 13:42:22.710] [7194589] I/drv.epic lcd_task: drv_gpu closed.
[07/09/2025 13:42:22.710] [7194610] I/drv.lcd lcd_task: display off
[07/09/2025 13:42:22.710] [7194629] I/NO_TAG lcd_task: Set lcdlight 0
[07/09/2025 13:42:22.710] [7194651] I/drv.lcd lcd_task: backligt_set 0
[07/09/2025 13:42:22.710] [7194675] I/drv.lcd lcd_task: [ON] -> [OFF]
[07/09/2025 13:42:22.710] [7194695] I/drv.lcd lcd_task: HW close
[07/09/2025 13:42:22.710] [7194713] I/drv.lcd lcd_task: HW close done.
[07/09/2025 13:42:22.710] [7194733] I/drv.lcd lcd_task: Power off done
[07/09/2025 13:42:22.710] [pm]S:3,7194773
[07/09/2025 13:45:01.165] [pm]W:12387578
[07/09/2025 13:45:01.165] [pm]WSR:0x4
[07/09/2025 13:45:01.165] [pm]S:3,12387602
[07/09/2025 13:52:55.636] [27935466] E/mw.sys ISR: Crash triggered
[07/09/2025 13:52:55.637] Assertion failed at function:DBG_Trigger_IRQHandler, line number:361 ,(0)
[07/09/2025 13:52:55.643] Previous ISR enable 1
[07/09/2025 13:52:55.643] ===================
[07/09/2025 13:52:55.643] Thread Info        
[07/09/2025 13:52:55.652] ===================
[07/09/2025 13:52:55.652]          pri  status      sp      top     stack size max used left tick  error
[07/09/2025 13:52:55.652] -------- ---  ------- ---------- ---------- ----------  ------  ---------- ---
[07/09/2025 13:52:55.652] KE_EVT3   10  suspend 0x20028538 0x200285ac 0x00000400    25%   0x0000000d 000
[07/09/2025 13:52:55.652] KE_EVT0   25  suspend 0x20028080 0x200280f8 0x00000400    12%   0x00000014 000
[07/09/2025 13:52:55.652] KE_EVT2   12  suspend 0x20027b48 0x20027c44 0x00001000    25%   0x00000003 000
[07/09/2025 13:52:55.663] power_mb  25  suspend 0x2001fa18 0x2001fb24 0x00001000    19%   0x0000000b 000
[07/09/2025 13:52:55.663] app_ble_  20  suspend 0x2001e8c0 0x2001e9d0 0x00000800    37%   0x00000006 000
[07/09/2025 13:52:55.663] lcd_task  12  suspend 0x2000ffb8 0x2001011c 0x00000800    45%   0x00000009 000
[07/09/2025 13:52:55.663] tshell    20  suspend 0x2001c6e0 0x2001c85c 0x00001000    16%   0x0000000a 000
[07/09/2025 13:52:55.663] ds_proc   14  suspend 0x20013b98 0x20013c34 0x00001000    03%   0x00000009 000
[07/09/2025 13:52:55.663] tidle     31  ready   0x20015f10 0x20015ff0 0x00000800    34%   0x00000006 000
[07/09/2025 13:52:55.663] timer      4  suspend 0x20010840 0x2001091c 0x00000800    59%   0x00000003 000
[07/09/2025 13:52:55.663] main      10  suspend 0x2001a0f0 0x2001a200 0x00002000    29%   0x00000009 000
[07/09/2025 13:52:55.663] ===================
[07/09/2025 13:52:55.663] Mailbox Info       
[07/09/2025 13:52:55.663] ===================
[07/09/2025 13:52:55.663]          entry size suspend thread
[07/09/2025 13:52:55.663] -------- ----  ---- --------------
[07/09/2025 13:52:55.663] app_ble_ 0000  0008 1:app_ble_
[07/09/2025 13:52:55.663] power_mb 0000  0016 1:power_mb
[07/09/2025 13:52:55.663] ===================
[07/09/2025 13:52:55.663] MessageQueue Info  
[07/09/2025 13:52:55.663] ===================
[07/09/2025 13:52:55.663]          entry suspend thread
[07/09/2025 13:52:55.663] -------- ----  --------------
[07/09/2025 13:52:55.663] uisrv    0000  0
[07/09/2025 13:52:55.663] drv_lcd  0000  1:lcd_task�
[07/09/2025 13:52:55.663] dserv    0000  1:ds_proc
[07/09/2025 13:52:55.663] ===================
[07/09/2025 13:52:55.663] Mutex Info         
[07/09/2025 13:52:55.663] ===================
[07/09/2025 13:52:55.663]            owner  hold suspend thread
[07/09/2025 13:52:55.674] -------- -------- ---- --------------
[07/09/2025 13:52:55.678] ble_flas (null)   0000 0
[07/09/2025 13:52:55.678] ui_pm    (null)   0000 0
[07/09/2025 13:52:55.678] dserv    (null)   0000 0
[07/09/2025 13:52:55.678] ulog loc (null)   0000 0
[07/09/2025 13:52:55.678] fslock   (null)   0000 0
[07/09/2025 13:52:55.678] i2c_bus_ (null)   0000 0
[07/09/2025 13:52:55.678] spi1     (null)   0000 0
[07/09/2025 13:52:55.678] ===================
[07/09/2025 13:52:55.678] Semaphore Info     
[07/09/2025 13:52:55.678] ===================
[07/09/2025 13:52:55.678]          v   suspend thread
[07/09/2025 13:52:55.678] -------- --- --------------
[07/09/2025 13:52:55.678] KE       000 1:KE_EVT3
[07/09/2025 13:52:55.678] KE       000 1:KE_EVT0
[07/09/2025 13:52:55.678] KE       000 1:KE_EVT2
[07/09/2025 13:52:55.678] sifli    000 0
[07/09/2025 13:52:55.678] ui_pm    000 1:main
[07/09/2025 13:52:55.678] lv_data  001 0
[07/09/2025 13:52:55.678] lv_lcd   001 0
[07/09/2025 13:52:55.678] lcd_msg  000 0
[07/09/2025 13:52:55.678] lcd_draw 000 0
[07/09/2025 13:52:55.678] drv_lcd  001 0
[07/09/2025 13:52:55.678] shrx     000 0
[07/09/2025 13:52:55.678] epic     001 0
[07/09/2025 13:52:55.678] aes_drv  001 0
[07/09/2025 13:52:55.678] drv_eDma 001 0
[07/09/2025 13:52:55.678] gpadc    001 0
[07/09/2025 13:52:55.678] i2c2     000 0
[07/09/2025 13:52:55.678] spi1     000 0
[07/09/2025 13:52:55.678] heap     001 0
[07/09/2025 13:52:55.678] flash2   001 0
[07/09/2025 13:52:55.678] ===================
[07/09/2025 13:52:55.678] Memory Info     
[07/09/2025 13:52:55.678] ===================
[07/09/2025 13:52:55.678] total memory: 425092 used memory : 62740 maximum allocated memory: 77876
[07/09/2025 13:52:55.687] ===================
[07/09/2025 13:52:55.687] MemoryHeap Info     
[07/09/2025 13:52:55.687] ===================
[07/09/2025 13:52:55.687]          pool size  max used size available size
[07/09/2025 13:52:55.687] ------- ---------- ------------- --------------
[07/09/2025 13:52:55.687] =====================
[07/09/2025 13:52:55.687] PSP: 0x0x20015f20, MSP: 0x0x20001f54
[07/09/2025 13:52:55.687] =====================
[07/09/2025 13:52:55.687]  sp: 0x20001fb0
[07/09/2025 13:52:55.687] psr: 0x80000002
[07/09/2025 13:52:55.687] r00: 0x120be629
[07/09/2025 13:52:55.687] r01: 0x1213d33d
[07/09/2025 13:52:55.687] r02: 0x00000169
[07/09/2025 13:52:55.687] r03: 0xc0000000
[07/09/2025 13:52:55.687] r12: 0x12089f81
[07/09/2025 13:52:55.687]  lr: 0x1207a85f
[07/09/2025 13:52:55.687]  pc: 0x1207a85f
[07/09/2025 13:52:55.687] =====================
[07/09/2025 13:52:55.687] fatal error on ISR

休眠后HCPU被自动唤醒了几次,查看手册0X4是低功耗定时器唤醒,不清楚是不是被lcpu的ble协议栈唤醒的。看样子是在被唤醒后再次进入休眠的时候触发了断言

[07/09/2025 13:42:22.710] [pm]S:3,7194773

[07/09/2025 13:45:01.165] [pm]W:12387578

[07/09/2025 13:45:01.165] [pm]WSR:0x4

[07/09/2025 13:45:01.165] [pm]S:3,12387602

好奇怪的问题,这个断言触发是个概率性事件。

void app_sleep_enter()
{
    LOG_I("[APP][SLEEP] Processing sleep enter begin");

    app_power_env_t *app_power_env = app_power_get_env();

    app_power_env->is_sleeping = true;

    app_power_env->LastButtonTime = rt_tick_get_millisecond();

    app_button_enter_sleep();

    lv_timer_enable(false);

    rt_timer_stop(app_power_env->update_timer);

    rt_hw_watchdog_set_status(0);

    LOG_I("[APP][SLEEP] Sleep enter successfully");
}

void app_sleep_exit()
{
    LOG_I("[APP][SLEEP] Processing sleep exit begin");

    app_power_env_t *app_power_env = app_power_get_env();

    app_power_env->is_sleeping = false;

    app_power_env->LastButtonTime = rt_tick_get_millisecond();

    app_power_env->system_tick_ms = rt_tick_get_millisecond();

    rt_hw_watchdog_set_status(1);

    lv_timer_enable(true);

    rt_timer_start(app_power_env->update_timer);

    // rt_thread_mdelay(200);

    app_button_exit_sleep();
}

void app_sleep_pm_callback(gui_pm_event_type_t event)
{
    switch (event)
    {
    case GUI_PM_EVT_SUSPEND:
    {
        LOG_I("GUI_PM_EVT_SUSPEND");
        app_sleep_enter();
        break;
    }
    case GUI_PM_EVT_RESUME:
    {
        LOG_I("GUI_PM_EVT_RESUME");
        app_sleep_exit();
        break;
    }
    default:
    {
        RT_ASSERT(0);
    }
    }
}


const pm_policy_t pm_policy[] =
{
#ifdef PM_STANDBY_ENABLE
#ifdef SOC_BF0_HCPU
    {100, PM_SLEEP_MODE_STANDBY},
#else
    {10, PM_SLEEP_MODE_STANDBY},
#endif /* SOC_BF0_HCPU */
#elif defined(PM_DEEP_ENABLE)
#ifdef SOC_BF0_HCPU
    {300, PM_SLEEP_MODE_DEEP},
#else
    {10, PM_SLEEP_MODE_DEEP},
#endif /* SOC_BF0_HCPU */
#else
#ifdef SOC_BF0_HCPU
    {100, PM_SLEEP_MODE_LIGHT},
#else
    {15, PM_SLEEP_MODE_LIGHT},
#endif /* SOC_BF0_HCPU */
#endif /* PM_STANDBY_ENABLE */
};

///////////////////////////////
static int cmd_sleep_enter(int argc, char **argv)
{
    rt_kprintf("Entering sleep mode...\n");

    // 直接发送休眠消息
    rt_err_t result = rt_mb_send(app_power_get_env()->mb_handle, (rt_uint32_t)POWER_MSG_SLEEP_ENTER);
    if (result != RT_EOK)
    {
        rt_kprintf("Failed to send sleep enter message: %d\n", result);
        return -1;
    }

    rt_kprintf("Sleep enter message sent successfully\n");
    return 0;
}
MSH_CMD_EXPORT_ALIAS(cmd_sleep_enter, sleep_enter, Enter sleep mode);

**唤醒源为按键,触发中断后发生信息到邮箱,邮箱调用gui_pm_fsm(GUI_PM_ACTION_WAKEUP);然后再调用app_sleep_exit执行唤醒操作 **

static void gpio_wakeup_handler(void *args)
{
    rt_err_t result = rt_mb_send(app_power_get_env()->mb_handle, (rt_uint32_t)POWER_MSG_SLEEP_EXIT);
    if (result != RT_EOK)
    {
        LOG_E("[APP][BUTTON] Failed to send power message: type=%d, result=%d", POWER_MSG_SLEEP_EXIT, result);
    }
    else
    {
        rt_pin_irq_enable(CONFIG_KEY_COM_Pin, 0);
    }
}

static void power_mailbox_thread_entry(void *parameter)
{
    rt_uint32_t msg_type;
    rt_err_t result;

    LOG_I("[APP][POWER] Power mailbox thread started");

    while (1)
    {
        // 等待邮箱消息
        result = rt_mb_recv(app_power_env.mb_handle, &msg_type, RT_WAITING_FOREVER);
        if (result != RT_EOK)
        {
            LOG_E("[APP][POWER] Failed to receive mailbox message: %d", result);
            continue;
        }

        LOG_D("[APP][POWER] Received power message: type=%d", msg_type);

        // 根据消息类型处理
        switch (msg_type)
        {
        case POWER_MSG_SLEEP_ENTER:
            gui_pm_fsm(GUI_PM_ACTION_SLEEP);
            break;

        case POWER_MSG_SLEEP_EXIT:
            gui_pm_fsm(GUI_PM_ACTION_WAKEUP);
            break;

        case POWER_MSG_POWER_OFF:
            app_enter_hibernate();
            break;

        default:
            LOG_W("[APP][POWER] Unknown power message type: %d", msg_type);
            break;
        }
    }
}

您好,请问是在哪个例程碰到如上的问题,这边尝试复现一下

或者这边给我提供一个最小的复现工程,具体的分析可能需要导出现场分析

如果可以的话,方便导个现场给我们进行分析:死机分析指南 - SiFli SDK编程指南 文档

问题已解决

CONFIG_BSP_USING_WDT2_SWITCH is not set

就好了 暂时不知道为什么