Allow using Segger RTT as debug output (#3052)
Firmware needs to be built with -DDEBUG=YES and -DDEBUG_SEGGER_RTT=YES to use this feature.
This commit is contained in:
@@ -11,3 +11,6 @@
|
|||||||
path = radio/src/thirdparty/FreeRTOS
|
path = radio/src/thirdparty/FreeRTOS
|
||||||
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
|
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
|
||||||
shallow = true
|
shallow = true
|
||||||
|
[submodule "radio/src/thirdparty/Segger_RTT"]
|
||||||
|
path = radio/src/thirdparty/Segger_RTT
|
||||||
|
url = https://github.com/adfernandes/segger-rtt.git
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ option(RAS "RAS (SWR) enabled" ON)
|
|||||||
option(TEMPLATES "Model templates menu" OFF)
|
option(TEMPLATES "Model templates menu" OFF)
|
||||||
option(TRACE_SIMPGMSPACE "Turn on traces in simpgmspace.cpp" ON)
|
option(TRACE_SIMPGMSPACE "Turn on traces in simpgmspace.cpp" ON)
|
||||||
option(TRACE_LUA_INTERNALS "Turn on traces for Lua internals" OFF)
|
option(TRACE_LUA_INTERNALS "Turn on traces for Lua internals" OFF)
|
||||||
|
option(DEBUG_SEGGER_RTT "Debug output to Segger RTT" OFF)
|
||||||
option(DEBUG_WINDOWS "Turn on windows traces" OFF)
|
option(DEBUG_WINDOWS "Turn on windows traces" OFF)
|
||||||
option(DEBUG_YAML "Turn on YAML traces" OFF)
|
option(DEBUG_YAML "Turn on YAML traces" OFF)
|
||||||
option(DEBUG_LABELS "Turn on Labels traces" OFF)
|
option(DEBUG_LABELS "Turn on Labels traces" OFF)
|
||||||
@@ -365,6 +366,11 @@ if(TRACE_LUA_INTERNALS)
|
|||||||
add_definitions(-DTRACE_LUA_INTERNALS_ENABLED)
|
add_definitions(-DTRACE_LUA_INTERNALS_ENABLED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(DEBUG_SEGGER_RTT)
|
||||||
|
add_definitions(-DDEBUG_SEGGER_RTT)
|
||||||
|
set(SRC ${SRC} ${THIRDPARTY_DIR}/Segger_RTT/RTT/SEGGER_RTT.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(DEBUG_WINDOWS)
|
if(DEBUG_WINDOWS)
|
||||||
add_definitions(-DDEBUG_WINDOWS)
|
add_definitions(-DDEBUG_WINDOWS)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -45,6 +45,10 @@
|
|||||||
#include "extmodule_serial_driver.h"
|
#include "extmodule_serial_driver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(DEBUG_SEGGER_RTT)
|
||||||
|
#include "thirdparty/Segger_RTT/RTT/SEGGER_RTT.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PRINTF_BUFFER_SIZE 128
|
#define PRINTF_BUFFER_SIZE 128
|
||||||
|
|
||||||
static void (*dbg_serial_putc)(void*, uint8_t) = nullptr;
|
static void (*dbg_serial_putc)(void*, uint8_t) = nullptr;
|
||||||
@@ -67,6 +71,33 @@ void dbgSerialSetSendCb(void* ctx, void (*cb)(void*, uint8_t))
|
|||||||
dbg_serial_putc = cb;
|
dbg_serial_putc = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(DEBUG_SEGGER_RTT)
|
||||||
|
|
||||||
|
extern "C" void dbgSerialPutc(char c)
|
||||||
|
{
|
||||||
|
SEGGER_RTT_Write(0, (const void *)&c, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void dbgSerialPrintf(const char * format, ...)
|
||||||
|
{
|
||||||
|
va_list arglist;
|
||||||
|
char tmp[PRINTF_BUFFER_SIZE+1];
|
||||||
|
|
||||||
|
// no need to do anything if we don't have an output
|
||||||
|
if (!dbg_serial_putc) return;
|
||||||
|
|
||||||
|
va_start(arglist, format);
|
||||||
|
vsnprintf(tmp, PRINTF_BUFFER_SIZE, format, arglist);
|
||||||
|
tmp[PRINTF_BUFFER_SIZE] = '\0';
|
||||||
|
va_end(arglist);
|
||||||
|
|
||||||
|
const char *t = tmp;
|
||||||
|
while (*t && dbg_serial_putc) {
|
||||||
|
SEGGER_RTT_Write(0, (const void *)t++, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
extern "C" void dbgSerialPutc(char c)
|
extern "C" void dbgSerialPutc(char c)
|
||||||
{
|
{
|
||||||
auto _putc = dbg_serial_putc;
|
auto _putc = dbg_serial_putc;
|
||||||
@@ -92,6 +123,7 @@ extern "C" void dbgSerialPrintf(const char * format, ...)
|
|||||||
dbg_serial_putc(dbg_serial_ctx, *t++);
|
dbg_serial_putc(dbg_serial_ctx, *t++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" void dbgSerialCrlf()
|
extern "C" void dbgSerialCrlf()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,6 +54,13 @@ if(BLUETOOTH)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(DEBUG_SEGGER_RTT)
|
||||||
|
set(BOOTLOADER_SRC
|
||||||
|
${BOOTLOADER_SRC}
|
||||||
|
../../../../../thirdparty/Segger_RTT/RTT/SEGGER_RTT.c
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
|
if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
|
||||||
set(BOOTLOADER_SRC
|
set(BOOTLOADER_SRC
|
||||||
@@ -92,7 +99,7 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
|
|||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
set(BOOTLOADER_SRC
|
set(BOOTLOADER_SRC
|
||||||
${BOOTLOADER_SRC}
|
${BOOTLOADER_SRC}
|
||||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c
|
# ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c
|
||||||
../../../../../serial.cpp
|
../../../../../serial.cpp
|
||||||
../../../../../targets/common/arm/stm32/aux_serial_driver.cpp
|
../../../../../targets/common/arm/stm32/aux_serial_driver.cpp
|
||||||
../../../../../targets/common/arm/stm32/stm32_usart_driver.cpp
|
../../../../../targets/common/arm/stm32/stm32_usart_driver.cpp
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#if defined(DEBUG_SEGGER_RTT)
|
||||||
|
#include "thirdparty/Segger_RTT/RTT/SEGGER_RTT.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PCBXLITE)
|
#if defined(PCBXLITE)
|
||||||
#define BOOTLOADER_KEYS 0x0F
|
#define BOOTLOADER_KEYS 0x0F
|
||||||
#else
|
#else
|
||||||
@@ -228,6 +232,10 @@ void bootloaderInitApp()
|
|||||||
boardBootloaderInit();
|
boardBootloaderInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(DEBUG_SEGGER_RTT)
|
||||||
|
SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP);
|
||||||
|
#endif
|
||||||
|
|
||||||
pwrInit();
|
pwrInit();
|
||||||
keysInit();
|
keysInit();
|
||||||
|
|
||||||
|
|||||||
+1
Submodule radio/src/thirdparty/Segger_RTT added at fdac9caa26
Reference in New Issue
Block a user