0

I have an android device acting as the usb host to a raspberry pi zero which will behave as the a slave device. I have absolutely no problem using the android api for interacting with usb slave devices.

I apparently need a driver such as Gadget Serial Driver which i load at startup with the following command on the raspberry pi.

sudo modprobe g_serial

The system should apparently create the device node /dev/ttyGS0 for the driver, but that didn't happen. What could be the reason for this?

If the driver got loaded successfully how do I write a program using it and it's node? Is it even possible or do I need to write my own driver? Are there any alternative ways of going about this? I'm fairly new to linux so answers with terminal commands will be very helpful. Thanks in advance.

1
  • check out the adafruit tutorial on the subject.
    – meuh
    Mar 3, 2018 at 15:41

1 Answer 1

0

I can't tell you what went wrong on your Raspberry Pi (because I don't have one), but I can tell you how to test and work with the serial gadget driver. Try the following on your main PC first.

Load a virtual (simulated) host controller driver for USB gadgets:

sudo modprobe dummy_hcd

This will simultanously act as a framework for the gadget drivers and give you a new "normal" USB bus (check with lsusb) visible to the computer, and loopback between those.

Now load the serial gadget driver:

sudo modprobe g_serial

You should see a new device on the bus, and also /dev/ttyGS0 from the gadget driver. At the same time, the new device causes the kernel driver for serial clients to be loaded, so you will also get a /dev/ttyACM0 device.

You can just write and read from those devices, and see if they communicate. E.g. do cat /dev/ttyACM0 in one window, and echo foo > /dev/ttyGS0 in another.

I suspect that you'll have to put the Raspberry Pi into USB client mode, and load the correct HCD driver so the gadget drivers can attach, and if you haven't done this the gadget driver will just do nothing, as you've observed. But I don't know the right one to use for the Raspberry Pi.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .