mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-10 06:54:19 +00:00
[FL-2892] Gui: update statusbar attention icon and better crash handling (#1908)
* Gui: update statusbar attention icon * Furi: snapshot registers on crash and restore in halt * Furi: document check routines
This commit is contained in:
parent
c1bb10a694
commit
f8af0c1509
6 changed files with 78 additions and 29 deletions
|
@ -152,7 +152,7 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
|||
}
|
||||
// Extra notification
|
||||
if(need_attention) {
|
||||
width = icon_get_width(&I_Attention_5x8);
|
||||
width = icon_get_width(&I_Hidden_window_9x8);
|
||||
// Prepare work area background
|
||||
canvas_frame_set(
|
||||
gui->canvas,
|
||||
|
@ -166,7 +166,7 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
|||
// Draw Icon
|
||||
canvas_frame_set(
|
||||
gui->canvas, x, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
||||
canvas_draw_icon(gui->canvas, 0, 0, &I_Attention_5x8);
|
||||
canvas_draw_icon(gui->canvas, 0, 0, &I_Hidden_window_9x8);
|
||||
// Recalculate next position
|
||||
left_used += (width + 2);
|
||||
x += (width + 2);
|
||||
|
|
BIN
assets/icons/StatusBar/Alert_9x8.png
Normal file
BIN
assets/icons/StatusBar/Alert_9x8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
BIN
assets/icons/StatusBar/Hidden_window_9x8.png
Normal file
BIN
assets/icons/StatusBar/Hidden_window_9x8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
|
@ -1,5 +1,5 @@
|
|||
entry,status,name,type,params
|
||||
Version,+,3.6,,
|
||||
Version,+,4.0,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
|
@ -260,6 +260,8 @@ Function,-,__eprintf,void,"const char*, const char*, unsigned int, const char*"
|
|||
Function,+,__errno,int*,
|
||||
Function,-,__fpclassifyd,int,double
|
||||
Function,-,__fpclassifyf,int,float
|
||||
Function,+,__furi_crash,void,
|
||||
Function,+,__furi_halt,void,
|
||||
Function,-,__getdelim,ssize_t,"char**, size_t*, int, FILE*"
|
||||
Function,-,__getline,ssize_t,"char**, size_t*, FILE*"
|
||||
Function,-,__isinfd,int,double
|
||||
|
@ -891,7 +893,6 @@ Function,-,ftello,off_t,FILE*
|
|||
Function,-,ftrylockfile,int,FILE*
|
||||
Function,-,funlockfile,void,FILE*
|
||||
Function,-,funopen,FILE*,"const void*, int (*)(void*, char*, int), int (*)(void*, const char*, int), fpos_t (*)(void*, fpos_t, int), int (*)(void*)"
|
||||
Function,+,furi_crash,void,const char*
|
||||
Function,+,furi_delay_ms,void,uint32_t
|
||||
Function,+,furi_delay_tick,void,uint32_t
|
||||
Function,+,furi_delay_until_tick,FuriStatus,uint32_t
|
||||
|
@ -1308,7 +1309,6 @@ Function,+,furi_hal_version_uid,const uint8_t*,
|
|||
Function,+,furi_hal_version_uid_size,size_t,
|
||||
Function,-,furi_hal_vibro_init,void,
|
||||
Function,+,furi_hal_vibro_on,void,_Bool
|
||||
Function,+,furi_halt,void,const char*
|
||||
Function,-,furi_init,void,
|
||||
Function,+,furi_kernel_get_tick_frequency,uint32_t,
|
||||
Function,+,furi_kernel_lock,int32_t,
|
||||
|
@ -2674,6 +2674,7 @@ Variable,+,A_iButton_14,const Icon,
|
|||
Variable,-,ITM_RxBuffer,volatile int32_t,
|
||||
Variable,+,I_125_10px,const Icon,
|
||||
Variable,+,I_ActiveConnection_50x64,const Icon,
|
||||
Variable,+,I_Alert_9x8,const Icon,
|
||||
Variable,+,I_ArrowC_1_36x36,const Icon,
|
||||
Variable,+,I_ArrowDownEmpty_14x15,const Icon,
|
||||
Variable,+,I_ArrowDownFilled_14x15,const Icon,
|
||||
|
@ -2741,6 +2742,7 @@ Variable,+,I_HeatHi_25x27,const Icon,
|
|||
Variable,+,I_HeatHi_hvr_25x27,const Icon,
|
||||
Variable,+,I_HeatLo_25x27,const Icon,
|
||||
Variable,+,I_HeatLo_hvr_25x27,const Icon,
|
||||
Variable,+,I_Hidden_window_9x8,const Icon,
|
||||
Variable,+,I_InfraredArrowDown_4x8,const Icon,
|
||||
Variable,+,I_InfraredArrowUp_4x8,const Icon,
|
||||
Variable,+,I_InfraredLearnShort_128x31,const Icon,
|
||||
|
@ -2841,6 +2843,7 @@ Variable,+,I_update_10px,const Icon,
|
|||
Variable,-,MSIRangeTable,const uint32_t[16],
|
||||
Variable,-,SmpsPrescalerTable,const uint32_t[4][6],
|
||||
Variable,+,SystemCoreClock,uint32_t,
|
||||
Variable,+,__furi_check_message,const char*,
|
||||
Variable,+,_ctype_,const char[],
|
||||
Variable,+,_global_impure_ptr,_reent*,
|
||||
Variable,+,_impure_ptr,_reent*,
|
||||
|
|
|
|
@ -11,6 +11,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
PLACE_IN_SECTION("MB_MEM2") const char* __furi_check_message = NULL;
|
||||
PLACE_IN_SECTION("MB_MEM2") uint32_t __furi_check_registers[12] = {0};
|
||||
|
||||
extern size_t xPortGetTotalHeapSize(void);
|
||||
extern size_t xPortGetFreeHeapSize(void);
|
||||
extern size_t xPortGetMinimumEverFreeHeapSize(void);
|
||||
|
@ -52,8 +55,10 @@ static void __furi_print_name(bool isr) {
|
|||
}
|
||||
}
|
||||
|
||||
static FURI_NORETURN void __furi_halt() {
|
||||
static FURI_NORETURN void __furi_halt_mcu() {
|
||||
register const void* r12 asm ("r12") = (void*)__furi_check_registers;
|
||||
asm volatile(
|
||||
"ldm r12, {r0-r11} \n"
|
||||
#ifdef FURI_DEBUG
|
||||
"bkpt 0x00 \n"
|
||||
#endif
|
||||
|
@ -61,22 +66,29 @@ static FURI_NORETURN void __furi_halt() {
|
|||
"wfi \n"
|
||||
"b loop%= \n"
|
||||
:
|
||||
:
|
||||
: "r" (r12)
|
||||
: "memory");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
FURI_NORETURN void furi_crash(const char* message) {
|
||||
FURI_NORETURN void __furi_crash() {
|
||||
register const void* r12 asm ("r12") = (void*)__furi_check_registers;
|
||||
asm volatile(
|
||||
"stm r12, {r0-r11} \n"
|
||||
:
|
||||
: "r" (r12)
|
||||
: "memory");
|
||||
|
||||
bool isr = FURI_IS_ISR();
|
||||
__disable_irq();
|
||||
|
||||
if(message == NULL) {
|
||||
message = "Fatal Error";
|
||||
if(__furi_check_message == NULL) {
|
||||
__furi_check_message = "Fatal Error";
|
||||
}
|
||||
|
||||
furi_hal_console_puts("\r\n\033[0;31m[CRASH]");
|
||||
__furi_print_name(isr);
|
||||
furi_hal_console_puts(message);
|
||||
furi_hal_console_puts(__furi_check_message);
|
||||
|
||||
if(!isr) {
|
||||
__furi_print_stack_info();
|
||||
|
@ -86,9 +98,9 @@ FURI_NORETURN void furi_crash(const char* message) {
|
|||
#ifdef FURI_DEBUG
|
||||
furi_hal_console_puts("\r\nSystem halted. Connect debugger for more info\r\n");
|
||||
furi_hal_console_puts("\033[0m\r\n");
|
||||
__furi_halt();
|
||||
__furi_halt_mcu();
|
||||
#else
|
||||
furi_hal_rtc_set_fault_data((uint32_t)message);
|
||||
furi_hal_rtc_set_fault_data((uint32_t)__furi_check_message);
|
||||
furi_hal_console_puts("\r\nRebooting system.\r\n");
|
||||
furi_hal_console_puts("\033[0m\r\n");
|
||||
furi_hal_power_reset();
|
||||
|
@ -96,18 +108,25 @@ FURI_NORETURN void furi_crash(const char* message) {
|
|||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
FURI_NORETURN void furi_halt(const char* message) {
|
||||
FURI_NORETURN void __furi_halt() {
|
||||
register const void* r12 asm ("r12") = (void*)__furi_check_registers;
|
||||
asm volatile(
|
||||
"stm r12, {r0-r11} \n"
|
||||
:
|
||||
: "r" (r12)
|
||||
: "memory");
|
||||
|
||||
bool isr = FURI_IS_ISR();
|
||||
__disable_irq();
|
||||
|
||||
if(message == NULL) {
|
||||
message = "System halt requested.";
|
||||
if(__furi_check_message == NULL) {
|
||||
__furi_check_message = "System halt requested.";
|
||||
}
|
||||
|
||||
furi_hal_console_puts("\r\n\033[0;31m[HALT]");
|
||||
__furi_print_name(isr);
|
||||
furi_hal_console_puts(message);
|
||||
furi_hal_console_puts(__furi_check_message);
|
||||
furi_hal_console_puts("\r\nSystem halted. Bye-bye!\r\n");
|
||||
furi_hal_console_puts("\033[0m\r\n");
|
||||
__furi_halt();
|
||||
__furi_halt_mcu();
|
||||
}
|
||||
|
|
|
@ -8,25 +8,52 @@ extern "C" {
|
|||
#define FURI_NORETURN noreturn
|
||||
#endif
|
||||
|
||||
/** Pointer to pass message to __furi_crash and __furi_halt */
|
||||
extern const char* __furi_check_message;
|
||||
|
||||
/** Crash system */
|
||||
FURI_NORETURN void __furi_crash();
|
||||
|
||||
/** Halt system */
|
||||
FURI_NORETURN void __furi_halt();
|
||||
|
||||
/** Crash system with message. Show message after reboot. */
|
||||
#define furi_crash(message) \
|
||||
do { \
|
||||
__furi_check_message = message; \
|
||||
__furi_crash(); \
|
||||
} while(0)
|
||||
|
||||
/** Halt system with message. */
|
||||
#define furi_halt(message) \
|
||||
do { \
|
||||
__furi_check_message = message; \
|
||||
__furi_halt(); \
|
||||
} while(0)
|
||||
|
||||
/** Check condition and crash if check failed */
|
||||
#define furi_check(__e) ((__e) ? (void)0 : furi_crash("furi_check failed\r\n"))
|
||||
#define furi_check(__e) \
|
||||
do { \
|
||||
if ((__e) == 0) { \
|
||||
furi_crash("furi_check failed\r\n"); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/** Only in debug build: Assert condition and crash if assert failed */
|
||||
#ifdef FURI_DEBUG
|
||||
#define furi_assert(__e) ((__e) ? (void)0 : furi_crash("furi_assert failed\r\n"))
|
||||
#define furi_assert(__e) \
|
||||
do { \
|
||||
if ((__e) == 0) { \
|
||||
furi_crash("furi_assert failed\r\n"); \
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
#define furi_assert(__e) \
|
||||
do { \
|
||||
((void)(__e)); \
|
||||
#define furi_assert(__e) \
|
||||
do { \
|
||||
((void)(__e)); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/** Crash system */
|
||||
FURI_NORETURN void furi_crash(const char* message);
|
||||
|
||||
/** Halt system */
|
||||
FURI_NORETURN void furi_halt(const char* message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue