Midi 2.0 on ESP32S2?

Anyone have any luck getting MIDI 2.0 working on espressif32 MCU’s? There’s a number of libraries meant to help from midi2-dev, namely tsub_ump and AM MIDI 2.0 Lib, but these generate what I believe are linker errors. I’m relatively new to C programming and platformio in general, so I’m unsure how to resolve these:

c:/users/<user>/.platformio/packages/toolchain-xtensa-esp32s2/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: .pio\build\lolin_s2_mini\src\main.cpp.o:(.literal._Z11sendMidi2CChht+0x8): undefined reference to `tud_ump_n_mounted'

c:/users/<user>/.platformio/packages/toolchain-xtensa-esp32s2/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: .pio\build\lolin_s2_mini\src\main.cpp.o:(.literal._Z11sendMidi2CChht+0xc): undefined reference to `tud_ump_write'

c:/users/<user>/.platformio/packages/toolchain-xtensa-esp32s2/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: .pio\build\lolin_s2_mini\src\main.cpp.o: in function `sendMidi2CC(unsigned char, unsigned char, unsigned short)':

C:\Users\<user>\My Drive\MCUBasedProjects\MIDI2Ctrl/src/main.cpp:31: undefined reference to `tud_ump_n_mounted'

c:/users/<user>/.platformio/packages/toolchain-xtensa-esp32s2/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: C:\Users\<user>\My Drive\MCUBasedProjects\MIDI2Ctrl/src/main.cpp:32: undefined reference to `tud_ump_write'

collect2.exe: error: ld returned 1 exit status

*** [.pio\build\lolin_s2_mini\firmware.elf] Error 1

platformio.ini

[env:lolin_s2_mini]
platform = espressif32
board = lolin_s2_mini
framework = arduino
lib_deps =
  bodmer/TFT_eSPI
  https://github.com/midi2-dev/tusb_ump
  https://github.com/midi2-dev/AM_MIDI2.0Lib
lib_ldf_mode = deep+
build_flags =
  -D USE_TFT_ESPI       ; Required for the TFT_eSPI library
  ; Flags for TinyUSB MIDI 2.0
  -D USB_VID=0x1209
  -D USB_PID=0x0042
  -D USB_PRODUCT="\"MIDI2 Controller\""
  -D USB_MANUFACTURER="\"AKEng\""
  -D USE_TINYUSB
build_unflags = -DUSB_VID -DUSB_PID -DUSB_PRODUCT -DUSB_MANUFACTURER
monitor_speed = 115200

These functions are missing because they’re wrapped inside a compile-time if statement

So since the macro CFG_TUD_UMP (and later on CFG_TUD_UMP_RX_BUFSIZE and CFG_TUD_UMP_TX_BUFSIZE) are not defined, it won’t build those functions. So you need to at least add

  -DCFG_TUD_UMP
  -DCFG_TUD_UMP_RX_BUFSIZE=128
  -DCFG_TUD_UMP_TX_BUFSIZE=128

to your existing build_flags list.

1 Like

Oh wow! That totally did it. I spent hours looking in the wrong places. Thank you for that!