How to Separate Logging and Serial Communication on Different VCOMs (nRF5340)

I am using the board nRF5340 Soc, which by default exports two VCOM ports via the J-Link OB debugger. Currently:

  • VCOM1 (UART0) is used for both logging and serial communication by default.
  • VCOM2 mainly logs boot information.

Goal:

I want to separate logging and serial communication as follows:

  1. VCOM1 (UART0) → Only for logs (debug messages).
  2. VCOM2 (UART1) → Only for serial read/write communication.

Questions:

  1. Is there an internal J-Link OB forwarding mechanism that could be causing this issue?
  2. Are there any Zephyr configurations or Nordic-specific settings required to properly separate logs and serial communication?
  3. What is the best way to ensure logs stay on VCOM1 and serial communication happens only on VCOM2?

Any guidance or recommendations would be greatly appreciated. Thanks!

  • Hello,

    The two COM ports on the DK are the two UARTs that the nRF5340 uses for logging by default. One for the application core, and one for the network core. So the one you are saying just logs boot information, that is probably the network core logging. 

    Is there an internal J-Link OB forwarding mechanism that could be causing this issue?

    The debugger is hard wired to specific GPIOs that are used by the app core and network core by default. They are listed on the back of the DK. They are named RTS TXD CTS and RXD.

    What you can do is to disable logging on the network core, stop the pin forwarding to the network core, and control these as a separate UART on the app core. 

    Are there any Zephyr configurations or Nordic-specific settings required to properly separate logs and serial communication?

    Yes. The logging is by default done on the first UART instance, i.e. UARTE0. So if you set up a different UART for serial communication you should be fine. Just make sure that they use the same GPIOs as the network core use by default.

    What is the best way to ensure logs stay on VCOM1 and serial communication happens only on VCOM2?

    These are hard-wired to particular pins, so they will not change. 

    However, if you want to use UART for serial communication and at the same time monitor logs, another, perhaps easier option, is to use RTT Logging. This kind of log doesn't require it's own GPIOs. It uses a RAM buffer to write the log, and the debugger reads this RAM buffer. If you are interested, this is the way it is done in the NCS\nrf\samples\bluetooth\peripheral_uart sample. To monitor the LOG, you can either open the log in VS Code by connecting the RTT viewer there, or you can use a standalone RTT viewer, such as the one provided by JLink. (from segger.com). 

    Best regards,

    Edvin

Related