/ tools / scripts / debug / swo.sh
swo.sh
 1  #!/bin/bash
 2  
 3  # TODO - support multiple tools (stlink/jlink/blackmagicprobe)
 4  
 5  PROJ_BASE=`git rev-parse --show-toplevel`
 6  
 7  TMPLOGFILE=`mktemp /tmp/swo_log.XXXXXXXXXX` || exit 1
 8  
 9  set -m
10  openocd -f $PROJ_BASE/scripts/st_nucleo_l4.cfg -c "tpiu config internal $TMPLOGFILE uart off 80000000 1000000" -c "itm ports on" > /dev/null 2>&1 &
11  openocd_pid=$!
12  set +m
13  
14  echo Logging SWO output to $TMPLOGFILE
15  echo Press Ctrl+C to stop
16  
17  echo "running"
18  set -m
19  # Removing \x01 for stdout (still present in trace file)
20  tail -f $TMPLOGFILE | tr -d $'\x01'
21  set +m
22  echo "done"
23  
24  kill -9 $openocd_pid