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

usb gadget on rpi A #1343

Closed
wants to merge 2 commits into from
Closed

usb gadget on rpi A #1343

wants to merge 2 commits into from

Conversation

prudy
Copy link
Contributor

@prudy prudy commented Mar 11, 2016

It is direct fix for issue 'usb gadget on rpi A #324'.

@pelwell
Copy link
Contributor

pelwell commented Mar 12, 2016

The overlay commit looks good to me, although the commit message could mention the overlay by name. @P33M Do you approve of the OTG change?

@P33M
Copy link
Contributor

P33M commented Mar 16, 2016

@prudy: Can you rebase the patch?

The OTG change looks ok, but this is an upstream driver. Are we happy to accept this out-of-tree?

@popcornmix
Copy link
Collaborator

We would prefer the dwc patch is submitted upstream and we can pick it once it is accepted.

@prudy
Copy link
Contributor Author

prudy commented Mar 16, 2016

It makes sense, but don't you feedback changes to the upstream?

@prudy
Copy link
Contributor Author

prudy commented Mar 16, 2016

let split dtb and dwc2 changes, so only dtb will apply locally as rpi specific.

@prudy prudy closed this Mar 16, 2016
@pelrun
Copy link

pelrun commented Mar 30, 2016

@prudy, is "dtoverlay=dwc2,dr_mode=peripheral" all I need to switch this on, or is something extra required? Haven't quite got this working on my A+ yet.

@prudy
Copy link
Contributor Author

prudy commented Mar 30, 2016

Two ways:

  • compile dwc2 in gadget-only mode and use 'dtoverlay=dwc2' or
  • compile dwc2 in dual-mode and use 'dtoverlay=dwc2,dr_mode=peripheral'

In any case this dtb patch is needed but also kernel patch to gadget. The latter is on its way in upstream or you can take it from my branch.

@pelrun
Copy link

pelrun commented Mar 30, 2016

I had already recompiled the dwc2 driver in dual mode (with all the patches, obviously since I'm posting on this pr), and the overlay is already in the rpi tree, and it's behaving as expected when I configure some libcomposite devices, but nothing happens when I connect to the pi with an a-a cable. Both ends act as if I'd not connected the cable at all.

@prudy
Copy link
Contributor Author

prudy commented Mar 30, 2016

If nothing happens it means the patches are not active. I'd check:

  • using ko modules (so not built-in) do not forget to modprobe the right module
  • the rpi firmware is fresh enough to handle DT
  • kernel is using DT, dtb are built and put onto sdcard overlay/
  • the config.txt is set to use DT (device_tree=bcm2708-rpi-b.dtb)
  • nothing else is using the USB
  • with the above in place, use 'dtdebug=1' in config, so you can use vcdbg to check if dr_mode is applied correctly
    (or even easier, compile dwc2 in gadget-only mode, so it is in the only right mode)

See this post with kernel configuration:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=129653

In the startup log you should see this:
"Configuration mismatch. dr_mode forced to"

and this:
[ 2.307172] g_serial gadget: Gadget Serial v2.4
[ 2.314621] g_serial gadget: g_serial ready
[ 2.324993] dwc2 20980000.usb: bound driver g_serial

eventually this when plugging in the cable:
[ 37.540037] dwc2 20980000.usb: new device is high-speed
[ 37.693650] dwc2 20980000.usb: new device is high-speed
[ 37.791228] dwc2 20980000.usb: new address 4

@pelrun
Copy link

pelrun commented Apr 1, 2016

As far as I can tell, everything is running as intended (no "mismatch" message because I have dr_mode set correctly in config.txt) and I've added debug messages to prove that the force dev bits are being preserved... but inserting the cable (I've tried both a home-soldered one and a purchased one) does nothing. At this point I think I'll probably wait until this makes it into the official Pi kernel before trying again.

@ED6E0F17
Copy link

ED6E0F17 commented Apr 4, 2016

Linux 4.5 has an extra patch that will check the hardware capabilities of the model "A", and block otg mode:

EDIT: Confirmed this patch is not a problem, and gadget mode is working on model A

@SloMusti
Copy link

Any idea how to most effectively enable OTG mode on A+ with latest linux and work around the OTG mode block?

@ED6E0F17
Copy link

As far as I know it should work with "dtoverlay=dwc2","dr_mode=peripheral" from linux 4.6 and above.

The patch I mentioned above may only check what the chip can do, not which cable is connected but I broke the sdcard slot on my Model A, so I replaced that with a Zero and cannot actually test what might happen on an A+.

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.

7 participants