forked from ROMEO/obsw
handling failed freeRTOS assertion as panic
This commit is contained in:
parent
c9a81c025f
commit
a7336c7f75
@ -241,6 +241,7 @@ void vApplicationMallocFailedHook(void) {
|
||||
timers, and semaphores. The size of the FreeRTOS heap is set by the
|
||||
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
//TODO panic
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
@ -254,6 +255,7 @@ void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName) {
|
||||
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
|
||||
function is called if a stack overflow is detected. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
//TODO panic
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
@ -277,7 +279,14 @@ void vApplicationIdleHook(void) {
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void rust_assert_called(const char *pcFile, unsigned long ulLine);
|
||||
|
||||
|
||||
void vAssertCalled(const char *pcFile, unsigned long ulLine) {
|
||||
|
||||
rust_assert_called(pcFile, ulLine);
|
||||
|
||||
|
||||
volatile unsigned long ul = 0;
|
||||
|
||||
(void)pcFile;
|
||||
|
@ -21,8 +21,10 @@ fn panic(panic: &PanicInfo<'_>) -> ! {
|
||||
osal::stop_it();
|
||||
}
|
||||
// TODO: Make this unicode-safe
|
||||
sif!("In Task \"");
|
||||
sifln!("");
|
||||
sif!("in task \"");
|
||||
unsafe {
|
||||
//TODO is from_ptr safe enough?
|
||||
let task_name = core::ffi::CStr::from_ptr(osal::get_task_name());
|
||||
let task_name_utf8 = core::str::from_utf8(task_name.to_bytes());
|
||||
match task_name_utf8 {
|
||||
@ -41,6 +43,25 @@ fn panic(panic: &PanicInfo<'_>) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn rust_assert_called(ptr: *const core::ffi::c_char, line: core::ffi::c_ulong) {
|
||||
let file_name = unsafe {
|
||||
//TODO is from_ptr safe enough?
|
||||
let file_name = core::ffi::CStr::from_ptr(ptr);
|
||||
let file_name_utf8 = core::str::from_utf8(file_name.to_bytes());
|
||||
match file_name_utf8 {
|
||||
Ok(string) => {
|
||||
string
|
||||
}
|
||||
Err(_) => {
|
||||
"Schei<EFBFBD> Encoding"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
panic!("assertion failed at {file_name}:{}", line);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn rust_main() {
|
||||
sifln!("Rust startup 🚀");
|
||||
|
Loading…
x
Reference in New Issue
Block a user