Skip to content

Target trace usage (UART, SWO, RTT)

Dmitry Rezvanov edited this page Oct 15, 2024 · 9 revisions

UART

  1. Connect the UART pins to MioLink (target's TX to probe's RX and vice versa, target's RX to probe's TX);
  2. Open a terminal program (e.g., Putty) and connect to MioLink's second VCOM with the same parameters configured on the target (example on the screenshot):
    image
  3. That's it!

UART on the 10-pin JTAG connector (works only for MioLink):

The key difference between MioLink and the current Black Magic Probe is that the JTAG TDI and TDO pins can be used as MioLink UART TX and RX, respectively (TDI - MioLink TX, TDO - MioLink RX) when the target is debugged via SWD.

To enable this, add the command monitor uart_on_tdi_tdo enable to the GDB commands.
To disable, use monitor uart_on_tdi_tdo disable.
Note that after changing this setting, you need to reopen the port in the terminal program.
Also, this setting is NOT saved in non-volatile memory, so you'll need to re-enter the command after restarting the probe.

SWO

  1. Connect the debugger's SWO pin to the target's SWO pin;
  2. Configure TRACESWO on the target side. MioLink currently supports only UART mode (Manchester support is planned later);
    Example of TRACESWO setup for STM32F1:
DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN;
DBGMCU->CR &= ~(DBGMCU_CR_TRACE_MODE);

TPI->ACPR = 71;  // Output bits at 72000000/(71+1)=1MHz.
TPI->SPPR = 2;   // Use Async mode (1 for RZ/Manchester)
TPI->FFCR = 0;   // Disable formatter

ITM->LAR = 0xC5ACCE55;
ITM->TCR = (1 << ITM_TCR_TraceBusID_Pos) | ITM_TCR_SYNCENA_Msk | 
 		 ITM_TCR_ITMENA_Msk;
ITM->TER = 0xFFFFFFFF;
  1. Enable the SWO on the probe side: add the command monitor swo enable <baudrate> decode <channel> to your GDB command list.
    Here, baudrate is the interface speed, and channel is the channel where the data is sent (e.g., ITM_SendChar sends data to channel 0).
    Example (1Mbaud, channel 0): monitor swo enable 1000000 decode 0
  2. As with UART mode, open a terminal program and connect to MioLink's second VCOM.
    This time, parameters don't matter since we already set the speed and channel through the GDB command.
  3. That's it!
    Keep in mind that the monitor swo command does not persist its state, so SWO parameters need to be set again after restarting the probe.
Clone this wiki locally