Hack of the MIDIPLUS/MIDITECH 4x4 USB MIDI
The idea
I currently own 2 MIDI 4X4 from Miditech/Miduplus manufacturer.I thought it was possible to stack the 2 on the same PC to get 8x2 ports IN/Out. But as theses devices have exactly the same product and vendor ID, and no serial, it is in fact impossible to do that without conflicts (it seems however some people installed 2 MIDI 4X4 succefully on the same computer...). So the only alternative was to buy a 8x8 interface to the same manufacturer, for the three times the price of the MIDI 4x4 that I did not.
More, recently, one of my interface started to work incorrectly, invoking to me a corrupted firmware.
I asked to the Miditech and Midiplus support and they were enough kind to provide to me an updated firmware kit, but for the NEW version...Happy to learn that my interface was the "old" one, however still sold on many web sites today...I tested that update package without any success...My version was not updatable at all they said.
I could'nt accept that a device (almost) still in order with USB, 8 ports 4IN - 4 OUT goes directly in the trash bin. Nothing to loose, I opened the box, and inside I discovered that the microcontroller was a STMF103RC, a very common uC on musical gears(the Arturia Minilab and the Novation launchkey and launchpad are using it for example).
Here start the idea of a possible hack :I have a board available with a programmable and powerfull chip, native USB, plus all the circuitry for 4 MIDI IN / 4OUT.Why not rewriting a new firmware from scratch as I did for other uC like of the AVR family ? I could even extend that firmware to enable merge mode, thru mode, specific routing and filtering modes.So, building an ultimate USB MIDI interface better than the original....
First steps
The STMF103 has an internal bootloader working with the UART Serial 1. The bootloader mode is activated by maintaining the Boot0 pin to HIGH and the Boot1 pin to LOW. So I desoldered 2 resitors on the board because they were disabling that mode,made a small reset button / "boot1 HIGH" circuit, and soldered the boot 0 to ground.
I also connected TX and RX of the serial 1 to a small plug. That was easy because some large labelled TXn / RXn pads exist on the MIDI4x4 motherboard. I connected that plug to an USB Serial TTL, and 2 H later, I was able to upload a new firmware in the thing.
The original Miditech / Midiplus firmware is protected against read. I had to accept the "The chip will be entirely erased if you continue.." warning. Not a problem as hacking the existing firmware was not my goal at all.
STMDUINO
To preserve and reuse my existing software libraries, I choose to use STMDUINO.
It is port of the Arduino platform to the ARM STM32 chip family from ST Micro. So you can develop "sketches" as usual, with the Arduino IDE, and reuse your existing "Arduino" code.
I flashed a modified STMDuino generic bootloader2.0 to the board with STMFLASH, and tested the 4x4 board as a generic STMF103RC in the Arduino IDE... my MIDI demo sketch worked at the first compilation...And I could address the 4 serial ports connected to midi jacks.
I have rewritten entirely the firmware from a white page, and I have extended its features to enable routing : "4 merge" mode, thru mode, split mode, etc, So I can say my modified USB interface 4X4 is now better than the original, very stable, and, the most important stackable with my existing one as I changed, obviously, the Product ID !
The STM32F103 is really really fast...no lag at all, even at 300 BPM with 4IN/OUT working. At this time, I use the box with the new firmware in my MIDI setup :-) !
The code is easily adaptable to any other multi-jack USB interface.
https://github.com/TheKikGen/USBMidiKliK4x4
Uploading the STDMDuino modified bootloader
You need to modify the board to enable the internal bootloader of the STM32F103. To do that, start by unscrewing the front plate of the case, and remove the board from the case.
- Remove the R28 resistor because it's disabling the bootloader standard mode. Connect a 10K resistor between the boot1 pin and the ground as shown.
- Solder a wire to the Boot0 pin, and another to the VCC 3,3V pin. Connect the wires together. This can be removed after the STMDuino bootloader download
- Plug the Miditech/Midipplus board into the USB
- Launch STM Flash loader demonstrator (if you don't have it , check the ST Micro. web site) and reset the Miditech/Midiplus board by by touching the RST tap point and the ground (for example the USB plug shield). As the chip is in bootloader mode, you will, or hear nothing...
- Connect TTL RX 1/TTL TX1 from the Miditech/Midiplus board to the TTL RX/ TTL TX of your serial USB converter. You can solder 2 wires to the pads clearly labelled on the board it self, or just hold the wires with the left hand and do the rest with the right one !
- Choose the right serial port in the list proposed by STMFlash tool the click on "Next"
At this point, it is still time to stop. After that step, not return possible !!!!!
- You will see a red warning indicating that the firmware is protected, and going further will erase it. So, if you are really sure, click on "Remove protection". The existing Miditech/Midiplus firmware will be entirely erased.
- Click next, and choose the "midiplus4x4_boot20.bin". This is the STMDUINO bootloader,especially modified for the Miditech/Midiplus board (notably to activate the USB with a DISC command on PA8). Check "Optimizer", "Global Erase", and "Verify after download", then "Next". The download will start, and if everything is ok, you will have a message confirming that the the update was done correctly.
- Unplug, and plug agin the Miditech/Midiplusboard : that will activate the STM32DUINO perpetual bootloader mode. If the blue led is flashing, you are ready to use the Arduino IDE with that board !