1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 23:08:14 +00:00

chore(core): more systematic systemview function definitions

This commit is contained in:
Ondrej Mikle 2020-12-11 16:45:10 +01:00 committed by Pavol Rusnak
parent 869cfbbd1c
commit 550216354b
4 changed files with 28 additions and 14 deletions

View File

@ -358,6 +358,7 @@ if SYSTEM_VIEW:
'embed/segger/SEGGER/SEGGER_SYSVIEW.c',
'embed/segger/SEGGER/SEGGER_RTT.c',
'embed/segger/SEGGER/SEGGER_RTT_ASM_ARMv7M.S',
'embed/segger/SEGGER/Syscalls/SEGGER_RTT_Syscalls_GCC.c',
'embed/firmware/systemview.c',
]
CPPPATH_MOD += [
@ -365,6 +366,7 @@ if SYSTEM_VIEW:
'embed/segger/Config/',
]
CPPDEFINES_MOD += ['SYSTEM_VIEW']
CCFLAGS_MOD += '-DSYSTEM_VIEW '
SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED

View File

@ -156,6 +156,13 @@
#define MICROPY_PY_TREZORUI (1)
#define MICROPY_PY_TREZORUTILS (1)
#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
#define SYSTEMVIEW_DEST_SYSTEMVIEW (1)
#endif
#define MP_STATE_PORT MP_STATE_VM
// ============= this ends common config section ===================

View File

@ -19,9 +19,8 @@
#include "common.h"
#include "py/mphal.h"
#include "usb.h"
#include "systemview.h"
#include "string.h"
#include "usb.h"
static int vcp_iface_num = -1;
@ -43,15 +42,3 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
}
void mp_hal_set_vcp_iface(int iface_num) { vcp_iface_num = iface_num; }
#ifdef SYSTEM_VIEW
int segger_print(const char* str, size_t len) {
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;
}
#endif

View File

@ -2,6 +2,9 @@
#include "systemview.h"
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include "mpconfigport.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_Conf.h"
@ -94,4 +97,19 @@ void enable_systemview() {
SYSTICK->CSR = 0x07; // enable systick
}
size_t _write(int file, const void *ptr, size_t len);
size_t segger_print(const char *str, size_t len) {
#if 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
_write(0, str, len);
return len;
#endif
}
#endif