Close

USB host mode

A project log for Modular MIDI

Using a CAN bus to distribute MIDI messages in a modular synthesizer

davidDavid 02/01/2024 at 21:340 Comments

I have slowly been making progress on the USB module over the past months, but it has not been easy. This is my first time using the RP2040 and CMAKE so that is the source of most of these hurdles. 

Even getting blinky working with the RP2040 took a long time. The USB bootloader worked as expected, I could upload code and verify the binary file. But when it exited the bootloader the device would be completely dead. I thought it was a problem with the crystal because it was not oscillating, so I spent some time resoldering components. But it turns out the RP2040 uses two bootloaders and the default second-stage bootloader is not compatible with the flash chip I am using. Blinky finally worked when I added the right flash settings to the board header file.

One hardware issue I discovered on the new PCBs is that the new USB CC chip is host only... It handles CC to ID interpreting and has an integrated power switch for the connected device. BUT it does not have the pulldown resistors to advertise being a device, so it will not work for a dual-role port. I have switched it back to a TUSB321 and MIC2005 in the schematics. I will not order a PCB with this fix because I can get around the bug using a USB-A to USB-C cable, so I'll get the testing done anyway.

The first feature I tried implementing was the USB host mode because it was the biggest feature missing in the last version. I used an existing MIDI host driver to handle the USB side of driving the devices. There was a pull request with this feature on the TinyUSB library, but it never got pulled. So this driver adds the functionality from that pull request. Host mode mostly works on this module now: It works with my MPK mini and modwave, even via a USB hub. However, it does not work with the beatstep pro and a USB-C hub with extra features like an SDCARD reader and HDMI port. There is some debugging to do there I guess.

Then I started implementing code from the previous version. There were a couple SAMD specific commands in my libraries, and linking the libraries with CMAKE gave me so much trouble. But adapting the libraries for RP2040 was otherwise pretty simple. It is now at the point where it sends messages to other modules over the CAN bus. Device mode and I2S are still not working, and I haven't implemented the external EEPROM or RAM chips in the code yet.

This week I found out that some great resources for MIDI 2.0 have become open-source. I will probably switch to their MIDI library because it has implemented capability inquiry and other features. There are finally tools I can test MIDI 2.0 functionality with, there is even a device driver for TinyUSB. But I want to get the two other modules working before I continue with the USB module because the non-linearity of the previous CV16 module makes it impossible to do a good demo and the tangle module is almost done.

Discussions