Did you know you can use the Banana Pi BPI-M4 as an STM32 / ARM MCU programmer/debugger (SWD over SPI)? Here’s how it works:
-
Activate SPI in the kernel as described here: https://wiki.banana-pi.org/Getting_Started_with_M4#Enable_SPI
-
Install OpenOCD variant with SPI
a) from here: https://www.pcbway.com/blog/technology/OpenOCD_on_Raspberry_Pi__Better_with_SWD_on_SPI.html
-OR- from here: https://github.com/lupyuen/openocd-spi
c) Download jimctl and put it in OpenOCD folder: https://github.com/spiderkeys/jimtcl
- Connect Banana-PI and STM32 MCU via 3-wire SPI as follows (left is Banana PI with SPI pins, right is your MCU with SWD pins):
-
In downloaded OpenOCD code, change (SPI mode to 1 and speed to 500 Khz) in file ‘src/jtag/drivers/bcm2835spi.c’ as follows:
static uint8_t mode = 1;
static uint speed_khz = 500;
-
Compile OpenOCD:
./bootstrap (when building from the git repository)
./configure --enable-sysfsgpio --enable-bcm2835spi --enable-cmsis-dap
make
-
Run OpenOCD to flash your STM32 MCU with the Banana PI : https://www.pcbway.com/blog/technology/OpenOCD_on_Raspberry_Pi__Better_with_SWD_on_SPI.html
Feel free to ask questions / make comments