This should also get you started with other Mutable STM32F modules including Elements, Warps, Marbles and Clouds.
If you don't feel like going through all this rigamarole, you can download a wav of the firmware instead.
If you don’t want to scratch your module’s faceplate, maybe get a spanner head screwdriver like this.
I’ve made Amazon Affiliate links here, so I get a bit of money (eventually, maybe) if you buy anything via this page. The downside is Bezos gets paid too, but that’s quite hard to avoid these days isn’t it?
Here are the instructions on the Mutable Instruments website:
https://mutable-instruments.net/modules/plaits/open_source/
The important bits are:
If you don’t mind installing Vagrant and VirtualBox a cozy environment for firmware hacking is available.
See step 1 below for details on what this means and how to do it.
Then (at time of writing) it says:
Firmware programming
The recommended solution for firmware programming is to use a ST Discovery board.
Connect the 4 SWD lines of the board to the 4 programming lines of Plaits (RESET
,SWDIO
,SWCLK
andGND
).
Make sure that the programming interface (PGM_INTERFACE
variable) is set tostlink-v2
instmlib/programming.inc
.
Upload the firmware with:
make -f plaits/makefile upload
There’s a lot to unpack here. And it wasn’t quite right in my case so I’ll share my findings along with the more detailed steps below.
I am in no way responsible if you break something following this guide. The steps below are indicative of the journey I took and should not . This is not 100% straightforward so please be careful.
First you have to get get VirtualBox and the Mutable Dev Environment up and running.
vagrant up
vagrant ssh
I covered this in much more detail in my previous video where you can follow along until about 4:00 before coming back here.
Unlike Grids, Plaits does not come with a header to connect a programmer. This was to cut costs apparently. So we need to solder a header on the back.
You need to solder a four pin header to the board at the location shown below:
As per the instructions we need to:
Connect the 4 SWD lines of the board to the 4 programming lines of Plaits (
RESET
,SWDIO
,SWCLK
andGND
).
These aren’t labelled on the board itself but I found the labels in the PCB design. I used the free EAGLE app to view the PCB.
I checked the user manual for my board to see how to connect it, searching for SWD in the document.
So I saw that
RESET
, SWDIO
, SWCLK
and GND
) are available on pins 5, 4, 2 and 3 respectively - with pin 1 marked •
Carefully cross-reference the two guides and use jumper cables to connect each pin to its counterpart of the same name on the other board.
I would recommend making sure at least one side uses the leads in-order so it’s easy to disconnect and reconnect without checking the pin diagrams again.
There might be multiple USB ports so make sure you connect the right one
My board showed up as an external drive on macOS when I plugged it in.
You could also check About This Mac to look for it under USB.
Jump into the dev environment:
$mac vagrant up
$mac vagrant ssh
Then inside the dev environment type lsusb
vagrant@vagrant-ubuntu-trusty-64:/vagrant/eurorack-modules$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
If you don’t see anything that says something like ST-LINK
--
*
then your board probably isn’t connected.
Launch the VirtualBox app, select the mutable-dev-environment and click USB to see the device whitelist.
Then you need to restart the VM and try lsusb
again.
$vagrant exit
$mac vagrant halt # stop virtual machine (VM)
$mac vagrant up # start VM
$mac vagrant ssh # log into VM
$vagrant lsusb # list connected usb devices
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0483:374b STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB)
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
My board showed up as ST-LINK/V2.1 (Nucleo-F103RB)
.
If Plaits isn’t responsive when plugged in, you might need to disconnect the jumper cable, turn your rack off and on again and then reconnect to the development board.
Plaits should run okay once it’s connected.
On the website the instructions say this:
Make sure that the programming interface (
PGM_INTERFACE
variable) is set tostlink-v2
instmlib/programming.inc
.
But this isn’t quite right.
More up-to-date instructions for setting PGM_INTERFACE
are available on the Github repo.
Using a different programmer
To use a programmer other than the default (AVR ISP mkII, ARM-USB-OCD-H) it is no longer necessary to edit the makefiles. Instead, the programmer can be set in the shell for the current session, e.g.
export PGM_INTERFACE=stlink-v2
export PGM_INTERFACE_TYPE=hla
You also need to match the stlink version with your board
My board is named STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB)
so it turned out I needed this:
export PGM_INTERFACE=stlink-v2-1
I found all the possible devices here in OpenOCD in case you’re wondering.
Now you now upload firmware with
> make -f plaits/makefile upload
It takes a few seconds during which you should see light flashing on your development board. Plaits will be unresponsive until the upload is complete.
We did it!
Now we can try some new code…
You can change Plait’s chord arrangement by uncommenting one line of code in plaits/dsp/engine/chord_engine.h.
Change this:
// #define JON_CHORDS
to this:
#define JON_CHORDS
Then upload this with:
> make -f plaits/makefile upload
You will now have a new chord layout in the Chords engine, described here.
I referenced this page to create an array of Just Intonation ratios based on the JON_CHORDS
layout, like so:
This array is called chordsAsRatios
so I replaced the call to SemitonesToRatio
to use the defined ratios directly.
// OLD CODE: ratios_\[i * kChordNumNotes + j] = SemitonesToRatio(chords[i\][j]);
// NEW_CODE:
ratios_[i * kChordNumNotes + j] = chordsAsRatios[i][j]; // NEW CODE
Here it is on Github, with the main commit being here.
Or if you just want to try it out, download the wav below. Otherwise, hopefully see you on my Twitch soon!