From a11cb11ba38c48809aa41316bf41b54c29a65123 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 26 Jan 2021 16:49:09 +0100 Subject: [PATCH] chore(core): rework SYSTEMVIEW_DEST_SYSTEMVIEW to work with ifdef instead of if --- core/embed/firmware/mpconfigport.h | 6 ++++-- core/embed/firmware/systemview.c | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/embed/firmware/mpconfigport.h b/core/embed/firmware/mpconfigport.h index 0666b8bbba..2a98b08367 100644 --- a/core/embed/firmware/mpconfigport.h +++ b/core/embed/firmware/mpconfigport.h @@ -158,8 +158,10 @@ #ifdef SYSTEM_VIEW #define MP_PLAT_PRINT_STRN(str, len) segger_print(str, len) -// set following to 0 if you want to print to RTT instead of SystemView -// openocd supports only the RTT output method +// uncomment DEST_RTT and comment DEST_SYSTEMVIEW +// if you want to print to RTT instead of SystemView +// OpenOCD supports only the RTT output method +// #define SYSTEMVIEW_DEST_RTT (1) #define SYSTEMVIEW_DEST_SYSTEMVIEW (1) #endif diff --git a/core/embed/firmware/systemview.c b/core/embed/firmware/systemview.c index ba9e6db114..06fc221e32 100644 --- a/core/embed/firmware/systemview.c +++ b/core/embed/firmware/systemview.c @@ -93,17 +93,20 @@ void enable_systemview() { SYSTICK->CSR = 0x07; // enable systick } +#ifdef SYSTEMVIEW_DEST_RTT size_t _write(int file, const void *ptr, size_t len); +#endif size_t segger_print(const char *str, size_t len) { -#if SYSTEMVIEW_DEST_SYSTEMVIEW +#ifdef SYSTEMVIEW_DEST_SYSTEMVIEW static char str_copy[1024]; size_t copylen = len > 1023 ? 1023 : len; memcpy(str_copy, str, copylen); str_copy[copylen] = 0; SEGGER_SYSVIEW_Print(str_copy); return len; -#else +#endif +#ifdef SYSTEMVIEW_DEST_RTT _write(0, str, len); return len; #endif