static rt_err_t exception_hook(void *context) { struct exception_stack_frame { rt_uint32_t r0; rt_uint32_t r1; rt_uint32_t r2; rt_uint32_t r3; rt_uint32_t r12; rt_uint32_t lr; rt_uint32_t pc; rt_uint32_t psr; }; struct exception_stack_frame *exception_stack = (struct exception_stack_frame *) context; elog_output_lock_enabled(false); //elog_flash_lock_enabled(false); elog_e("hw_fault", "psr: 0x%08x", exception_stack->psr); elog_e("hw_fault", " pc: 0x%08x", exception_stack->pc); elog_e("hw_fault", " lr: 0x%08x", exception_stack->lr); elog_e("hw_fault", "r12: 0x%08x", exception_stack->r12); elog_e("hw_fault", "r03: 0x%08x", exception_stack->r3); elog_e("hw_fault", "r02: 0x%08x", exception_stack->r2); elog_e("hw_fault", "r01: 0x%08x", exception_stack->r1); elog_e("hw_fault", "r00: 0x%08x", exception_stack->r0); elog_e("hw_fault", "hard fault on thread: %s", rt_thread_self()->name); //elog_flash_flush(); return RT_EOK; }
static void rtt_user_assert_hook(const char* ex, const char* func, rt_size_t line) { elog_output_lock_enabled(false); // elog_flash_lock_enabled(false); elog_a("rtt", "(%s) has assert failed at %s:%ld.\n", ex, func, line); // elog_flash_flush(); while(1); }
static void elog_user_assert_hook(const char* ex, const char* func, size_t line) { rt_enter_critical(); /* disable logger output lock */ elog_output_lock_enabled(false); /* disable flash plugin lock */ elog_flash_lock_enabled(false); /* output assert information */ elog_a("elog", "(%s) has assert failed at %s:%ld.\n", ex, func, line); /* write all buffered log to flash */ elog_flash_flush(); while(1); }