Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add USB Gadget Device support #567

Merged
merged 2 commits into from
Nov 24, 2023

Conversation

diyelectromusic
Copy link
Collaborator

This fixes issue #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:

  • Raspberry Pi A (kernel.img)
  • Raspberry Pi 3A+ (kernel8.img)
  • Raspberry Pi 4B (kernel8-rpi4.img)
  • Raspberry Pi Zero (kernel.img)
  • Raspberry Pi Zero W (kernel.img)
  • Raspberry Pi Zero 2 (kernel8.img)

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: #547 (comment)

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
Copy link

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

Kevin

@probonopd
Copy link
Owner

probonopd commented Nov 23, 2023

Thank you very much @diyelectromusic.

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

@diyelectromusic
Copy link
Collaborator Author

Build for testing

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

  • Pi Zero (USB Gadget)
  • Pi 1 (USB Host)
  • Pi 3A+ (USB Gadget/USB Host)
  • Pi 3B (USB Host)
  • Pi 4 (USB Gadget/USB Host)

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

Kevin

@Banana71
Copy link

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
Copy link
Collaborator Author

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 probonopd merged commit 258a456 into probonopd:main Nov 24, 2023
1 check passed
@probonopd
Copy link
Owner

Thank you very much @diyelectromusic!

@diyelectromusic diyelectromusic deleted the USBGadgetDevice branch November 24, 2023 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants