This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3352 USB connect/disconnect as a device on Linux

Other Parts Discussed in Thread: AM3352

I 'm fairly new to Linux drivers, and have a similar question as in this post, but on an AM3352

I've got my board configured as a USB gadget serial device.

When I connect to a host, I can see the diagnostic message "g_serial gadget ..." on the console.

How do I capture this in some way so my application knows when the host is connected?

Likewise, how do I configure and capture the "host disconnected" status.

It should be possible via detecting the change in the DEVCTL_VBUS status, but I'm unsure of how to monitor that bit in user space.

Thanks,

  Peter Steinberg

  • Peter,

    What your user space application will do when received the host connect/disconnect events?

    I would think your application only needs to open and listen to port /dev/ttyGS0, the host will will send communication requests when connected, otherwise your application would be just sleeping.

  • We have an entire application running normally on the AM3352.

    When our device is connected to the host our application will make additional functions available to the user (such as having them give control to the host, and then take control back from the host, etc.).

    If there is no host connected then having those options displayed is confusing to the users.

  • You can use the otg state as follows.

    # node=$(basename /sys/devices/platform/ocp/47400000.usb/47401400.usb/musb-hdrc*)
    # cat /sys/bus/platform/devices/${node}/mode

    which should be b_ide when host is not connected, or b_peripheral when host is connected.

    The example above is for USB0 port. If you use USB1 port, please change 47401400.usb to 47401c00.usb in the first command.

  • That partially works.

    Power up the system, disconnected from the host:
    cat /sys/bus/platform/devices/47400000.usb/47401400.usb/musb-hdrc.0.auto/mode
    b_idle
    Connect to the host:
    cat /sys/bus/platform/devices/47400000.usb/47401400.usb/musb-hdrc.0.auto/mode
    b_peripheral
    Disconnect from the host:
    cat /sys/bus/platform/devices/47400000.usb/47401400.usb/musb-hdrc.0.auto/mode
    b_peripheral
  • Peter Steinberg said:
    Disconnect from the host:
    cat /sys/bus/platform/devices/47400000.usb/47401400.usb/musb-hdrc.0.auto/mode
    b_peripheral

    Something is wrong here. the mode should change back to b_idle after disconnect. Please open a new thread for this issue.