mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-21 10:35:43 +00:00
feat(code): introduce dbg_printf for kernel debugging
[no changelog]
This commit is contained in:
parent
2867768745
commit
0fb1693ea8
30
core/embed/sys/dbg/inc/sys/dbg_printf.h
Normal file
30
core/embed/sys/dbg/inc/sys/dbg_printf.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This file is part of the Trezor project, https://trezor.io/
|
||||
*
|
||||
* Copyright (c) SatoshiLabs
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef KERNEL_MODE
|
||||
|
||||
// vprintf-like functions for debugging
|
||||
void dbg_vprintf(const char* fmt, va_list args);
|
||||
|
||||
// printf-like functions for debugging
|
||||
void dbg_printf(const char* fmt, ...);
|
||||
|
||||
#endif // KERNEL_MODE
|
47
core/embed/sys/dbg/stm32/dbg_printf.c
Normal file
47
core/embed/sys/dbg/stm32/dbg_printf.c
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of the Trezor project, https://trezor.io/
|
||||
*
|
||||
* Copyright (c) SatoshiLabs
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef KERNEL_MODE
|
||||
|
||||
#include <rtl/mini_printf.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/irq.h>
|
||||
|
||||
void dbg_vprintf(const char* fmt, va_list args) {
|
||||
char temp[80];
|
||||
mini_vsnprintf(temp, sizeof(temp), fmt, args);
|
||||
|
||||
irq_key_t irq_key = irq_lock();
|
||||
for (size_t i = 0; i < sizeof(temp); i++) {
|
||||
if (temp[i] == '\0') {
|
||||
break;
|
||||
}
|
||||
ITM_SendChar(temp[i]);
|
||||
}
|
||||
irq_unlock(irq_key);
|
||||
}
|
||||
|
||||
void dbg_printf(const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
dbg_vprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#endif // KERNEL_MODE
|
@ -17,6 +17,7 @@ def stm32f4_common_files(env, defines, sources, paths):
|
||||
"embed/sec/secure_aes/inc",
|
||||
"embed/sec/time_estimate/inc",
|
||||
"embed/sys/bsp/stm32f4",
|
||||
"embed/sys/dbg/inc",
|
||||
"embed/sys/irq/inc",
|
||||
"embed/sys/linker/inc",
|
||||
"embed/sys/mpu/inc",
|
||||
@ -68,6 +69,7 @@ def stm32f4_common_files(env, defines, sources, paths):
|
||||
"embed/sec/rng/stm32/rng.c",
|
||||
"embed/sec/secret/stm32f4/secret.c",
|
||||
"embed/sec/time_estimate/stm32/time_estimate.c",
|
||||
"embed/sys/dbg/stm32/dbg_printf.c",
|
||||
"embed/sys/linker/linker_utils.c",
|
||||
"embed/sys/mpu/stm32f4/mpu.c",
|
||||
"embed/sys/pvd/stm32/pvd.c",
|
||||
|
@ -18,8 +18,9 @@ def stm32u5_common_files(env, defines, sources, paths):
|
||||
"embed/sec/secret/inc",
|
||||
"embed/sec/secure_aes/inc",
|
||||
"embed/sec/time_estimate/inc",
|
||||
"embed/sys/irq/inc",
|
||||
"embed/sys/bsp/stm32u5",
|
||||
"embed/sys/dbg/inc",
|
||||
"embed/sys/irq/inc",
|
||||
"embed/sys/linker/inc",
|
||||
"embed/sys/mpu/inc",
|
||||
"embed/sys/pvd/inc",
|
||||
@ -86,6 +87,7 @@ def stm32u5_common_files(env, defines, sources, paths):
|
||||
"embed/sec/secret/stm32u5/secret.c",
|
||||
"embed/sec/secure_aes/stm32u5/secure_aes.c",
|
||||
"embed/sec/time_estimate/stm32/time_estimate.c",
|
||||
"embed/sys/dbg/stm32/dbg_printf.c",
|
||||
"embed/sys/linker/linker_utils.c",
|
||||
"embed/sys/mpu/stm32u5/mpu.c",
|
||||
"embed/sys/pvd/stm32/pvd.c",
|
||||
|
Loading…
Reference in New Issue
Block a user