One of the more interesting things I've done was to turn it into a JTAG dongle using openocd. Openocd can be configured to use the GPIO ports on RPI2 as JTAG debug pins. You can then connect those pins to your stm32 boards to implement a JTAG debugger. The file below shows you how I configured the RPI2 to act as a SWD debugger for my red pill stm32f103.
Code: Select all
# RPI2 as a SWD JTAG device and stm32f103 red pill as target
# RPI2 - STM32F103
# GPIO18 ---> DCLK
# GPIO23 ---> DIO
# GND ---> GND
# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on system clock, calibrated for stock 900MHz
# bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
bcm2835gpio_speed_coeffs 146203 36
# Each of the SWD lines need a gpio number set: swclk swdio
# Header pin numbers: GPIO18 GPIO23 (pins 12 and 16 on J8 connector)
bcm2835gpio_swd_nums 18 23
transport select swd
set WORKAREASIZE 0x2000
source [find target/stm32f1x.cfg]
Just connect jumper wires as described in the file above and then launch openocd and connect to it using arm-none-eabi-gdb.
Code: Select all
root@raspberrypi:/home/pi/openocd_cfg#openocd -f ./rpi2_redpill.cfg
Open On-Chip Debugger 0.10.0-dev-00220-gdfc6658-dirty (2016-02-19-16:19)
Licensed under GNU GPL v2
For bug reports, read
BCM2835 GPIO nums: swclk = 18, swdio = 23
adapter speed: 1000 kHz
cortex_m reset_config sysresetreq
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
Info : clock speed 1001 kHz
Info : SWD IDCODE 0x1ba01477
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
After running the command above, openocd is exposing a gdb server on port 3333. You could connect to it from arm-none-eabi-gdb running on your RPI2 or more interesting would be remotely from a windows or linux development machine using the ethernet address of your RPI2. (something like : $ arm-none-eabi-gdb -ex 'target extended-remote 192.168.0.100:3333') The big advantage to using the raspberry pi 2 as the JTAG dongle, you don't need to install any drivers on your windows, mac or linux development machine. The commands are sent over a TCP/IP socket but take place on the RPI2.
So yeah, yet another interesting way to twiddle with the bits on your stm32 boards.