pull/67/merge
grape-wzy 3 years ago committed by GitHub
commit 2dcf739f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -211,6 +211,9 @@ static void get_cur_thread_stack_info(uint32_t sp, uint32_t *start_addr, size_t
osRtxThread_t *thread = osRtxInfo.thread.run.curr; osRtxThread_t *thread = osRtxInfo.thread.run.curr;
*start_addr = (uint32_t)thread->stack_mem; *start_addr = (uint32_t)thread->stack_mem;
*size = thread->stack_size; *size = thread->stack_size;
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_ONEOS)
*start_addr = (uint32_t) os_task_self()->stack_begin;
*size = (os_uint32_t)((os_ubase_t)os_task_self()->stack_end - (os_ubase_t)os_task_self()->stack_begin);;
#endif #endif
} }
@ -238,6 +241,8 @@ static const char *get_cur_thread_name(void) {
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5) #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
osThreadId_t id = osThreadGetId(); osThreadId_t id = osThreadGetId();
return osThreadGetName(id); return osThreadGetName(id);
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_ONEOS)
return os_task_self()->name;
#endif #endif
} }

@ -0,0 +1,61 @@
#include "arch_interrupt.h"
#include "arch_exception.h"
#include "os_task.h"
#include <os_memory.h>
#include <os_spinlock.h>
#include <arch_interrupt.h>
#include "os_kernel_internal.h"
#include "os_errno.h"
#include "protocol.h"
#include "devdef.h"
#include "stdio.h"
#include "string.h"
#include <cm_backtrace.h>
void cm_backtrace_hard_fault_exception(uint32_t lr, uint32_t sp)
{
os_meminfo_t info;
OS_KERNEL_INIT();
OS_KERNEL_ENTER();
os_memory_info(&info);
os_kprintf("\r\nmemory info:\r\n");
os_kprintf("Used: %d maxUsed: %d total: %d\r\n\n", info.mem_used, info.mem_maxused, info.mem_total);
sh_show_task_info();
cm_backtrace_fault(*((uint32_t*)(cmb_get_sp() + sizeof(uint32_t) * 8)), cmb_get_sp() + sizeof(uint32_t) * 9);
while (1);
OS_KERNEL_EXIT();
}
os_err_t os_hw_hard_fault_exception_hook(void* context, os_size_t* msp, os_size_t* psp)
{
cm_backtrace_hard_fault_exception(0, 0);
return OS_EOK;
}
extern void os_hw_exception_install(os_err_t (*exception_handle)(void*, os_size_t*, os_size_t*));
int cmBacktrace_init(void)
{
char hardware[10];
memset(hardware, 0, sizeof(hardware));
sprintf(hardware, "%d", DAYB_HARD_VER);
/* CmBacktrace initialize */
cm_backtrace_init("oneos", hardware, FIRMWARE_VERSION);
/* set exception hook */
os_hw_exception_install(os_hw_hard_fault_exception_hook);
return OS_EOK;
}
OS_APP_INIT(cmBacktrace_init, OS_INIT_SUBLEVEL_LOW);

@ -29,18 +29,19 @@
#ifndef _CMB_CFG_H_ #ifndef _CMB_CFG_H_
#define _CMB_CFG_H_ #define _CMB_CFG_H_
/* print line, must config by user */ #include <os_types.h>
#define cmb_println(...) /* e.g., printf(__VA_ARGS__);printf("\r\n") or SEGGER_RTT_printf(0, __VA_ARGS__);SEGGER_RTT_WriteString(0, "\r\n") */ #include <os_task.h>
/* enable bare metal(no OS) platform */
/* #define CMB_USING_BARE_METAL_PLATFORM */ /* print line, must config by user */
#define cmb_println(...) os_kprintf(__VA_ARGS__);os_kprintf("\r\n")
/* enable OS platform */ /* enable OS platform */
/* #define CMB_USING_OS_PLATFORM */ #define CMB_USING_OS_PLATFORM
/* OS platform type, must config when CMB_USING_OS_PLATFORM is enable */ /* OS platform type, must config when CMB_USING_OS_PLATFORM is enable */
/* #define CMB_OS_PLATFORM_TYPE CMB_OS_PLATFORM_RTT or CMB_OS_PLATFORM_UCOSII or CMB_OS_PLATFORM_UCOSIII or CMB_OS_PLATFORM_FREERTOS or CMB_OS_PLATFORM_RTX5 */ #define CMB_OS_PLATFORM_TYPE CMB_OS_PLATFORM_ONEOS
/* cpu platform type, must config by user */ /* cpu platform type, must config by user */
#define CMB_CPU_PLATFORM_TYPE /* CMB_CPU_ARM_CORTEX_M0 or CMB_CPU_ARM_CORTEX_M3 or CMB_CPU_ARM_CORTEX_M4 or CMB_CPU_ARM_CORTEX_M7 */ #define CMB_CPU_PLATFORM_TYPE CMB_CPU_ARM_CORTEX_M0
/* enable dump stack information */ /* enable dump stack information */
/* #define CMB_USING_DUMP_STACK_INFO */ #define CMB_USING_DUMP_STACK_INFO
/* language of print information */ /* language of print information */
/* #define CMB_PRINT_LANGUAGE CMB_PRINT_LANGUAGE_ENGLISH(default) or CMB_PRINT_LANGUAGE_CHINESE */ #define CMB_PRINT_LANGUAGE CMB_PRINT_LANGUAGE_ENGLISH
#endif /* _CMB_CFG_H_ */ #endif /* _CMB_CFG_H_ */

@ -47,6 +47,7 @@
#define CMB_OS_PLATFORM_UCOSIII 2 #define CMB_OS_PLATFORM_UCOSIII 2
#define CMB_OS_PLATFORM_FREERTOS 3 #define CMB_OS_PLATFORM_FREERTOS 3
#define CMB_OS_PLATFORM_RTX5 4 #define CMB_OS_PLATFORM_RTX5 4
#define CMB_OS_PLATFORM_ONEOS 5
#define CMB_PRINT_LANGUAGE_ENGLISH 0 #define CMB_PRINT_LANGUAGE_ENGLISH 0
#define CMB_PRINT_LANGUAGE_CHINESE 1 #define CMB_PRINT_LANGUAGE_CHINESE 1
@ -339,6 +340,10 @@ if (!(EXPR)) \
extern char * vTaskName(void); extern char * vTaskName(void);
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5) #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
#include "rtx_os.h" #include "rtx_os.h"
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_ONEOS)
#include <os_types.h>
#include <os_task.h>
#include <os_util.h>
#else #else
#error "not supported OS type" #error "not supported OS type"
#endif /* (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTT) */ #endif /* (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTT) */

Loading…
Cancel
Save