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.

PROCESSOR-SDK-J721E: Using J7 EVM as a gadget

Part Number: PROCESSOR-SDK-J721E

Hi Experts,

I am trying to use the J7 EVM platform as a gadget serial hoping that the board would allow this on the USB Type-C connector (J5). I am using the prebuilt images.

root@j7-evm:~# modprobe g_serial
[   36.011536] udc-core: couldn't find an available UDC - added [g_serial] to list of pending drivers
root@j7-evm:~# 
root@j7-evm:~# zcat /proc/config.gz | grep DUAL                                                      
CONFIG_USB_MUSB_DUAL_ROLE=y
CONFIG_USB_DWC3_DUAL_ROLE=y
CONFIG_USB_ISP1760_DUAL_ROLE=y
root@j7-evm:~# 
root@j7-evm:~# zcat /proc/config.gz | grep GADGET
CONFIG_USB_CDNS3_GADGET=y
# CONFIG_USB_MUSB_GADGET is not set
# CONFIG_USB_DWC3_GADGET is not set
# CONFIG_USB_ISP1760_GADGET_ROLE is not set
CONFIG_USB_GADGET=m
# CONFIG_USB_GADGET_DEBUG is not set
# CONFIG_USB_GADGET_DEBUG_FILES is not set
# CONFIG_USB_GADGET_DEBUG_FS is not set
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=32
# CONFIG_USB_GADGET_XILINX is not set
# CONFIG_GADGET_UAC1 is not set
CONFIG_USB_GADGETFS=m
CONFIG_USB_MIDI_GADGET=m
root@j7-evm:~# 
root@j7-evm:~# cat /proc/device-tree/interconnect@100000/cdns_usb@4104000/usb@6000000/dr_mode 
otg

Any help would be appreciated.

  • Hi,

    Thanks for the query. Can we know why are you using the USB gadget serial option instead of the UART port available on the J7 EVM platform?

    Also, Check if CONFIG_USB_G_SERIAL is enabled.

    Thanks.

  • Hi,

    As the ticket title identifies we're trying to test USB gadget mode generally. Using gadget serial is the most straight forward way I believe. All the gadget configurations are enabled by default in the prebuilt image.

    root@j7-evm:~# zcat /proc/config.gz | grep CONFIG_USB_G_                                             
    CONFIG_USB_G_NCM=m
    CONFIG_USB_G_SERIAL=m
    CONFIG_USB_G_PRINTER=m
    CONFIG_USB_G_ACM_MS=m
    CONFIG_USB_G_MULTI=m
    CONFIG_USB_G_MULTI_RNDIS=y
    CONFIG_USB_G_MULTI_CDC=y
    CONFIG_USB_G_HID=m
    CONFIG_USB_G_DBGP=m
    # CONFIG_USB_G_DBGP_PRINTK is not set
    CONFIG_USB_G_DBGP_SERIAL=y
    CONFIG_USB_G_WEBCAM=m

    However, trying to probe any of the gadget drivers fails with the same error and no gadget device is created.

    root@j7-evm:~# modprobe g_serial
    [  324.481702] udc-core: couldn't find an available UDC - added [g_serial] to list of pending drivers
    root@j7-evm:~# ls /dev/ttyGS*
    ls: /dev/ttyGS*: No such file or directory
    root@j7-evm:~# 
    root@j7-evm:~# modprobe g_ether 
    [  357.529880] udc-core: couldn't find an available UDC - added [g_ether] to list of pending drivers
    root@j7-evm:~# 
    root@j7-evm:~# zcat /proc/config.gz | grep CONFIG_USB_GADGETFS
    CONFIG_USB_GADGETFS=m
    root@j7-evm:~# 
    root@j7-evm:~# dd bs=1M count=64 if=/dev/zero of=/tmp/backing_file                                   
    64+0 records in
    64+0 records out
    root@j7-evm:~# fdisk /tmp/backing_file 
    
    Welcome to fdisk (util-linux 2.32.1).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    Device does not contain a recognized partition table.
    Created a new DOS disklabel with disk identifier 0xa1ada1a3.
    
    Command (m for help): x
    
    Expert command (m for help): s
    Number of sectors (1-63, default 63): 8
    
    Expert command (m for help): h
    Number of heads (1-255, default 255): 16
    
    Expert command (m for help): c
    Number of cylinders (1-1048576, default 1024): 
    
    Expert command (m for help): r
    
    Command (m for help): n
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical partitions)
    Select (default p): 
    
    Using default response p.
    Partition number (1-4, default 1): 
    First sector (2048-131071, default 2048): 
    Last sector, +sectors or +size{K,M,G,T,P} (2048-131071, default 131071): 
    
    Created a new partition 1 of type 'Linux' and of size 63 MiB.
    
    Command (m for help): w
    The partition table has been altered.
    Syncing disks.
    
    root@j7-evm:~# modprobe g_mass_storage file=/tmp/backing_file
    [ 1065.221255] udc-core: couldn't find an available UDC - added [g_mass_storage] to list of pending drivers

    As written in the original post, the dr_mode for the usb device is already in "otg" mode.

  • Hi,

    Understood that you trying to test the USB gadget mode.

    First thing, make sure that you have the following:

    - For the USB0 to work in "otg" mode, the Type-C config DIP switch (SW3) must be set for DRP (Dual-role-Port) operation. SW3.3 = OFF, SW3.4 = ON.

    - Now depending on what type of Type-C cable is connected, the role switch will happen.

    cat /sys/class/usb_role/6000000.usb-role-switch/role

    When no USB cable is connected to the type-C port, the command below will output as "none"

    When USB Type-C-to-A Adapter cable is connected, the software will switch to XHCI host mode. The output of the above command will be "host". Now you can try to connect a USB device to the adapter and it will be enumerated.

    When you connect the  USB-C Male to Type A USB-A Male cable between the Type-C port on the J7EVM and the host PC, the software will switch to "device" mode. The output of the above command will be "device". At this point in time, you can try calling "modprobe g_serial". This must load the Serial gadget 

    Thanks.

  • Thanks for the help Praveen, this worked!

  • Thanks for confirming that it works now. Closing the thread.