treefella
Posts: 17
Joined: Thu Mar 24, 2016 11:59 pm

USB Gadget Mode on Compute Module

Tue Apr 05, 2016 12:03 am

Hey all!

Is it possible to use the otg port on the compute module dev board for USB gadget mode?

I am using the midi gadget & I have gotten gadget mode to work on the zero sending signals back and forth.

The CM's OS opens the port internally and seems to be set up exactly like the zero but it is not seen by my desktop host device.

What am I missing?

Cheers,
Ron Sardarian
instagram.com/teafela/
teafella.com

rotwang
Posts: 243
Joined: Sat Dec 07, 2013 1:12 pm

Re: USB Gadget Mode on Compute Module

Tue Apr 05, 2016 10:47 am

I'm going to have to investigate this over the next few months, (working well on Pi Zero, just not enough gpio pins). Which USB connector are you using? I THINK you need to use the micro-usb ("usb slave") connector, which I think switches the usb multiplexer chip and puts the processor interface into slave mode. Be warned, this is a wild-ass guess based on the way I think rpiboot works. Maybe someone with access to the compute module schematics can confirm or deny?
I'll follow this topic in case anyone can make further progress.
Roger
treefella wrote:Hey all!

Is it possible to use the otg port on the compute module dev board for USB gadget mode?

I am using the midi gadget & I have gotten gadget mode to work on the zero sending signals back and forth.

The CM's OS opens the port internally and seems to be set up exactly like the zero but it is not seen by my desktop host device.

What am I missing?

Cheers,

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7303
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: USB Gadget Mode on Compute Module

Tue Apr 05, 2016 11:01 am

rotwang wrote:I'm going to have to investigate this over the next few months, (working well on Pi Zero, just not enough gpio pins). Which USB connector are you using? I THINK you need to use the micro-usb ("usb slave") connector, which I think switches the usb multiplexer chip and puts the processor interface into slave mode. Be warned, this is a wild-ass guess based on the way I think rpiboot works. Maybe someone with access to the compute module schematics can confirm or deny?
I'll follow this topic in case anyone can make further progress.
Roger
You mean the schematics that are on the Documentation pages? https://www.raspberrypi.org/documentati ... ematics.md

Looking at the CMIO schematics, something connected to the micro USB slave port will switch the mux. Whilst the comments on the schematic make reference to boot differences based on whether something is connected there or not, I can't see an obvious reason for it.
That is connected directly to the SoC USB controller in the same way as Model A or Zero, so all the gadget mode stuff should then just work.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
adun
Posts: 102
Joined: Fri Mar 20, 2015 9:25 am
Location: Switzerland

Re: USB Gadget Mode on Compute Module

Tue Apr 05, 2016 11:15 am

On Pi Zero the USB OTG pin is connected to the micro USB port.
On CM the OTG pin is accessible on the GPIO bank where it can be tied to ground.
Usually if a external USB device pulls this signal to GND, then the OTG controller will switch to Host mode. If this signal is floating when the external USB device is plugged in, then the OTG controller will switch to Device (slave) mode.
So if you let the OTG pin floating the CM should behave like a Pi Zero in slave mode.

rotwang
Posts: 243
Joined: Sat Dec 07, 2013 1:12 pm

Re: USB Gadget Mode on Compute Module

Tue Apr 05, 2016 1:11 pm

Found the schematic, and using extreme zoom I think I can see what you mean. It's confusing having the mux on one set of schematics, and the cm on a second set, so I think it's going to mean an A3 printer and some literal cut and paste.

There seem to be two problems, first the OTG pin on the CMIO connector appears to be floating, does this have an internal pull-up/pulldown. Second, the ID pin on the usb slave connector is not connected. While linking the two should theoretically be possible, it would require the ability to solder to a gnat's eyelash, especially on the DIMM connector.

So just how does rpiboot do its thing, given that it can't be by using the OTG line to the SoC. So just how does one get the compute module into slave mode? I'd like to get to the bottom of this one, since gadget mode on the Zero is working so well.
It looks as though one SHOULD be able to leave a hub etc. connected to the USB host port, and switch into gadget mode simply by connecting a micro USB to the slave port, but it can't be that simple, or can it?

6by9 wrote:
rotwang wrote:I'm going to have to investigate this over the next few months, (working well on Pi Zero, just not enough gpio pins). Which USB connector are you using? I THINK you need to use the micro-usb ("usb slave") connector, which I think switches the usb multiplexer chip and puts the processor interface into slave mode. Be warned, this is a wild-ass guess based on the way I think rpiboot works. Maybe someone with access to the compute module schematics can confirm or deny?
I'll follow this topic in case anyone can make further progress.
Roger
You mean the schematics that are on the Documentation pages? https://www.raspberrypi.org/documentati ... ematics.md

Looking at the CMIO schematics, something connected to the micro USB slave port will switch the mux. Whilst the comments on the schematic make reference to boot differences based on whether something is connected there or not, I can't see an obvious reason for it.
That is connected directly to the SoC USB controller in the same way as Model A or Zero, so all the gadget mode stuff should then just work.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7303
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: USB Gadget Mode on Compute Module

Tue Apr 05, 2016 1:32 pm

rotwang wrote:Found the schematic, and using extreme zoom I think I can see what you mean. It's confusing having the mux on one set of schematics, and the cm on a second set, so I think it's going to mean an A3 printer and some literal cut and paste.

There seem to be two problems, first the OTG pin on the CMIO connector appears to be floating, does this have an internal pull-up/pulldown. Second, the ID pin on the usb slave connector is not connected. While linking the two should theoretically be possible, it would require the ability to solder to a gnat's eyelash, especially on the DIMM connector.

So just how does rpiboot do its thing, given that it can't be by using the OTG line to the SoC. So just how does one get the compute module into slave mode? I'd like to get to the bottom of this one, since gadget mode on the Zero is working so well.
It looks as though one SHOULD be able to leave a hub etc. connected to the USB host port, and switch into gadget mode simply by connecting a micro USB to the slave port, but it can't be that simple, or can it?
Technically an OTG port should be using a type AB connector, and that requires correct behaviour of the ID line. The CMIO has only a type B, and it doesn't have the correct linking back to the USB controller for auto switching. In that regard it's the same as the Model A where the type A connector could be (ab)used as an OTG port.
There's a fair amount of discussion on https://github.com/raspberrypi/linux/pull/1239 about dtb changes required for a Model A/A+ to get around the lack of an ID line, all of that would be relevant to the CM as well.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: USB Gadget Mode on Compute Module

Tue Apr 05, 2016 2:43 pm

The CMIO has both ports, with the D+D- lines switched over to the micro if a cable carrying power is plugged in there. The micro port is used for flashing, and it's intended to be client only, in that it can't supply power.

But like on the A(+), the OTG_Sense is hard-wired to ground for host mode. Remove R12 & gadget mode should be fine at the micro USB socket. Alternatively, leave the resister in place & use the patched dwc2 driver provided here.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7303
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: USB Gadget Mode on Compute Module

Tue Apr 05, 2016 3:01 pm

gregeric wrote:The CMIO has both ports, with the D+D- lines switched over to the micro if a cable carrying power is plugged in there. The micro port is used for flashing, and it's intended to be client only, in that it can't supply power.

But like on the A(+), the OTG_Sense is hard-wired to ground for host mode. Remove R12 & gadget mode should be fine at the micro USB socket. Alternatively, leave the resister in place & use the patched dwc2 driver provided here.
As USB_OTGID is on J6 pin55, then you could jumper it on there instead of having to remove R12. Pass as to what voltage it wants to be pulled to.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

treefella
Posts: 17
Joined: Thu Mar 24, 2016 11:59 pm

Re: USB Gadget Mode on Compute Module

Thu Apr 21, 2016 12:11 am

I have unsoldered R12 and now I can ground OTGID whenever I don't need gadget mode.

Thanks for your help! :D
Ron Sardarian
instagram.com/teafela/
teafella.com

User avatar
E3V3A
Posts: 26
Joined: Sun Apr 17, 2016 7:13 am
Location: -∇φ

Re: USB Gadget Mode on Compute Module

Tue Sep 13, 2016 10:06 am

Would it be possible to make a similar hack on the RP3B as you guys did on the CM?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7303
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: USB Gadget Mode on Compute Module

Tue Sep 13, 2016 10:29 am

E3V3A wrote:Would it be possible to make a similar hack on the RP3B as you guys did on the CM?
No.
There is only one USB peripheral on the BCM283x SoC. On the CM, A, and Zero that is exposed directly to the outside world, so these tricks can be played. On any B, B+, 2B, or 3B there is an SMSC951x chip connected to it to act as a USB hub and network interface. You therefore can't switch the function of the port.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
E3V3A
Posts: 26
Joined: Sun Apr 17, 2016 7:13 am
Location: -∇φ

Re: USB Gadget Mode on Compute Module

Wed Sep 14, 2016 3:32 pm

6by9 wrote:No. There is only one USB peripheral on the BCM283x SoC. On the CM, A, and Zero that is exposed directly to the outside world, so these tricks can be played. On any B, B+, 2B, or 3B there is an SMSC951x chip connected to it to act as a USB hub and network interface. You therefore can't switch the function of the port.
Sorry, I know this is OT for this thread, but it really does look from the Schematics as I show in this post, that there is a direct USB connection of processor to one of the USB ports. Although there is some uncertainty what the 0 Ohm R28/29 are doing, if even present. This would allow circumventing the HUB/LAN endpoints and provide USB OTG on that one port. Now, since we don't have the exact schematics of the RP3 we'd have to do some more research which port this is and how to shutdown or cutout the HUB chip.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7303
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: USB Gadget Mode on Compute Module

Wed Sep 14, 2016 3:43 pm

E3V3A wrote:Sorry, I know this is OT for this thread, but it really does look from the Schematics as I show in this post, that there is a direct USB connection of processor to one of the USB ports. Although there is some uncertainty what the 0 Ohm R28/29 are doing, if even present. This would allow circumventing the HUB/LAN endpoints and provide USB OTG on that one port. Now, since we don't have the exact schematics of the RP3 we'd have to do some more research which port this is and how to shutdown or cutout the HUB chip.
R28 and R29 have a "(A)" after them. IC3 (the SMSC9512) has a "(B)". The schematics cover both the Model A and the Model B as on the original A and B they shared a common PCB (I don't believe the A+ and B+ do).
If you desolder IC3 and add R28 & R29, then you can do gadget mode, but you might as well buy a Model A in the first place.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

treefella
Posts: 17
Joined: Thu Mar 24, 2016 11:59 pm

Re: USB Gadget Mode on Compute Module

Sat Oct 05, 2019 4:20 am

Hello again!

I am playing with the Compute Module 3+ and I am having trouble getting an OTG host connection with g_ether and the official Dev board.

I have tried forcing slave mode with dr_mode=peripheral in config.txt as suggested in other threads but this does not seem to work.

ssh is working fine via wifi or ethernet dongle. Pi is connected with a tested micro usb cable that works for ssh via otg with my pi zero with the same OS image.

Any ideas on what might be going wrong?
Ron Sardarian
instagram.com/teafela/
teafella.com

Return to “Compute Module”