SWD programming using a RaspberryPi

I previously write this post on how to use a BeagleBoneBlack as a JTAG (SWD) programmer. It was fun but really slow. I port my code on RaspberryPI and now what was taken 5-8 hours is a couple of minutes.

To connect the SWD connector to the PI use the following schema

Connect SWD to RaspberryPi

Connect SWD to RaspberryPi

I use this peace of code to reflash my TD1204 and TD1208 based both on EFM32 when bricked after unsuccessful update…

Here is the python file to interact with SWD : https://github.com/disk91/PySWD/blob/master/RpiGPIO.py

I hop it will be soon integrated in the main PySWD project as the previous one.

You should check or modify flashEFM32.py file

import array

from PirateSWD import *
from RpiGPIO import *
from SWDCommon import *

[...]

def main():
    busPirate = RpiSWD("", vreg = True)
    debugPort = DebugPort(busPirate)
    efm32     = EFM32(debugPort)

To run the Flash program, just launch

# ./flashEFM32.py ../myProgram.bin

 

Use of BeagleBone GPIO for SWD programming

Recently I killed on of SigFox Td1208 device by misprogramming it, destroying the bootloader. In a such situation serial port is not anymore accessible for programming. The use of JTAG port is a necessity. On the TD1208, jtag has been repaced by SWD which is a 2 wires port doing the same thing.

To use this port, you generally need a specific interface. These interfaces like Jlink are expensive (> 300€), some are less like BusPirate (30€). By the way, if you do not have it, you will have to order and wait for it. That’s why I’ve taken the choice of using my BeagleBone black device GPIO to pilot these signal. This code can easily be port to RaspberryPI…

Continue reading