diff --git a/os/board/bk7239n/src/components/bk_init/components_init.c b/os/board/bk7239n/src/components/bk_init/components_init.c index 118222a879..c05ff9c37a 100755 --- a/os/board/bk7239n/src/components/bk_init/components_init.c +++ b/os/board/bk7239n/src/components/bk_init/components_init.c @@ -52,9 +52,7 @@ #include #endif -#if defined(CONFIG_TFM_S_TO_NS_DUMP_ENABLE) #include "tfm_aes_gcm_nsc.h" -#endif #include "os/mem.h" #include "cmsis_gcc.h" @@ -344,9 +342,8 @@ int components_init(void) //wdt_init(); #endif -#if defined(CONFIG_TFM_S_TO_NS_DUMP_ENABLE) && defined(CONFIG_SECURITY_LEVEL) extern void bk_security_to_nosecurity_dump_register_callback(void); bk_security_to_nosecurity_dump_register_callback(); -#endif + return BK_OK; } diff --git a/os/board/bk7239n/src/middleware/arch/cm33/trap_base.c b/os/board/bk7239n/src/middleware/arch/cm33/trap_base.c index 024dd0e181..4d3a489934 100755 --- a/os/board/bk7239n/src/middleware/arch/cm33/trap_base.c +++ b/os/board/bk7239n/src/middleware/arch/cm33/trap_base.c @@ -684,8 +684,6 @@ static void arch_dump_cpu_registers_securt_fault(uint32_t mcause, SAVED_CONTEXT } } - -#if defined(CONFIG_TFM_S_TO_NS_DUMP_ENABLE) && defined(CONFIG_SECURITY_LEVEL) //#include "tfm_aes_gcm_nsc.h" #include #define FRAME_BUF_LEN (64) @@ -813,31 +811,38 @@ static void NS_handle_securt_fault(uint32_t reset_reason, struct tfm_exception_i /* Handled Trap */ g_enter_exception = 1; - +#ifdef CONFIG_TFM_S_TO_NS_DUMP_ENABLE rtos_dump_system(msp, psp); - - +#endif +#ifdef CONFIG_SYSTEM_REBOOT_REASON up_reboot_reason_write(BK_SECURE_FAULT_REBOOT_REASON); - bk_reboot_reset_reason(); +#endif + PANIC(); while(g_enter_exception); // rtos_enable_int(int_level); } else { +#ifdef CONFIG_SYSTEM_REBOOT_REASON up_reboot_reason_write(BK_SECURE_FAULT_REBOOT_REASON); - bk_reboot_reset_reason(); +#endif + PANIC(); } } void bk_security_donmain_notifies_non_security_domain_to_dump(uint32_t *reg) { // High security level will not dump the exception information. +#ifdef CONFIG_SECURITY_LEVEL if (get_security_level() > LOW_SECURITY_LEVEL) { +#ifdef CONFIG_SYSTEM_REBOOT_REASON up_reboot_reason_write(BK_SECURE_FAULT_REBOOT_REASON); - bk_reboot_reset_reason(); +#endif + PANIC(); return; } +#endif struct tfm_exception_info_t *ctx = &tfm_exception_info; @@ -896,7 +901,6 @@ void bk_security_to_nosecurity_dump_register_callback(void) uint32_t callback_address = (uint32_t)(&bk_security_donmain_notifies_non_security_domain_to_dump); psa_register_dump_callback(callback_address, (uint32_t)&tfm_exception_info); } -#endif /* if mpu enable, accessing itcm zero pointer violates the mpu rule, please refer to mpu_cfg * if mpu disable, null pointer/zero pointer maybe is a software fault. So bk_null_trap_handler