probonopd / MiniDexed

Dexed FM synthesizer similar to 8x DX7 (TX816/TX802) running on a bare metal Raspberry Pi (without a Linux kernel or operating system)
https://github.com/probonopd/MiniDexed/wiki
1.07k stars 78 forks source link

Add USB Gadget Device support #567

Closed diyelectromusic closed 10 months ago

diyelectromusic commented 10 months ago

This fixes issue https://github.com/probonopd/MiniDexed/issues/547 and provides an option to enable USB gadget support in MiniDexed on those Raspberry Pi hardware devices that support it.

This is configuring using the following option in MiniDexed (assumed set to 0, off by default): USBGadget=1

Note: This is not being added to MiniDexed as a comment though as USB Gadget support should not be enabled without full understanding of the hardware implications around powering the RPi and so on. Consequently, this will all be explained on the wiki and considered an "advanced" feature of MiniDexed.

USB Gadget support in Circle is still a little experimental, but this has been initially tested and shown to work on the following:

It should work on a Pi A+ too, but I don't have one to test. I don't think there is a Pi V2 that supports USB Gadget mode.

If Gadget mode is enabled on a Pi that doesn't support it then MiniDexed will halt and there will be messages logged on the console explaining why. It would be possible to allow MiniDexed to start and run normally but with no USB support (we could just not return False after initialising USB in kernel.cpp), but it was felt that this would just hide the configuration problem and cause more user confusion than forcing a halt.

There is some discussion of the implications here: https://github.com/probonopd/MiniDexed/issues/547#issuecomment-1793866888

IMPORTANT: This requires an upgrade to the latest version of Circle and consequently circle-stdlib. But it also uses the first new commit to the development version of Circle after the release as that includes the check of USB Gadget functionality to Pi hardware, submod.sh has been updated accordingly.

Also note: USBID.sh contains the now officially allocated (by pid.codes) MiniDexed USB Vendor and Device IDs. These should only be changed if replaced by another officially allocated USB Vendor and Device ID. These should not just be "made up".

Kevin

BobanSpasic commented 10 months ago

Any chance to have two separate modes, selectable at booting over a switch or something? Namely, it would be interesting to have one mode where the MiniDexed is a SD Card reader, to expose the SD Card to the PC. It would be a blessing for people (like me) who needs to copy files to the card all the time.

diyelectromusic commented 10 months ago

I see no reason in the future why we couldn't explore USB mass storage support at some point... but we need to wait for it to appear in Circle first :)

Kevin

diyelectromusic commented 10 months ago

Instructions now added to the Wiki, see: https://github.com/probonopd/MiniDexed/wiki/Hardware#usb-gadget-mode

Kevin

probonopd commented 10 months ago

Thank you very much @diyelectromusic.

Build for testing: MiniDexed_2023-11-21-669a8ac

diyelectromusic commented 10 months ago

Build for testing

I've done some very basic testing on the following:

And USB functionality seems to be working as I'd expect it to.

Kevin

Banana71 commented 10 months ago

My Akai MPC One recognizes the miniDexed RPi 3A+ as MIDIGadget and they work great together. This function expands the area of application enormously and makes many things easier, thank you.

For your information: The entry USBGadget= is missing in the minidexed.ini and must be entered manually.

diyelectromusic commented 10 months ago

For your information: The entry USBGadget= is missing in the minidexed.ini and must be entered manually.

Yes. That is deliberate. I don't want people experimenting with enabling this without first understanding the issues around how to power the Pi and the importance of not trying to use a USB gadget link and separate power at the same time.

So for the hardware reasons (which are RPi reasons, not MiniDexed reasons), although this is a nicer option for many cases, I regard this as an advanced option and thus would like to reserve it for those who have found it explicitly, and therefore have had at least a reasonable chance of reading, the wiki.

Kevin

probonopd commented 10 months ago

Thank you very much @diyelectromusic!