Reading ITM via FTDI USB adapter cable

Hi friends,

After reading @japaric's great article on ITM (blog.japaric.io/itm/) I decided I should give it a shot.
However, I can't seem to read out any data --- maybe one of y'all can tell what I'm doing wrong.

Setup

  • stm32f103 "black pill" dev board, programmed via st-link clone
  • FTDI FT232R 3.3V cable connected with just two pins as shown in @japaric's article (common ground and FTDI rx pin to black pill's B3 pin, which stm32f103 datasheet confirms is SWO pin)
  • Mac OS X 10.14 (I've tried both Apple's built-in FTDI driver and FTDIUSBSerialDriver_v2_4_2.dmg from FTDI's website)

OpenOCD setup (via openocd.gdb)

target remote :3333
set print asm-demangle on
# set backtrace limit to not have infinite backtrace loops
set backtrace limit 32
monitor arm semihosting enable

#itm output
monitor tpiu config external uart off 8000000 2000000
monitor itm port 0 on

# detect unhandled exceptions, hard faults and panics
break DefaultHandler
break HardFault
# break rust_begin_unwind

load
continue

Relevant part of the RTFM framework init function:

let stim = &mut cx.core.ITM.stim[0];
cortex_m::iprintln!(stim, "The quick brown fox jumps over the lazy dog");

Evidence

  • Some signal is sent: oscilloscope trace on the B3 pin / ftdi rx net shows pulses about 60ns wide.
  • FTDI loopback works: If I connect only rx and tx pins of FTDI cable, I can run screen /dev/tty.usbserial-AH02QPPY, type, and see characters show up; if I disconnect these two pins, when I type nothing shows up.
  • Board is programmed correctly: I can see semihosting debug output printed when the program gets to idle loop (after the init runs successfully)
  • I've tried reading via screen /dev/tty.usbserial-AH02QPPY with and without the expected baud rate (2000000) listed; nothing ever shows up
  • I've tried reading via cat /dev/tty.usbserial-AH02QPPY and reflashed the board, powered it on/off by unplugging the stlink clone, etc.; nothing ever shows up

Any ideas what I might be missing here?

Thanks, and happy new year everyone!

I figured this out: The issue was that the baud rate I was trying, 2000000 (copied from the blog post), was too fast.

I tried several speeds.
These worked: 9600, 38400, 57600, 115200
These didn't: 200000, 256000, 1000000, 2000000

I'm not sure where I'm hitting the limitation, though.
The FTDI FT232R cable homepage says:

  • Data transfer rates from 300 baud to 3 Megabaud (RS422 / RS485 and at TTL levels) and 300 baud to 1 Megabaud (RS232).

It could be Apple's built-in FTDI driver.
If I need to go faster than 115200 I'll try the FTDI driver again and see if that raises the limit.