AM62P: USB D+ pull-up

Part Number: AM62P

Hi,

I've implemented a usb node as shown bellow

&usb0 {
	dr_mode = "otg";
	usb-role-switch;
	#address-cells = <0x01>;
	#size-cells = <0x00>;

	port@0 {
		reg = <0x00>;

		usb0_ep: endpoint {
			remote-endpoint = <&usb_dr_connector>;
		};
	};

	connector {
		compatible = "gpio-usb-b-connector", "usb-b-connector";
		pinctrl-names = "default";
		pinctrl-0 = <&main_usb0_id_pins_default>, <&pinctrl_usb0_en>;
		id-gpios = <&main_gpio0 40 GPIO_ACTIVE_HIGH>;
		label = "USB_0";
		self-powered;

		port {
			usb_dr_connector: endpoint {
				remote-endpoint = <&usb0_ep>;
			};
		};
	};

};

And when I change usb role

root@am62p-lohr:/sys/kernel/config/usb_gadget/g1# gpioset -c gpiochip1 39=0
^C
root@am62p-lohr:/sys/kernel/config/usb_gadget/g1# cat /sys/kernel/debug/usb/31000000.usb/mode
device
root@am62p-lohr:/sys/kernel/config/usb_gadget/g1# gpioset -c gpiochip1 39=1
^C
root@am62p-lohr:/sys/kernel/config/usb_gadget/g1# cat /sys/kernel/debug/usb/31000000.usb/mode
host

Even with the phone connected, the pull-up doesn't appear on my D+ pin.

Is there any configuration needed to make it work?
I'm using kernel 6.6.

Att.

  • Hi Sergio,

    root@am62p-lohr:/sys/kernel/config/usb_gadget/g1# gpioset -c gpiochip1 39=0
    ^C
    root@am62p-lohr:/sys/kernel/config/usb_gadget/g1# cat /sys/kernel/debug/usb/31000000.usb/mode
    device
    root@am62p-lohr:/sys/kernel/config/usb_gadget/g1# gpioset -c gpiochip1 39=1
    ^C
    root@am62p-lohr:/sys/kernel/config/usb_gadget/g1# cat /sys/kernel/debug/usb/31000000.usb/mode
    host

    At which step of this command sequence did you measure the D+ pin? How is the AM62P VBUS pin state when you probe D+?

  • Hi Bin Liu,

    I left the multimeter connected during all steps. When the mode was device, the D+ pin measured 0.094V, and when the mode was host, the D+ pin measured 0.027V.

    Regarding the VBUS issue, in host mode the pin is at 5V, and when in device mode the pin is at 0V.

  • Hi Sergio,

    Please note that only the USB device pulls up D+ during the initial stage of the USB enumeration, not the USB host.

    For AM62P USB to work in device mode, its VBUS pin has to be at 5V (typically coming from the USB host).

    You also need to ensure the Linux USB gadget driver is already loaded.

    During USB enumeration, the D+ will be pulled up for very short period of time by the USB device controller. I don't think probing it using a multimeter is a good idea, you'd better to check it with a scope.

  • Hi Bin Liu,
    How can I check the Linux USB gadget driver issue? 
    I've checked dmesg and found this entries.

    root@am62p-lohr:/storage# dmesg | grep -i gadget
    [   28.479125] configfs-gadget.g1 gadget.0: HOST MAC **:**:**:**:**:**
    [   28.479151] configfs-gadget.g1 gadget.0: MAC **:**:**:**:**:**

    I'll also check the D+ signals using an oscilloscope.

    BR,

  • Hi Sergio,

    Your dmesg log seems showing the gadget driver is loaded. A better way is using command "cat /sys/class/udc/31000000.usb/uevent" to check "USB_UDC_DRIVER" information. For example:

    root@am62xx-evm:~# cat /sys/class/udc/31000000.usb/uevent
    USB_UDC_NAME=dwc3-gadget

    root@am62xx-evm:~# modprobe g_serial
    [881604.235238] g_serial gadget.0: Gadget Serial v2.4
    [881604.245527] g_serial gadget.0: g_serial ready

    root@am62xx-evm:~# cat /sys/class/udc/31000000.usb/uevent
    USB_UDC_NAME=dwc3-gadget
    USB_UDC_DRIVER=g_serial

  • Hi Bin Liu,

    I've measured with an oscilloscope  and got this result when changed to host.


    root@am62p-lohr:/storage# cat /sys/class/udc/31000000.usb/uevent
    USB_UDC_NAME=dwc3-gadget
    USB_UDC_DRIVER=g1


    root@am62p-lohr:~# modprobe g_serial
    [ 7817.430226] UDC core: g_serial: couldn't find an available UDC

    Att.

  • Hi Sergio,

    root@am62p-lohr:/storage# cat /sys/class/udc/31000000.usb/uevent
    USB_UDC_NAME=dwc3-gadget
    USB_UDC_DRIVER=g1

    You already have a gadget "g1" loaded, so

    root@am62p-lohr:~# modprobe g_serial
    [ 7817.430226] UDC core: g_serial: couldn't find an available UDC

    you don't need to load g_serial. I used it as an example for you to show how to check if a gadget driver is loaded or not.

    and got this result when changed to host.

    I am a bit of confused. What is your USB use case?

  • Hi Bin Liu,

    I am a bit of confused. What is your USB use case?


    We are developing a system that operates with Apple CarPlay.
    In the tests conducted so far, we have managed to initiate communication with the device. However, when it requests a role switch, the VBUS on our system drops to zero and our mode switches to "device," yet we do not see a pulse on our D+ line, and the communication is aborted.

  • Hi Sergio,

    I don't know much about the Apple Carplay protocol. But I guess initially AM62P USB is the host and the iPhone is the USB device, when role switches, AM62P USB becomes device and the iPhone switch to host. Right?

    If so, does to the Carplay protocol define who provides VBUS power during role switching, the USB device (AM26P in this case) or the USB host (the iPhone in this case)?