Every possible connection Mar 2017

The Raspberry Pi does not really need an introduction: Linux plus some tinkering pins - who could possibly ask for more? It has all the features needed to create a flexible and powerful programming / debugging tool for microcontrollers. It can even run entire toolchains for cross-compiling for a wide variety of these µCs.

One tricky aspect, which is probably the main stumbling block if you’ve ever looked into trying out things with a 32-bit ARM-based µC, is how to get the software onto those chips. There are many ways, well-researched on this weblog and elsewhere, but they all have little quirks - from trouble with connecting everything together, to not being portable across Win/Mac/Lin, to requiring a special programmer - it quickly turns into a chicken-and-egg kind of adventure:

YOU ARE IN A MAZE OF TWISTY LITTLE PASSAGES, ALL ALIKE

Here is yet another setup, which requires nothing other than a working Raspberry Pi (to be called “RasPi” from now on) - of which there are millions by now. Best of all, it’ll work with any RasPi model (and probably most compatible alternatives), no matter how old or limited:

We’ll use nine pins on the RasPi’s header - all in the first 26 pins, i.e. present on all models:

Function RasPi name Header Pin
+3.3V power - 1
+5V power - 2, 4
Ground - 6, 9, 14, 25
Serial out TX 8
Serial in RX 10
µC RESET GPIO 18 12
µC BOOT0 GPIO 23 16
µC SWDIO GPIO 24 18
µC SWCLK GPIO 25 22

Here is an example how these pins could be wired to a few female headers:

Below is a fully self-contained unit, hacked together from parts lying around here at JeeLabs. The tape keeps some unused wires from the 26-core flat cable out of harm’s way:

There’s a small USB power bank (based on the very common 18650 LiPo cell) and in this case also a WiFi dongle, plugged into the only USB port available on this older RasPi 1, model A. Any SD card of at least 2 GB will do, and it’s all meant to be used via SSH, i.e. via the cmd-line.

In the above setup, you can also see a 470 µF capacitor between +5V and GND, and another one of 47 µF between +3.3V and GND, because old RasPi’s are sensitive to power fluctuations. Without them, plugging a µC board into any of the headers can trip it up and reset the RasPi.

For JeeNode Zero boards, with a FTDI pinout including DTR & RTS, we can plug in as follows:

To connect a JNZ for programming over SWD, this will work (note the extra RESET wire):

For a HyTiny F103 board, we need to use its dedicated header (again with extra RESET wire):

And lastly, the Blue Pill board has its own header (yes, it too needs the RESET wire):

The RESET wire is not always needed for programming over SWD. It depends on whether the code running on the µC has disabled SWD - when SWD is disabled, the only way to get control back is to connect RESET. Asserting this signal keeps the µC in reset during programming.

Coming next: setting up the software to turn this RasPi into a general-purpose µC tool…

Weblog © Jean-Claude Wippler. Generated by Hugo.