1 of 32

Flashing your DIY Mutable Instruments Module over JTAG/SWD

Connecting to a mutable instruments module via JTAG with an STLinkV2 debugger or discovery (disco) board over SWD.

2 of 32

Use this walkthrough at your own risk

I assume this goes without saying, but everyone else always provides this notification at the top of any tutorial, so someone must have lost a lawsuit over not posting this info at some point.

Use this walkthrough at your own risk. I do not accept liability for damages to your diy unit for following this walkthrough. I am just some random dude on the internet and am not an authority on this module or this process.

The findings in this overview are in the interest of collaboration and helping others only. If you feel any of this is in error, feel free to reach out to me to correct.

Thanks and have fun!

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

3 of 32

Prerequisites

Your MI board of choice ready to power up. I recommend Adam’s website: https://www.amazingsynth.com/clouds-pcb/

A 12v AC (+12/-12) psu: https://www.tindie.com/products/p0k3t0/basic-eurorack-power-supply-kit-or-assembled/

A computer with Windows 7,8,10 (This is what I used after fussing w/ STM32CubeIDE for a while)

Micro Jtag connector (buy this w/ your MI module parts): https://www.adafruit.com/product/1675

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

4 of 32

Prerequisites

Discovery board (disco board) : https://www.digikey.com/product-detail/en/stmicroelectronics/STM32F0DISCOVERY/497-12876-ND/3045359

Your homebrew MI module:� Board from amazingsynth https://www.amazingsynth.com� Components from digikey https://www.digikey.com/� Specialty components and knobs from thonk https://www.thonk.co.uk

CHECK YOUR GROUND/3.3v RAILS AGAINST YOUR CHIP BEFORE POWER ON (In these instructions)

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

5 of 32

What is our goal?

We are trying to flash our STM32 via its JTAG port over SWD protocol via a discovery board.

The general order of steps is:

  • Connect MI Module (Clouds in my case) to the discovery board.
  • Connect MI Module to +12/-12 eurorack psu and power up (We should see 4 orange lights most likely)
  • Connect MI Module to discovery board via jtag interface (and disconnect the disco 2 st-link disco jumpers cn2)
  • Plug in discovery board to Windows machine via USB
  • Open and connect to ST-Link software
  • Upload firmware.hex and main.hex

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

6 of 32

Time sinks

https://mutable-instruments.net/modules/clouds/open_source/ is super useful, but most of this ended up not being helpful for just getting the hex file onto the board. I spent a lot of time setting up the interface to build the hex file only to find that I already had access to a pre-built hex file through amazingsynth.com.

Not checking voltages across all of the pins first. Trust the software. If the ST-Link can connect to the onboard STM32, it can connect to the MI module STM32. They are connected in an identical way.

Make sure your jtag connector is connected to the reverse side of the board. You may be tempted to solder the jtag connector to the same side as all the other parts, but this would be an error. The jtag, power and ftdi connect all connect on the rear side of the board, following the silkscreen indication.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

7 of 32

Time sinks

Having multimeter probes that are WAY too big to interface while troubleshooting. I made a pair of mini probes with some 16ga wire and some 22ga hookup cables. Made a little spring out of the 16ga and then soldered the 22ga wire to it as a probe. Put a small piece of shrink tube over it and bent the spring slightly so it kept constant pressure.

Mutable instruments forum (reasonably) will not assist with diy modules even in the diy section.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

8 of 32

What is an ARM STM32?

https://www.st.com/en/microcontrollers-microprocessors/stm32f405-415.html

Pins start to the left of the SMALL dot and rotate around the board counter-clockwise. VDD, then PC13, Then PC14, etc.

The large dot on the chip is not the indicator of pin 1, it’s a smaller dot and it is actually recessed. This is critical.

We will be communicating via STM over JTAG, which uses PA14(JTCK; clock) and PA13(JTMS; data)

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

9 of 32

Check your GND and 3.3V inputs

Set your multimeter to beep mode to check for dead shorts and put one terminal at ground. Check each of the 3.3v inputs on your STM32 chip and be sure that you don’t have a dead short from 3.3v to ground on any pin.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

10 of 32

SWD Connection

We will be communicating via SWD over JTAG, which uses PA14(JTCK; clock) and PA13(JTMS; data)

Thse 2 pins, paired with ground and 3.3v will give us connectivity to the discovery (disco) programmer.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

11 of 32

What is JTAG?

JTAG stands for Joint Test Action Group and is used to directly connect to a chip for general diagnostic and programming.

JTAG is industry standard and is built into most communication devices for troubleshooting.

We are using MicroJTAG, which uses 10 pins instead of 14 and the spacing of the pins is 0.05”.

For a full 30 minute rundown of JTAG, please watch EEVBlog’s overview here.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

12 of 32

What is SWD?

SWD stands for Serial Wire Debug and is a simplified and proprietary connection method for interacting with ARM brand microprocessors that combines all communication through the swdio pin.

We are using the jtag port, but we will actually be interacting with the device through SWD to program it.

This is important because you will have to select SWD from within the STLink software and the JTAG option may cause some confusion.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

13 of 32

JTAG/SWD Pinout

We are now looking at this from the perspective of the opposite side of the main board. The micro jtag connector connects to the back side of the board.

  1. 3.3v (voltage reference)
  2. Data (JTMS)
  3. Ground
  4. Clock (JTCK)

This may vary by device, but I have checked 4 other modules and they are all following this standard sequence.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

14 of 32

What is an STM32 Discovery Board?

The discovery board has an STLINKv2 directly on it.. It’s wired to the onboard chip

This also has a spare STM32 processor on it. The STLINK is totally isolated from this processor, so you could totally remove it from the board and use it in a pinch with a hot air rework station.

Unplugging the discovery pins (CN2) will disconnect the spare STM32 processor and you will have direct access to this unit as if it’s an STLINKv2.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

15 of 32

Connecting via SWD over JTAG

Pinout:

  1. Disco pin 1 — VSUP— rings/clouds/MI JTAG pin 1
  2. Disco pin 2— CLK— rings/clouds/MI JTAG pin 4
  3. Disco pin 3— GND— rings/clouds/MI JTAG pin 3
  4. Disco pin 4— DATA— rings/clouds/MI JTAG pin 2

On the disco board, disconnect both CN2 jumpers and set them aside

You should now be able to plug this in and communicate with your computer

Discovery

Board

MI Module

JTAG Port

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

16 of 32

STM32 Pinout

VDD is Ground

VSS is 3.3v vin

PB12 sits at 0.5v constant, this is your JTCK pin (clock)

PB11 sits at 3.3v constant, this is your JTMS pin (data)

NRST should be low. All other pins should be read low

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

17 of 32

STM32 Crystal

Prior to flashing, the crystal will not be running. The STM32 has an internal clock circuit.

An inactive clock is not subject for alarm.

The other crystal will be actively oscillating and may throw you off. I figured if 1 was oscillating, the other should be. Not so!

You may still need the crystal in place to flash the unit.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

18 of 32

Getting STLink

https://www.st.com/en/development-tools/stsw-link004.html

You have to register for an account. It’s free, but it’s weird and�controlling like most of these engineering softwares.

I ran into a problem where I had to use the same browser that I requested the software from. So ordering it in chrome, then going upstairs to my windows machine and opening it in firefox wouldn’t work.. Had to be chrome if I was browsing the website in chrome.

You’ll get a link to download an install. This will also install the drivers for the disco board.

Keyleth Cameron - keyleth.cameron@gmail.com

This is a living document and is subject to change

19 of 32

There are 2 files...

Adam from AmazingSynth.com sends pre-built binaries whenever you buy from him.

Both hex files (located in AmazingSynth.com’s repository below) are available inside their own folders. There is a bootfile and the main folder. You need both folders for each module.

https://www.dropbox.com/sh/z7p2epcbigvl57c/AADl-A8MvFatvBTd0IGirK2ha?dl=0

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

20 of 32

Uploading firmware via STLink

Once everything was hooked up, this was REALLY simple. Like stupidly simple.

  1. Open your hex file. I ran firmware first, then main.
  2. Connect to device. This should work instantly, but if it doesn’t, we’ll troubleshoot in the next menu.
  3. This will upload the code (after another menu we’ll go over).

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

21 of 32

Uploading firmware via STLink

These are my successful settings.

Once I had a proper connection, after I clicked connect (or refresh here) I got a firmware version and a serial number.

Note I have selected SWD and 4.0MHz

Hot plug and reset mode kept throwing me for a loop. It would ask me to change these settings to connect, but these ended up being what I needed.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

22 of 32

Uploading firmware via STLink

I didn’t change a dang thing here. But here are my settings.

Reset wont work because we didn’t hook up the reset pin, so you’ll have to manually reset after it’s done flashing.

If you made it here, congratulations! Hit Start and upload your firmware. Then do the whole process a second time and upload the main file.

HOLY DOOTS YOU’RE DONE! CONGRATULATIONS!

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

23 of 32

Resources (Written Knowledge)

Cheeky tutorial on building MI clouds

Installing firmware

Purchase list

PCB Purchasing Location

FTDI programmer (not needed)

Parts list (BOM)

STLink Debug Overview

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

24 of 32

Resources (Videos)

JTAG

Boundary Scan

SWD

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

25 of 32

Resources (Software)

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

Driver/download website for the STLink Programmer (windows only)

Autodesk EagleCAD reader

STM32CubeIDE

26 of 32

Resources (Stores)

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

PCB Website and resources to build your own MI board from scratch

General electronics distributor

General electronics distributor

Electronics prototyping distributor

Knobs/Pots/Jacks

Knobs/Pots/Jacks

27 of 32

Acknowledgements

Acknowledgements to the community at https://www.reddit.com/r/synthdiy�Thank you for all of your help!

Thank you Adam at https://www.amazingsynth.com for all of your help.

Thank you to Mutable instruments for all of the resources you have provided open-source.

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

28 of 32

Contact me

Keyleth Cameron

keyleth.cameron@gmail.com

This is a living document and is subject to change

Keyleth Cameron - keyleth.cameron@gmail.com

29 of 32

Appendix: A

This is a living document and is subject to change

Pinouts on stm32

Keyleth Cameron - keyleth.cameron@gmail.com

30 of 32

Appendix: B

This is a living document and is subject to change

Pinouts on discovery board

Keyleth Cameron - keyleth.cameron@gmail.com

31 of 32

Appendix: C

This is a living document and is subject to change

General schematic of clouds

Keyleth Cameron - keyleth.cameron@gmail.com

32 of 32

Appendix: C

This is a living document and is subject to change

General schematic of clouds

Keyleth Cameron - keyleth.cameron@gmail.com