Skip to main content Skip to local navigation

TinyUSB on the ESP32-C6 -- I mean ESP32-S3: First Steps

CircuitMess Bit 2.0 board
CircuitMess Bit 2.0 board with an ESP32-S3 processor on board.

I am interested in developing MIDI 1.0 and MIDI 2.0 applications on embedded devices. As part of Designing Sound Futures, I worked with Mohaimen Hassan on Shetu, the very first MIDI 2.0 device produced in an academic setting. Unlike other attempts, it was written completely in C, with no other libraries or programming languages. The first attempt was on an NXP K25 microcontroller but the final proper version was developed on an NXP K32. We chose to use an existing and widely-used, broadly-ported USB library (TinyUSB) rather a simpler, single processor or single toolchain. USB is complicated and multi-faceted, so using a library like TinyUSB or CherryUSB makes sense.

The NXP processors were used because I have taught with Kinetis processors in the past, but I am now teaching with Espressif processors like the C3 and C6 here at York University. In this blog post I'll explore MIDI 1.0 on an ESP processor as a step towards the MIDI 2.0 port.

The Espressif team maintains its own fork of TinyUSB. So, to get started you'll need to install the ESP32-IDF tools (e.g. for Windows), which can be done through PowerShell using the EIM commands. If you're missing Python, it will add it. Here is an alternative video overview if you want to use the EIM GUI. Once it's installed you should see a message like:

"You can now use IDF commands and Python tools."

Ah, but for some reason, the compiler tools aren't being found on my Windows PowerShell, so I'm going to switch back to my Mac.

The Espressif GUI is also available on both my Mac and Windows boxes and, after updating the IDE, has the TinyUSB examples, including the MIDI 1.0 example:

Espressif IDE screen with TinyUSB MIDI example highlighted.  Only S3, P4 and S2 targets are supported.  Not the RISCV boards.
Espressif IDE screen with TinyUSB MIDI example highlighted. Only S3, P4 and S2 targets are supported. Not the RISCV boards.

Once loaded, the MIDI 1.0 example compiles fine:

TinyUSB example program compiles successfully.
TinyUSB example program compiles successfully.

Unfortunately, this is for the S3 version of the ESP32 family only. (e.g. Waveshare S3) No support for C3 or C6 which is what I use in my teaching. I don't have an S3 development board around but my kid has a CircuitMess Bit 2.0 with an S3 on it. If I'm going to experiment with it I'll need to make sure that I can reflash the firmware.

When I plug in the CircuitMess Bit 2.0 my Arduino IDE spots it:

Arduino IDE recognizes the S3 board inside the CircuitMess Bit 2.0.
Arduino IDE recognizes the S3 board inside the CircuitMess Bit 2.0.

Furthermore, I can see what port it is located on: (/dev/cu.usbmodem11101)

And to flash that firmware I need the esptool package, which can be installed on my Mac using Homebrew, which I then ran on the most current binary (version 3.1) from the developer site:

esptool -c esp32s3 -b 921600 -p /dev/cu.usbmodem11101 write-flash 0 Bit-v3.1.bin
command line interaction with the board using the ESPTOOL utility to reflash the CircuitMess Bit 2.0 board.

Which successfully wrote to the board and ended with a reboot and a happy chirping sound.

From the Espressif IDE on my Mac the board is also identified using the IDE's "ESP-IDF Manager" utility:

Espressif IDE identifies the board as a proper ESP32-S3 on the builtin USB-JTAG connector.
Espressif IDE identifies the board as a proper ESP32-S3 on the builtin USB-JTAG connector.

I then tried to flash the board, and was presented with the following error:

And, now, the ESP-IDF manager cannot find the serial port, nor can it find the board. Whoops. The screen on the board is now white, too. But -- good news! -- a TinyUSB device is found when getting a system report:

TinyUSB device appears on the System Report for the Mac.
TinyUSB device appears on the System Report for the Mac.

And with the ShowMIDI utility I can see notes being transmitted:

ShowMIDI shows midi notes.
ShowMIDI shows midi notes.

And, when piped through MultiTrackStudio Lite we can hear the notes:

So... the MIDI 1.0 example for TinyUSB on an ESP32S3 works. Now I have to figure out how to reset the firmware on the S3 before my kid finds out that the CircuitMess Bit 2.0 doesn't play video games anymore!

Next up, I need to reset the Bit 2.0 board so that the programming port pops up... seems like grounding one of the GPIO lines is required. (Manual link for the ESP32-S3). Can't seem to find a schematic for the Bit 2.0 so I'll resort to posting on the CircuitMess forum to see if one of the Bit 2.0 buttons is linked to GPIO 0.

Once that's resolved, then I'll have to see if I can port Shetu's K32 version of the MIDI 2.0 code to the S3-based Bit 2.0 board.


a pen

James Andrew Smith is a Professional Engineer and Associate Professor in the Electrical Engineering and Computer Science Department of York University’s Lassonde School, with degrees in Electrical and Mechanical Engineering from the University of Alberta and McGill University.  Previously a program director in biomedical engineering, his research background spans robotics, locomotion, human birth, music and engineering education. While on sabbatical in 2018-19 with his wife and kids he lived in Strasbourg, France and he taught at the INSA Strasbourg and Hochschule Karlsruhe and wrote about his personal and professional perspectives.  James is a proponent of using social media to advocate for justice, equity, diversity and inclusion as well as evidence-based applications of research in the public sphere. You can find him on Twitter.  You can find him on BlueSky. Originally from Québec City, he now lives in Toronto, Canada.