Hardware switchable USB Gadget Mode - possible? #669
Replies: 4 comments 19 replies
-
Hi Enzo, welcome! USB Gadget mode was contributed by @diyelectromusic in As far as I understand it, what you would like is to replace Line 39 in 258a456 by something that reads the value of a GPIO pin (low or high), instead of reading the value from the Something along the lines of
|
Beta Was this translation helpful? Give feedback.
-
That might do it. If it was me, I'd probably leave the config option as it is and include a means to read the GPIO on startup and then decide between the two options - GPIO or config - which "wins". My nervousness is that USBGadget mode has power requirements that really need to be thought about carefully and I a little nervous about the idea that it could be set accidentally when the Pi is powered the wrong way (see the wiki). Also, I'd need to check when the GPIO is initialised in kernel.cpp - obviously it would have to be before we're checking for USB Gadget mode if we went down this route. Update: that's ok - GPIOManager is initialised first. Kevin |
Beta Was this translation helpful? Give feedback.
-
Hi All, I understand the cons of having this option available. But couldn't we have a USBGadgetPin=0 or 1 option instead (as probonopd suggests in one of his replies above) with another option to then nominate the GPIO number (default 26). This would make this option no more dangerous than the USBGadget option in my view. Someone has to conciously make this change in the ini file, so user beware. Also, what happens with a default minidexed (USBGadget=0) when someone plugs in the power USB, and then inadvertantly plugs the other USB of the RPi into a powered computer instead of a passive controller? Does this fry the RPi as well? Is this power issue always there anyway? Enzo |
Beta Was this translation helpful? Give feedback.
-
Ok. So, this wasn't deliberate, but I've just updated the firmware to investigate an issue I'm having with Circuitpython and MiniDexed (that I've asked Rene about) and now have nothing working at all USB wise on my Pi 4... Then I glance at the screen and see "USB Gadget Mode: Enabled" and I'm like WTF? Really? Sigh, edit minidexed.ini - nothing there... Then I realise... My Pi 4 MiniDexed PCB uses GPIO 26 for the encoder... The code currently in our main tree defaults to looking at pin 26 if there is no USBGadgetPin present in minidexed.ini and regardless of the setting of USBGadget. The upshot is that any legacy installation that uses GPIO 26 for anything now might try to enable USB Gadget mode by mistake. As I have just done. And if USBGadget Mode isn't supported on that Pi, will end up disabling USB. And not realise. Thankfully it clicked for me what was going on. So this is proof to me that this change has to be reverted I'm afraid and done properly with more safeguards and checks. Sigh... Caught out by my own hypotheticals... that's a new one for me! Update: I'll start the update from the current main tree (so don't change anything else or my branch will be instantly out of date!) and take a look now :) Kevin |
Beta Was this translation helpful? Give feedback.
-
Hi All,
Thanks for this great project.
Just a query whether it would be possible to have USB Gadget mode switchable via a hardware switch and a spare GPIO input? I am new to RPi, and not sure how hard this would be to implement - I suspect some new coding would be required.
I would like to use my midi controller and minidexed in a standalone configuration sometimes, as well as sometimes connecting it to my computer and controlling it from my DAW, without having to reload the minidexed.ini with the USB Gadget mode switched on or off.
Thanks,
Enzo
Beta Was this translation helpful? Give feedback.
All reactions