Error while using the MIDIUSB library

Hello,

I tried to upload a simple sketch on the arduino nano BLE using the MIDIUSB library.
Only I get an error saying the library is not compatible with the current board.

The arduino nano ble has a native usb and uses an ARM microcontroller therefore I don't get why it isn't compatible.

Thanks.

It's generally handled by this file MIDIUSB/library.properties at master · arduino-libraries/MIDIUSB · GitHub

You'll find this file in the local library folder.

So, if you're convinced the nano should work then you need to amend this file. The simplest and quickest for testing purposes, is to delete the "avr,sam,samd" and replace with a "*"

Now the complicated bit.

You'll also need to amend the library files too as it includes directives such as:
#if defined(ARDUINO_ARCH_AVR) and #elif defined(ARDUINO_ARCH_SAMD) etc. which make it board specific.

So, looks like to me they've made this library SAMD specific rather than ARM generic

Hello vuhianp365,

Further to @gerrikoio's comments. Looking at the errors, it seems that the Nano BLE doesn't currently fulfil the requirements in MIDIUSB.h, specifically:

#if !defined(USBCON)
#error MIDIUSB can only be used with an USB MCU.
#endif

and

#if defined(ARDUINO_ARCH_AVR)
...
#elif defined(ARDUINO_ARCH_SAM)
...
#elif defined(ARDUINO_ARCH_SAMD)
...
#else

#error "Unsupported architecture"

I think it would need something like #if defined(ARDUINO_ARCH_NRF52840) or similar as although the BLE does use an ARM MCU it uses a mbed operating system which this library doesn't account for. This may be a simple case of updating the library definitions to suit the Nano BLE. For example, if you complie the MIDIUSB examples for a Nano IoT (SAMD) it doesn't have any errors.

I am not an expert but it might be worthwhile raising this as an issue on the official library GitHub.

Hope that helps,
Matt

Thanks for both your answers.

I understand the problem now. I'll open an issue on the github before starting hacking the library files ^^.

Have a good day,

Isaac