NRF_LOG: add option to activate UART backend on SWO pin, see How_to_use_Firmware.md

This commit is contained in:
Philippe Teuwen
2023-08-18 21:56:35 +02:00
parent 8de6a31196
commit bbf5f3027b
4 changed files with 35 additions and 3 deletions
+11
View File
@@ -309,3 +309,14 @@ in a second terminal:
```
JLinkRTTClient
```
## Using SWO pin as UART to monitor NRF_LOG
One can set `NRF_LOG_UART_ON_SWO_ENABLED := 1` in `Makefile.defs` to activate this functionality.
When activated, NRF_LOG will be available if one connects a UART bridge to the SWO pin which will work as a UART TX pin.
UART works at 115200 bauds. E.g. one can use a FTDI dongle and `screen /dev/ttyUSB0 115200`.
Contrary to RTT that needs to be activated by a JTAG probe, UART logs are immediately available.
Limitations:
* SWO pin is shared with... SWO so when e.g. reflashing the device, garbage may appear on the monitoring terminal.
* SWO pin is also shared with the blue channel of the RGB slot LEDs, so faint blue may appear briefly when logs are sent and LED might not work properly when supposed to be blue.
+3
View File
@@ -27,3 +27,6 @@ CURRENT_DEVICE_TYPE ?= ${CHAMELEON_ULTRA}
# Versioning information
GIT_VERSION := "$(shell git describe --abbrev=7 --dirty --always --tags)"
# Enable NRF_LOG on SWO pin as UART TX
NRF_LOG_UART_ON_SWO_ENABLED := 0
+17
View File
@@ -288,6 +288,23 @@ else
$(error Chameleon <Application>: No device type define.)
endif
ifeq (${NRF_LOG_UART_ON_SWO_ENABLED}, 1)
SRC_FILES += \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_uart.c \
$(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_uart.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c
CFLAGS += -DNRFX_UARTE_ENABLED=1 -DNRFX_UARTE0_ENABLED=1
CFLAGS += -DNRF_LOG_BACKEND_UART_ENABLED=1
#define NRF_GPIO_PIN_MAP(port, pin) (((port) << 5) | ((pin) & 0x1F))
#define NRF_LOG_BACKEND_UART_TX_PIN NRF_GPIO_PIN_MAP(1, 0)
CFLAGS += -DNRF_LOG_BACKEND_UART_TX_PIN=32
# 30801920 = 115200 baud
CFLAGS += -DNRF_LOG_BACKEND_UART_BAUDRATE=30801920
CFLAGS += -DNRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE=64
$(info Chameleon <Application>: enable NRF_LOG on UART via SWO pin.)
endif
# Optimization flags
OPT = -O3 -g3
+4 -3
View File
@@ -5868,9 +5868,10 @@
// <e> UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer
//==========================================================
#ifndef UART_ENABLED
#define UART_ENABLED 0
#endif
//Don't define it at all else it conflicts with NRFX
//#ifndef UART_ENABLED
//#define UART_ENABLED 0
//#endif
// <o> UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control
// <0=> Disabled