Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asterix-vla-dvb2 RTT debug support #144

Open
wants to merge 3 commits into
base: alicegrey/asterix_vla_dvb2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Utilities/openocd_rtt.sh
Original file line number Diff line number Diff line change
@@ -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;}"
30 changes: 22 additions & 8 deletions hw/chip/nrf52840/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@
#include <debug.h>
#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(
Expand All @@ -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;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions hw/platform/asterix/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@

#define BOARD_DISPLAY_ROT180

#define NRF_DEBUG_SEGGER_RTT

#else

#error unknown Asterix board
Expand Down
3 changes: 3 additions & 0 deletions hw/platform/asterix/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line needs to be removed as we've moved it to asterix_common

LDFLAGS_asterix_vla_dvb2 = $(LDFLAGS_asterix_common)
LIBS_asterix_vla_dvb2 = $(LIBS_asterix_common)
Expand Down