diff --git a/Utilities/openocd_rtt.sh b/Utilities/openocd_rtt.sh new file mode 100755 index 00000000..982df3b8 --- /dev/null +++ b/Utilities/openocd_rtt.sh @@ -0,0 +1,8 @@ +RTT_ADDR=$(arm-none-eabi-nm build/${1}/tintin_fw.elf | grep '_SEGGER_RTT' | cut -d " " -f1) +openocd -f interface/jlink.cfg -c "transport select swd" -f target/nrf52.cfg \ +-c "proc rtt_init {} {rtt setup 0x${RTT_ADDR} 2048 \"SEGGER RTT\";\ + rtt start;\ + rtt server start 9090 0;}" \ +-c "proc rtt_reset {} {rtt server stop 9090;\ + rtt stop;\ + rtt_init;}" \ No newline at end of file diff --git a/hw/chip/nrf52840/debug.c b/hw/chip/nrf52840/debug.c index 3591396f..9a8fa9e9 100644 --- a/hw/chip/nrf52840/debug.c +++ b/hw/chip/nrf52840/debug.c @@ -8,20 +8,12 @@ #include #include "rebbleos.h" #include "nrf_delay.h" -#include "nrfx_uart.h" #include "board_config.h" void delay_us(int us) { nrf_delay_us(us); } -/* We use UART, instead of UARTE, because we could be writing from flash, - * which would cause the EasyDMA engine to lock up, and that would be bad. - * So we just take the performance hit and run a UART engine in PIO mode. - * So it goes. */ - -static nrfx_uart_t debug_uart = NRFX_UART_INSTANCE(0); - __attribute__((naked)) uint32_t get_msp() { asm volatile( @@ -30,8 +22,28 @@ __attribute__((naked)) uint32_t get_msp() ); } +#ifdef NRF_DEBUG_SEGGER_RTT +#include "SEGGER_RTT.h" +void debug_init() { + SEGGER_RTT_Init(); +} + +void debug_write(const unsigned char *p, size_t len) { + SEGGER_RTT_Write(0, p, len); +} + +#else + +#include "nrfx_uart.h" + static int _did_init = 0; +/* We use UART, instead of UARTE, because we could be writing from flash, + * which would cause the EasyDMA engine to lock up, and that would be bad. + * So we just take the performance hit and run a UART engine in PIO mode. + * So it goes. */ + +static nrfx_uart_t debug_uart = NRFX_UART_INSTANCE(0); void debug_init() { nrfx_err_t err; @@ -66,6 +78,8 @@ void debug_write(const unsigned char *p, size_t len) { } } +#endif + void ss_debug_write(const unsigned char *p, size_t len) { // unsupported on this platform diff --git a/hw/platform/asterix/board_config.h b/hw/platform/asterix/board_config.h index f473b0c9..2d769340 100644 --- a/hw/platform/asterix/board_config.h +++ b/hw/platform/asterix/board_config.h @@ -83,6 +83,8 @@ #define BOARD_DISPLAY_ROT180 +#define NRF_DEBUG_SEGGER_RTT + #else #error unknown Asterix board diff --git a/hw/platform/asterix/config.mk b/hw/platform/asterix/config.mk index 73436aa0..6e662d62 100644 --- a/hw/platform/asterix/config.mk +++ b/hw/platform/asterix/config.mk @@ -47,6 +47,9 @@ PLATFORMS += asterix_vla_dvb1 CFLAGS_asterix_vla_dvb2 = $(CFLAGS_asterix_common) CFLAGS_asterix_vla_dvb2 += $(CFLAGS_driver_nrf52_ls013b7dh05) SRCS_asterix_vla_dvb2 = $(SRCS_asterix_common) +SRCS_asterix_vla_dvb2 += external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c +SRCS_asterix_vla_dvb2 += external/segger_rtt/SEGGER_RTT.c +SRCS_asterix_vla_dvb2 += external/segger_rtt/SEGGER_RTT_printf.c SRCS_asterix_vla_dvb2 += $(SRCS_driver_nrf52_ls013b7dh05) LDFLAGS_asterix_vla_dvb2 = $(LDFLAGS_asterix_common) LIBS_asterix_vla_dvb2 = $(LIBS_asterix_common)