mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-08 21:52:42 +00:00
unix: implement __fatal_error, simplify modtrezorutils
This commit is contained in:
parent
117edd233f
commit
795875523b
@ -12,13 +12,7 @@
|
||||
|
||||
#if MICROPY_PY_TREZORUTILS
|
||||
|
||||
#if defined TREZOR_STM32
|
||||
#include "common.h"
|
||||
#elif defined TREZOR_UNIX
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#error Unsupported TREZOR port. Only STM32 and UNIX ports are supported.
|
||||
#endif
|
||||
|
||||
/// def trezor.utils.memcpy(dst: bytearray, dst_ofs: int,
|
||||
/// src: bytearray, src_ofs: int,
|
||||
@ -71,13 +65,7 @@ STATIC mp_obj_t mod_TrezorUtils_halt(size_t n_args, const mp_obj_t *args) {
|
||||
printf("HALT!\n");
|
||||
}
|
||||
// TODO: is this the best we can do?
|
||||
#if defined TREZOR_STM32
|
||||
__fatal_error("HALT");
|
||||
#elif defined TREZOR_UNIX
|
||||
exit(1);
|
||||
#else
|
||||
#error Unsupported TREZOR port. Only STM32 and UNIX ports are supported.
|
||||
#endif
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUtils_halt_obj, 0, 1, mod_TrezorUtils_halt);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include STM32_HAL_H
|
||||
|
||||
#include "common.h"
|
||||
#include "display.h"
|
||||
|
||||
#define FATAL_FGCOLOR 0xFFFF
|
||||
|
@ -92,6 +92,9 @@ ifeq ($(MICROPY_PY_TREZORUTILS),1)
|
||||
SRC_MOD += $(EXTMOD_DIR)/modtrezorutils/modtrezorutils.c
|
||||
endif
|
||||
|
||||
CFLAGS_MOD += -I../$(EXTMOD_DIR)/../unix
|
||||
SRC_MOD += $(EXTMOD_DIR)/../unix/common.c
|
||||
|
||||
#################################################
|
||||
|
||||
-include mpconfigport.mk
|
||||
|
11
micropython/unix/common.c
Normal file
11
micropython/unix/common.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
void __attribute__((noreturn)) __fatal_error(const char *msg) {
|
||||
printf("FATAL ERROR:\n");
|
||||
printf(msg);
|
||||
printf("\n");
|
||||
exit(1);
|
||||
}
|
6
micropython/unix/common.h
Normal file
6
micropython/unix/common.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef __TREZORUNIX_COMMON_H__
|
||||
#define __TREZORUNIX_COMMON_H__
|
||||
|
||||
void __attribute__((noreturn)) __fatal_error(const char *msg);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user