Atmelsam@3.8.0 won't compile MIDIUSB@1.0.4 with Feather M0

it works fine with atmelsam@3.7.0
here is my Platformio.ini

[env:adafruit_feather_m0]
platform = atmelsam@3.8.0
board = adafruit_feather_m0
framework = arduino

lib_deps =
MIDIUSB@1.0.4
SSD1306Ascii@1.2.4

It gives many errors
.platformio/packages/framework-arduinosam/cores/adafruit/USB/USBAPI.h:118:23: error: conflicting declaration ‘USBDeviceClass USBDevice’
.platformio/packages/framework-arduinosam/cores/adafruit/USB/USBAPI.h:189:16: error: conflicting declaration ‘Serial_ Serial’
.platformio/packages/framework-arduinosam/cores/adafruit/USB/USBAPI.h:118:23: error: conflicting declaration ‘USBDeviceClass USBDevice’

Can you also post a minimal cpp file which reproduces the problem?

Sure !
Here is my source : https://pastebin.com/p2cLwpSg
Thanks a lot

Uncompilable for me without the library

#include "MCP23008.h" //from http://gtbtech.com/?p=875

and the link is dead.

Well anyways as can be seen from the changes made from 3.7.0 to 3.8.0

This now uses a different core (“TinyUSB core”, refer here and here)

     if BUILD_CORE == "adafruit":
        env.Append(
            CPPDEFINES=["USE_TINYUSB"],
            CPPPATH=[
                join(FRAMEWORK_DIR, "cores", BUILD_CORE,
                     "Adafruit_TinyUSB_Core"),
                join(FRAMEWORK_DIR, "cores", BUILD_CORE,
                     "Adafruit_TinyUSB_Core", "tinyusb", "src")
            ]
        )

And the library is incompatible with that new core.

Adding

board_build.core = samd

To the platformio.ini makes it use the previous core again and the compilation succeeds.

So as I see it there was a breaking change in the TinyUSB core from the upgrade or PlatformIO decided to use a new core alltogether, not sure right now.

Of course, a good way would also be to update the MIDIUSB library to support the TinyUSB core.

1 Like

And finally, TinyUSB also has USB-MIDI support, see example sketch Adafruit_TinyUSB_Arduino/midi_test.ino at master · adafruit/Adafruit_TinyUSB_Arduino · GitHub

I force the platform with

    [env:adafruit_feather_m0]
    platform = atmelsam@3.7.0
    board = adafruit_feather_m0
    framework = arduino

but I want a real solution. How to fix the MIDIUSB library ?

My understanding is that MIDI.h allow to receive MIDI data.
MIDIUSB.h allows the board to be seen as a MIDI instrument from the computer.

Actually looking at the MIDIUSB library I don’t think a rewrite to another core would be very feasable as someone who just wants to use the USB-MIDI functionality. You should either switch your firmware to use the new API (as linked above) or set board_build.core = samd to use the old core with no firmware changes but still the newest platform version.

Thanks for the update

For the moment I use board_build.core = samd but I am afraid it is not a sustainable solution
I am trying to get it to work with the TinyUSB but it won’t compile too (I am reporting this to Adafruit)https://github.com/adafruit/Adafruit_TinyUSB_Arduino/issues/14