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.

AM335x USB Device Detection

Hi,

we are configuring AM335x USB0 as device(not HOST). We are using DP, DM and GND.. The Device is self powered. But DP and DM are not externally pulled up.. When we connect this to HOST machine (Both Windows and Linux) nothing gets detected . Please let us know the possible reason for the same. Below is our DTS configuration .. Also we found that for Device side there is no PIN-MUX . Correct us if we are wrong. 

Please suggest us: we need to add device descriptors values for vendor specific -class- we have to use for SERIAL(CDC_ACM) only.

Q1: in which file we have to add these vendor specific class device descriptors.

http://processors.wiki.ti.com/index.php/Linux_Core_DWC3_User%27s_Guide#Driver_Configuration 

dts file config for USB:

&usb {
status = "okay";

control@44e10620 {
status = "okay";
};

usb-phy@47401300 {
status = "okay";
};

usb@47401000 {
status = "okay";
dr_mode = "peripheral";      // we added line to make it as device in a ti-wiki-link above 
};

dma-controller@47402000 {
status = "okay";
};

usb-phy@47401b00 {       // we are not using USB-1 -- it is default config -- we not changed any thing
status = "okay";
};
usb@47401800 {
status = "okay";
dr_mode = "host";
};
};

regards,

Viswanath K

  • You don't have to change anything in the AMSDK kernel, by default the usb0 port will work in device mode.

    After connected your board to a host USB port, please run the two diagnostic scripts attached below on your board, and provide the output logs.

    #!/bin/sh
    #
    # Util to check USB subsystem on for Linux kernel 3.12+
    #
    # TODO: usage
    
    VERSION=0.2.0
    
    
    ### functions ###
    
    has_supported_kernel() {
    	local _ver
    	local _t
    
    	_ver=`uname -r`
        DBG_PRINT "kernel $_ver"
        _t=${_ver%%.*}
        # 2.x.x, unsupported
        [ $_t -ge 3 ] || return 1
        # 4.x.x, supported
        [ $_t -lt 4 ] || return 0
    
        _ver=${_ver#*.}
        _t=${_ver%%.*}
        # < 3.12.x, unsupported
        [ $_t -ge 12 ] || return 1
        return 0
    }
    
    check_platform () {
    	local _hw
    
    	_hw=`grep '^Hardware' /proc/cpuinfo`
    	DBG_PRINT $_hw
    
        [ "${_hw#*AM33XX}" = "$_hw" ] || {
            PLATFORM="am335x"
            USB0='usb@47400000/usb@47401000'
            USB1='usb@47400000/usb@47401800'
            return 0; 
        }
    
        [ "${_hw#*AM43}" = "$_hw" ] || {
            PLATFORM="am437x"
            USB0='omap_dwc3@48380000/usb@48390000'
            USB1='omap_dwc3@483c0000/usb@483d0000'
            return 0
        }
    
        [ "${_hw#*DRA74X}" = "$_hw" ] || {
            PLATFORM="am57x"
            USB0='omap_dwc3_1@48880000/usb@48890000'
            USB1='omap_dwc3_2@488c0000/usb@488d0000'
            return 0
        }
    
        echo "Unsupported $_hw"
        return 1
    }
    
    # check a kernel CONFIG option
    # params $1 - the config option
    #        $2 = '-q', quiet output
    # return 0 - undefined
    #        1 - defined as 'm', kernel module
    #        2 - defined as 'y', kernel builtin
    check_kernel_config() {
        local _cfg
    
        [ -n "$1" ] || return 0
        _cfg=`zcat /proc/config.gz | grep "^$1\>"`
    
        case ${_cfg#*=} in
            "y") return 2;;
            "m") return 1;;
              *) [ "$2" = "-q" ] ||
                  echo "Error: $1 is undefined in kernel config"
              return 0;;
        esac
    }
    
    # check a kernel module
    # $1 - module name, relative path from drivers/, with .ko surfix
    # return 0 - found
    #        1 - error
    check_module() {
        local _modname
        local _moddep
    
        [ -n "$1" ] || return 1
    
        _modname="/lib/modules/`uname -r`/kernel/drivers/${1}.ko"
        _moddep="/lib/modules/`uname -r`/modules.dep"
    
        DBG_PRINT 1
        [ -f $_modname ] || {
            echo "Error: $_modname not found."
            echo "       Please ensure 'make module_install' is done properly."
            return 1
        }
    
        DBG_PRINT 2
        [ -f $_moddep ] || $moddep_checked || {
            echo "Error: $_moddep not found."
            echo "       Please ensure 'make module_install' is done properly."
            moddep_checked=true
        }
    
        DBG_PRINT 3
        lsmod | grep `basename $1 | tr '-' '_'` > /dev/null || {
            DBG_PRINT ">>>> ${1}.ko:"
            if grep "${1}.ko:" $_moddep > /dev/null; then
                DBG_PRINT 5
                echo "Error: $_moddep seems to be valid,"
                echo "       but `basename $1`.ko is not loaded."
                echo "       Please provide /proc/config.gz and /lib/module/`uname -r`/*"
                echo "       for further investigation."
            else
                DBG_PRINT 6
                echo "Error: `basename $1`: $_moddep is invalid."
                echo "       Please run command 'depmod' on the target to re-generate it,"
                echo "       then reboot the target. If the issue still exists, please"
                echo "       ensure 'make module_install' is done properly."
            fi
    
            DBG_PRINT 7
            return 1
        }
        DBG_PRINT 8
        return 0
    }
    
    check_musb_drivers() {
        check_kernel_config CONFIG_USB_MUSB_HDRC
        [ $? != 1 ] || check_module 'usb/musb/musb_hdrc'
    
        check_kernel_config CONFIG_USB_MUSB_DUAL_ROLE -q
        [ $? != 0 ] || echo "Warning: CONFIG_USB_MUSB_DUAL_ROLE undefined."
    
        check_kernel_config CONFIG_USB_MUSB_DSPS
        [ $? != 1 ] || {
            check_module 'usb/musb/musb_dsps'
            check_module 'usb/musb/musb_am335x'
        }
    
        check_kernel_config CONFIG_AM335X_PHY_USB
        [ $? != 1 ] || {
            check_module 'usb/phy/phy-am335x'
            check_module 'usb/phy/phy-am335x-control'
        }
    
        check_kernel_config CONFIG_MUSB_PIO_ONLY -q
        [ $? != 0 ] || {
           if check_kernel_config CONFIG_TI_CPPI41 -q; then
               echo "Error: MUSB CPPI DMA mode is enabled, but CPPI moudle is not enabled in DMA Engine."
               echo "       Please enable CONFIG_TI_CPPI41 under DMA Engine Support in kernel config."
           fi
        }
    }
    
    check_dwc3_drivers() {
        check_kernel_config CONFIG_USB_DWC3
        [ $? != 1 ] || check_module 'usb/dwc3/dwc3'
    
        check_kernel_config CONFIG_USB_DWC3_DUAL_ROLE -q
        [ $? != 0 ] || echo "Warning: CONFIG_USB_DWC3_DUAL_ROLE undefined."
    
        check_kernel_config CONFIG_USB_DWC3_OMAP
        [ $? != 1 ] || check_module 'usb/dwc3/dwc3-omap'
    
        check_kernel_config CONFIG_USB_XHCI_HCD
        [ $? != 1 ] || {
            check_module 'usb/host/xhci-plat-hcd'
            check_module 'usb/host/xhci-hcd'
        }
    
        check_kernel_config CONFIG_OMAP_CONTROL_PHY
        [ $? != 1 ] || check_module 'phy/phy-omap-control'
    
        if [ $PLATFORM = am437x ]; then
            check_kernel_config CONFIG_OMAP_USB2
            [ $? != 1 ] || check_module 'phy/phy-omap-usb2'
        else
            check_kernel_config CONFIG_TI_PIPE3
            [ $? != 1 ] || check_module 'phy/phy-ti-pipe3'
        fi
    }
    
    ### debug ###
    
    g_log_file=/tmp/chmusb.log
    
    DBG_ENABLE() { g_dbg_enabled=true; }
    DBG_DISABLE() { g_dbg_enabled=false; }
    DBG_LOG_RESET() { ! $g_dbg_enabled || echo > $g_log_file; }
    DBG_PRINT() { ! $g_dbg_enabled || echo "$(date +%H:%M:%S) [$(basename $0)]: $*"; }
    DBG_LOG() { DBG_PRINT $* >> $g_log_file; }
    DBG_LOG_MARK() { DBG_PRINT "----------------" >> $g_log_file; }
    
    
    ### main ####
    
    moddep_checked=false
    
    echo "chkusb.sh Version $VERSION"
    
    [ "$V" = "1" ] && DBG_ENABLE && DBG_LOG_RESET || DBG_DISABLE
    
    has_supported_kernel ||
        { echo "Unsupported kernel version: `uname -r`"; exit 1; }
    check_platform || exit 2
    DBG_PRINT device: $PLATFORM
    
    which lsusb > /dev/null ||
        { echo "Error; lsusb command not found"; exit 3; }
    
    if lsusb > /dev/null 2>&1; then
        echo "USB is initialized"
    else
        echo "USB initialization failed"
    
        # failed, continue checking
        [ -f /proc/config.gz ] ||
            { echo "Error: /proc/config.gz not found"; exit 4; }
    
        case $PLATFORM in
            am335x) check_musb_drivers;;
            am437x | am57x) check_dwc3_drivers;;
            *)
                echo "Error: unsupported platform $PLATFORM"
                exit 5;;
        esac
    fi
    
    # check dr_mode & gadget drivers
    
    [ -d /proc/device-tree ] || {
        echo "Warning: /proc/device-tree/ not found"
        if [ -d "/lib/modules/`uname -r`/" ]; then
            echo "The list of USB gadget drivers installed:"
            ls -1Rp "/lib/modules/`uname -r`/kernel/drivers/usb/gadget/"
        fi
        exit 0
    }
    
    for _usb in "${USB0}" "${USB1}"; do
        _usb_dir="/proc/device-tree/ocp/${_usb}"
        _status=`cat $_usb_dir/status 2> /dev/null`
        _dr_mode=`cat $_usb_dir/dr_mode`
        echo `basename $_usb`: $_dr_mode, $_status
    
        [ "$_status" = "disabled" -o "$_dr_mode" = "host" ] || gadget_mode=true
    done
    
    DBG_PRINT $gadget_mode
    $gadget_mode || exit 0
    
    echo
    
    check_kernel_config CONFIG_USB_LIBCOMPOSITE
    case $? in
        0) echo "Error: no any gadget driver enabled"
           exit 6;;
        1) is_gadget_builtin=false;;
        2) echo "The gadget driver is built-in"
           is_gadget_builtin=true;;
    esac
    
    check_kernel_config CONFIG_USB_ZERO -q ||
        echo "Gadget Kernel Config: g_zero is enabled"
    check_kernel_config CONFIG_USB_AUDIO -q ||
        echo "Gadget Kernel Config: g_audio is enabled"
    check_kernel_config CONFIG_USB_ETH -q ||
        echo "Gadget Kernel Config: g_ether is enabled"
    check_kernel_config CONFIG_USB_G_NCM -q ||
        echo "Gadget Kernel Config: g_ncm is enabled"
    check_kernel_config CONFIG_USB_MASS_STORAGE -q ||
        echo "Gadget Kernel Config: g_mass_storage is enabled"
    check_kernel_config CONFIG_USB_G_SERIAL -q ||
        echo "Gadget Kernel Config: g_serial is enabled"
    check_kernel_config CONFIG_USB_G_PRINTER -q ||
        echo "Gadget Kernel Config: g_printer is enabled"
    
    g_driver=`grep '^DRIVER=' /sys/class/udc/*/uevent 2>/dev/null`
    echo "gadget driver loaded: ${g_driver:-(none)}"
    
    echo
    
    if ! $is_gadget_builtin; then
        if [ -d "/lib/modules/`uname -r`/" ]; then
            echo "The list of USB gadget drivers installed:"
            ls -1Rp "/lib/modules/`uname -r`/kernel/drivers/usb/gadget/"
        else
            echo "Error: /lib/modules/`uname -r`/ not found"
            echo "       Please ensure 'make module_install' is done properly."
            exit 7
        fi
    fi
    
    # vim: ft=sh:ts=4:sw=4:et
    

    #!/bin/sh
    # dump some usb registers
    # usbreg.sh <bus-number>
    
    check_platform() {
    	local _hw
    
    	_hw=`grep '^Hardware' /proc/cpuinfo`
    
    	[ "${_hw#*AM33XX}" = "$_hw" ] || { PLATFORM="am335x"; return 0; }
    	[ "${_hw#*AM43}" = "$_hw" ] || { PLATFORM="am437x"; return 0; }
    	[ "${_hw#*DRA74X}" = "$_hw" ] || { PLATFORM="am57x"; return 0; }
    	PLATFORM="unkown"
    	return 1
    }
    
    [ "$1" = "" ] && {
    	echo '    bus #0:'
    	$0 0
    	echo '    bus #1:'
    	$0 1
    	exit 0
    }
    
    bus=$1
    
    [ "$bus" = "0" ] || [ "$bus" = "1" ] ||
    	{ echo "Error: unknown bus number"; exit 1; }
    
    check_platform
    
    case $PLATFORM in
    	am335x) bus_ent=musb-hdrc.${bus}.auto ;;
    	am437x) bus_ent=`printf "%x" $((0x48390000+${bus}*0x40000))`.usb ;;
    	am57x) bus_ent=`printf "%x" $((0x48890000+${bus}*0x40000))`.usb ;;
    	*)
    		echo "Error: unknown platform"
    		exit 2 ;;
    esac
    
    entry=/sys/kernel/debug/${bus_ent}/regdump
    
    [ -f $entry ] || { echo "$entry not found"; exit 3; }
    
    case $PLATFORM in
    	am335x)
    		grep 'Power\|DevCtl' $entry ;;
    	*)
    		grep GCTL $entry
    		grep DCTL $entry
    		grep 'OCFG\|OCTL\|OSTS' $entry
    		;;
    esac
    

  • Thank you Bin Liu and Biser for the support , i will test and will come back.
  • Hi Bin Liu,
    This is the log we got for those scripts

    root@am335x-evm:/usr# ./usbreg.sh
    bus #0:
    Power : 20
    DevCtl : 80
    bus #1:
    Power : e0
    DevCtl : 80



    root@am335x-evm:/usr# ./5706.chkusb.sh
    chkusb.sh Version 0.2.0
    USB is initialized
    usb@47401000: otg, okay
    usb@47401800: host, okay

    Gadget Kernel Config: g_zero is enabled
    Gadget Kernel Config: g_serial is enabled
    gadget driver loaded: (none)

    The list of USB gadget drivers installed:
    /lib/modules/3.14.26-g2489c02-dirty/kernel/drivers/usb/gadget/:
    g_acm_ms.ko
    g_audio.ko
    g_cdc.ko
    g_dbgp.ko
    g_ether.ko
    g_ffs.ko
    g_hid.ko
    g_mass_storage.ko
    g_midi.ko
    g_multi.ko
    g_ncm.ko
    g_printer.ko
    g_serial.ko
    g_webcam.ko
    g_zero.ko
    gadgetfs.ko
    libcomposite.ko
    u_ether.ko
    u_serial.ko
    usb_f_acm.ko
    usb_f_ecm.ko
    usb_f_ecm_subset.ko
    usb_f_fs.ko
    usb_f_mass_storage.ko
    usb_f_ncm.ko
    usb_f_obex.ko
    usb_f_rndis.ko
    usb_f_serial.ko
    usb_f_ss_lb.ko
    root@am335x-evm:/usr#


    regards,

    Viswanath K
  • One more point we like to add : we are not having "VCC" of USB bus , but the device is self powered. we are having only 3 lines DP,DM and GND connected to host.

    regards,

    Viswanath K
  • There are two issues here.

    first you have to connect the USB0_VBUS pin to the receptacle, even for self-powered devices, in such case the VBUS is still required for signaling.

    Also you did not load the CDC-ACM gadget driver, please do 'modprobe g_serial'.

  • Hi Bin Liu,

    V_BUS -- this point we need to get conformation from my client for the hardware modification.
    But for USB testing i will try to V_BUS testpoint or to a 5V .

    I added g_serial below is the log for that :

    root@am335x-evm:/usr# modprobe g_serial
    [ 93.564412] g_serial gadget: Gadget Serial v2.4
    [ 93.569344] g_serial gadget: g_serial ready
    root@am335x-evm:/usr# ./5706.chkusb.sh
    chkusb.sh Version 0.2.0
    USB is initialized
    usb@47401000: otg, okay
    usb@47401800: host, okay

    Gadget Kernel Config: g_zero is enabled
    Gadget Kernel Config: g_serial is enabled
    gadget driver loaded: DRIVER=g_serial // here it was came as loaded -- earlier case it is <none>

    The list of USB gadget drivers installed:
    /lib/modules/3.14.26-g2489c02-dirty/kernel/drivers/usb/gadget/:
    g_acm_ms.ko
    g_audio.ko
    g_cdc.ko
    g_dbgp.ko
    g_ether.ko
    g_ffs.ko
    g_hid.ko
    g_mass_storage.ko
    g_midi.ko
    g_multi.ko
    g_ncm.ko
    g_printer.ko
    g_serial.ko
    g_webcam.ko
    g_zero.ko
    gadgetfs.ko
    libcomposite.ko
    u_ether.ko
    u_serial.ko
    usb_f_acm.ko
    usb_f_ecm.ko
    usb_f_ecm_subset.ko
    usb_f_fs.ko
    usb_f_mass_storage.ko
    usb_f_ncm.ko
    usb_f_obex.ko
    usb_f_rndis.ko
    usb_f_serial.ko
    usb_f_ss_lb.ko


    regards,

    Viswanath K
  • VISWANATH KONDAPALLI said:
    But for USB testing i will try to V_BUS testpoint or to a 5V .

    Well...I did not validate this before...

    VISWANATH KONDAPALLI said:
    gadget driver loaded: DRIVER=g_serial // here it was came as loaded -- earlier case it is <none>

    Yeah, it is good now. The host still does not enumerate the board? Anything new in dmesg log on the host? What is the output of usbreg.sh script now?

  • 1.
    I didnt run the usbreg.sh script -- i will post that log. My doubt is g_serial loaded manually -- run time can we able to make it as static ???
    i tried USB_G_SERIAL set to Y in the defconfig -- then i got few warning -- related to other USB configs .

    Cant it is possible without V_BUS Line.. ?? i read in usb complete book -- about enumeration steps

    regards,

    Viswanath K

  • Hi Bin Liu,
    We are using Custom Boards 1 as Host and 2nd one is Device and these two are Hard-wired and not for plug and play( connected permanently). Here we like to do Device Communication only using USB-Serial from Host(1. Custom board) to the Device (2. Custom Board).

    We like to clarify from TI Support, Is there any solution in this USB 3 lines method .

    regards,

    Viswanath K
  • This is the post for the USB log: after loading : g_serial and after : usbreg.sh

    root@am335x-evm:/usr# modprobe g_serial
    [ 274.162778] g_serial gadget: Gadget Serial v2.4
    [ 274.167702] g_serial gadget: g_serial ready
    root@am335x-evm:/usr# ./5706.chkusb.sh
    chkusb.sh Version 0.2.0
    USB is initialized
    usb@47401000: otg, okay
    usb@47401800: host, okay

    Gadget Kernel Config: g_zero is enabled
    Gadget Kernel Config: g_serial is enabled
    gadget driver loaded: DRIVER=g_serial

    The list of USB gadget drivers installed:
    /lib/modules/3.14.26-g2489c02-dirty/kernel/drivers/usb/gadget/:
    g_acm_ms.ko
    g_audio.ko
    g_cdc.ko
    g_dbgp.ko
    g_ether.ko
    g_ffs.ko
    g_hid.ko
    g_mass_storage.ko
    g_midi.ko
    g_multi.ko
    g_ncm.ko
    g_printer.ko
    g_serial.ko
    g_webcam.ko
    g_zero.ko
    gadgetfs.ko
    libcomposite.ko
    u_ether.ko
    u_serial.ko
    usb_f_acm.ko
    usb_f_ecm.ko
    usb_f_ecm_subset.ko
    usb_f_fs.ko
    usb_f_mass_storage.ko
    usb_f_ncm.ko
    usb_f_obex.ko
    usb_f_rndis.ko
    usb_f_serial.ko
    usb_f_ss_lb.ko


    root@am335x-evm:/usr# ./usbreg.sh
    bus #0:
    Power : e0
    DevCtl : 80
    bus #1:
    Power : e0
    DevCtl : 80
    root@am335x-evm:/usr#
  • Hi Bin Liu,
    This is the log we got for those scripts

    oot@am335x-evm:/usr# modprobe g_serial
    [ 274.162778] g_serial gadget: Gadget Serial v2.4
    [ 274.167702] g_serial gadget: g_serial ready
    root@am335x-evm:/usr# ./5706.chkusb.sh
    chkusb.sh Version 0.2.0
    USB is initialized
    usb@47401000: otg, okay
    usb@47401800: host, okay

    Gadget Kernel Config: g_zero is enabled
    Gadget Kernel Config: g_serial is enabled
    gadget driver loaded: DRIVER=g_serial

    The list of USB gadget drivers installed:
    /lib/modules/3.14.26-g2489c02-dirty/kernel/drivers/usb/gadget/:
    g_acm_ms.ko
    g_audio.ko
    g_cdc.ko
    g_dbgp.ko
    g_ether.ko
    g_ffs.ko
    g_hid.ko
    g_mass_storage.ko
    g_midi.ko
    g_multi.ko
    g_ncm.ko
    g_printer.ko
    g_serial.ko
    g_webcam.ko
    g_zero.ko
    gadgetfs.ko
    libcomposite.ko
    u_ether.ko
    u_serial.ko
    usb_f_acm.ko
    usb_f_ecm.ko
    usb_f_ecm_subset.ko
    usb_f_fs.ko
    usb_f_mass_storage.ko
    usb_f_ncm.ko
    usb_f_obex.ko
    usb_f_rndis.ko
    usb_f_serial.ko
    usb_f_ss_lb.ko
    root@am335x-evm:/usr# ./usbreg.sh
    bus #0:
    Power : e0
    DevCtl : 80
    bus #1:
    Power : e0
    DevCtl : 80

    regards,

    Viswanath K
  • VISWANATH KONDAPALLI said:
    We like to clarify from TI Support, Is there any solution in this USB 3 lines method .

    Unfortunately there is no such solution. The dianostic log you provided shows the sw has no problem, the problem should be on the hw side due to missing VBUS. I recommand you provide the schemtics for review.

  • VISWANATH KONDAPALLI said:
    My doubt is g_serial loaded manually -- run time can we able to make it as static ???

    It depends on which kernel you use.

    If you use kernel in SDK7, yes you can build the gadget driver statically into the kernel, but if you use kernel in SDK8+, the gadget driver has to be built as module, due to a known bug in the USB framework, But you can still load the module automatically using script during system booting. For example, put the following script to filesystem /etc/rc5.d/ folder.


    #!/bin/sh
    modprobe g_serial