Soft serial 9k6 for debugging on free GPIO?


Martijn Smit
 

Hi there,

We have a prototype utilising the nRF52840 BME340 SoC module. Since we use a LoRaWAN module and a MAX3485 we used the two 840 uarts for connecting to these subsystems. But I do have some free GPIOs on the prototype PCB which I'd like to use as a console when running the project in debug mode. So I'm looking for a way to have a low-speed soft-serial taking care of logging. Any pointers, or perhaps other ways to get logging output (we are using BLE)?

Looked at some discussions on the Nordic devzone, but not a lot going for it.

Thanks,
Martijn


Jian Zhang
 

Hi Martijn,

Not sure about the exact situation you are facing, listed below please find some of the suggestions I can think of:

1. There are soft uart implementations on github, which you might be able to port to zephyr;
2. If you got SPI interface on your module, there are bridge modules available to convert i2c/spi to uart; // sc16is740 etc
3. If you only care about the application level log, probably you can use bluetooth to build a virtual serial port for logging purpose;

Best Regards,
Jian


Henrik Brix Andersen
 

Hi Martijn,

If you are using a Segger J-Link probe you can use the RAM-based RTT console by setting CONFIG_RTT_CONSOLE=y
See https://docs.zephyrproject.org/latest/guides/debugging/host-tools.html#jlink-debug-host-tools for more information.

./Brix
--
Henrik Brix Andersen

On 31 May 2019, at 15.53, martijn@... wrote:

Hi there,

We have a prototype utilising the nRF52840 BME340 SoC module. Since we use a LoRaWAN module and a MAX3485 we used the two 840 uarts for connecting to these subsystems. But I do have some free GPIOs on the prototype PCB which I'd like to use as a console when running the project in debug mode. So I'm looking for a way to have a low-speed soft-serial taking care of logging. Any pointers, or perhaps other ways to get logging output (we are using BLE)?

Looked at some discussions on the Nordic devzone, but not a lot going for it.

Thanks,
Martijn


Stanislav Pobořil
 

Hi Martinj,

This Zephyr example does UART over GPIO:
https://github.com/NXPmicro/zephyr/tree/soft_periph/samples/soft_periph

Here's a picture with the system overview:
https://www.zephyrproject.org/elc-openiot-nxp-demo/

However it receives the data to send via RPMsg from a second core running Linux and vice versa.
It could be possible to remove the RPMsg related part and rewrite the code into a driver and select that peripheral as a debug console in board's DTS file.
The code requires a hardware timer and supports just 8N1 format.

Best regards,
Stana


Martijn Smit
 

Hi Henrik,

RTT is the way to move forward as it seems, since it will provide a clean interface both on hardware and config. Thanks for pointing me there, and thanks for the soft-serial pointers from others in this thread as it might come in handy.

So, I've tried for the last two days to set RTT up, using the blinky or logging examples using a PCA10059 nRF52840 dongle just to experiment. I'm not connecting the dongle using USB but with a tag-connect TC2050-IDC-NL on the Segger J-Link with the pogo-pins directly on the board.

If I only use the CONFIG_RTT_CONSOLE=y nothing happens and the JLinkRTTLogger keeps searching for the RTT Control Block. Nothing happens.

If I take the log sample from the Zephyr project and use the prj_rtt.conf setting provided I run into different issues:

CONFIG_LOG=y
CONFIG_LOG_RUNTIME_FILTERING=y
CONFIG_LOG_BUFFER_SIZE=2048
CONFIG_LOG_PRINTK=y
CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD=0
CONFIG_LOG_BACKEND_RTT=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_COVERAGE=n

When using the Nordic SDK I'm getting into a world of hurt getting the Segger to compile in as this is triggered by the CONFIG_USE_SEGGER_RTT directive which can be fixed adding more include directories. The RTT tarball from Segger J-Link install is more forgiven, but I cannot get my project to compile since it eventually boils down to a missing include file on the ninja ccache step

...
[109/116] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/console/rtt_console.c.obj
FAILED: zephyr/CMakeFiles/zephyr.dir/drivers/console/rtt_console.c.obj
ccache /usr/local/bin/arm-none-eabi-gcc -DBUILD_VERSION=zephyr-v1.14.0-1238-gbd001081fce1 -DKERNEL -DNRF52840_XXAA -D_FORTIFY_SOURCE=2 -D__ZEPHYR__=1 -I../../../../../kernel/include -I../../../../../arch/arm/include -I../../../../../include -I../../../../../include/drivers -Izephyr/include/generated -I../../../../../soc/arm/nordic_nrf/nrf52 -I../../../../../soc/arm/nordic_nrf/include -I../../../../../lib/libc/minimal/include -I../../../../../ext/hal/cmsis/Include -I../../../../../ext/hal/nordic/nrfx -I../../../../../ext/hal/nordic/nrfx/drivers/include -I../../../../../ext/hal/nordic/nrfx/hal -I../../../../../ext/hal/nordic/nrfx/mdk -I../../../../../ext/hal/nordic/. -isystem /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/8.2.1/include -isystem /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/8.2.1/include-fixed -Os -nostdinc -g -imacros /Users/smeedy/code/zephyrproject/zephyr/samples/subsys/logging/logger/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -mthumb -mcpu=cortex-m4 -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/Users/smeedy/code/zephyrproject/zephyr=. -ffunction-sections -fdata-sections -mabi=aapcs -march=armv7e-m -std=c99 -MD -MT zephyr/CMakeFiles/zephyr.dir/drivers/console/rtt_console.c.obj -MF zephyr/CMakeFiles/zephyr.dir/drivers/console/rtt_console.c.obj.d -o zephyr/CMakeFiles/zephyr.dir/drivers/console/rtt_console.c.obj -c /Users/smeedy/code/zephyrproject/zephyr/drivers/console/rtt_console.c
/Users/smeedy/code/zephyrproject/zephyr/drivers/console/rtt_console.c:16:10: fatal error: SEGGER_RTT.h: No such file or directory


Could be this is going to be a cmake question (sorry for that). I added stuff like include_directories(...) and others into the CMakeLists.txt file, but I cannot seem to get this going since the extra include dirs keep on missing.

Any pointers are welcome,
Thanks again for your time,
Martijn


On 01/06/2019, 14:11, "devel@... on behalf of Henrik Brix Andersen" <devel@... on behalf of henrik@...> wrote:

Hi Martijn,

If you are using a Segger J-Link probe you can use the RAM-based RTT console by setting CONFIG_RTT_CONSOLE=y
See https://docs.zephyrproject.org/latest/guides/debugging/host-tools.html#jlink-debug-host-tools for more information.

./Brix
--
Henrik Brix Andersen

On 31 May 2019, at 15.53, martijn@... wrote:
>
> Hi there,
>
> We have a prototype utilising the nRF52840 BME340 SoC module. Since we use a LoRaWAN module and a MAX3485 we used the two 840 uarts for connecting to these subsystems. But I do have some free GPIOs on the prototype PCB which I'd like to use as a console when running the project in debug mode. So I'm looking for a way to have a low-speed soft-serial taking care of logging. Any pointers, or perhaps other ways to get logging output (we are using BLE)?
>
> Looked at some discussions on the Nordic devzone, but not a lot going for it.
>
> Thanks,
> Martijn
>


Piotr Mienkowski
 

Hi Martijn,

On 31.05.19 15:53, martijn@... wrote:
We have a prototype utilising the nRF52840 BME340 SoC module. Since we
use a LoRaWAN module and a MAX3485 we used the two 840 uarts for
connecting to these subsystems. But I do have some free GPIOs on the
prototype PCB which I'd like to use as a console when running the
project in debug mode. So I'm looking for a way to have a low-speed
soft-serial taking care of logging. Any pointers, or perhaps other
ways to get logging output (we are using BLE)?
Since nRF52840 is a Cortex-M4 device yet another option that you have is
to use Serial Wire Output (SWO). ARM added it specifically to support
trace/logging. It is a high speed interface with low code footprint /
resource usage. Zephyr logger has SWO backend but you would need to
prepare a PR to add support for Nordic device(s). It shouldn't be too
difficult. At minimum you would need to select 'HAS_SWO' Kconfig option
and - looking quickly at the documentation, there may be things I missed
- set TRACECONFIG.TRACEMUX = 1.

Regards,
Piotr