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.

sdk08.00 am335x usb 一主一从设计



各位好,现在想要usb0设置为从模式,与PC通信;usb1设置为主模式,通过hub连接各种usb设备。usb1功能已实现,usb0通过usb线连接电脑无反应。

硬件上,两个usb的vbus脚都是直接接5V,usb0的ID脚悬空,usb1的ID脚下拉到地。除DM、DP外的其它脚悬空。

dts配置如下:

&usb {
	status = "okay";

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

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

	usb-phy@47401b00 {
		status = "okay";
	};

	usb@47401000 {
		status = "okay";
	};

	usb@47401800 {
		status = "okay";
		dr_mode = "host";
	};

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

启动后usb信息如下:

 dmesg | grep usb
[    0.250293] usbcore: registered new interface driver usbfs
[    0.250482] usbcore: registered new interface driver hub
[    0.250677] usbcore: registered new device driver usb
[    1.275226] usbcore: registered new interface driver asix
[    1.281138] usbcore: registered new interface driver ax88179_178a
[    1.287742] usbcore: registered new interface driver cdc_ether
[    1.294095] usbcore: registered new interface driver smsc95xx
[    1.300298] usbcore: registered new interface driver net1080
[    1.306424] usbcore: registered new interface driver cdc_subset
[    1.312794] usbcore: registered new interface driver zaurus
[    1.318900] usbcore: registered new interface driver cdc_ncm
[    1.325029] usbcore: registered new interface driver cdc_mbim
[    1.355088] usbcore: registered new interface driver cdc_wdm
[    1.361281] usbcore: registered new interface driver usb-storage
[    1.368011] usbcore: registered new interface driver usbserial
[    1.374324] usbcore: registered new interface driver option
[    1.380329] usbserial: USB Serial support registered for GSM modem (1-port)
[    1.389949] of_get_named_gpiod_flags: can't parse gpios property of node '/ocp/usb@47400000/usb-phy@47401300[0]'
[    1.390014] 47401300.usb-phy supply vcc not found, using dummy regulator
[    1.399816] musb-hdrc musb-hdrc.0.auto: Failed to request rx1.
[    1.406019] musb-hdrc musb-hdrc.0.auto: musb_init_controller failed with status -517
[    1.414335] platform musb-hdrc.0.auto: Driver musb-hdrc requests probe deferral
[    1.422741] of_get_named_gpiod_flags: can't parse gpios property of node '/ocp/usb@47400000/usb-phy@47401b00[0]'
[    1.422794] 47401b00.usb-phy supply vcc not found, using dummy regulator
[    1.432417] musb-hdrc musb-hdrc.1.auto: Failed to request rx1.
[    1.438708] musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status -517
[    1.446892] platform musb-hdrc.1.auto: Driver musb-hdrc requests probe deferral
[    1.512511] usbcore: registered new interface driver uvcvideo
[    1.586269] usbcore: registered new interface driver usbhid
[    1.592184] usbhid: USB HID core driver
[    2.870145] musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx, SoftConn)
[    2.870162] musb-hdrc: MHDRC RTL version 2.0 
[    2.870172] musb-hdrc: setup fifo_mode 4
[    2.870187] musb-hdrc: 28/31 max ep, 16384/16384 memory
[    2.870292] musb-hdrc musb-hdrc.0.auto: MUSB HDRC host driver
[    2.876833] musb-hdrc musb-hdrc.0.auto: new USB bus registered, assigned bus number 1
[    2.885360] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    2.892526] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.900127] usb usb1: Product: MUSB HDRC host driver
[    2.905351] usb usb1: Manufacturer: Linux 3.14.26 musb-hcd
[    2.911141] usb usb1: SerialNumber: musb-hdrc.0.auto
[    2.930167] musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx, SoftConn)
[    2.930186] musb-hdrc: MHDRC RTL version 2.0 
[    2.930194] musb-hdrc: setup fifo_mode 4
[    2.930209] musb-hdrc: 28/31 max ep, 16384/16384 memory
[    2.930333] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    2.936934] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 2
[    2.945428] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[    2.952588] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.960197] usb usb2: Product: MUSB HDRC host driver
[    2.965417] usb usb2: Manufacturer: Linux 3.14.26 musb-hcd
[    2.971195] usb usb2: SerialNumber: musb-hdrc.1.auto
[    3.387144] usb 2-1: new high-speed USB device number 2 using musb-hdrc
[    3.549623] usb 2-1: New USB device found, idVendor=0424, idProduct=2514
[    3.556675] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.888301] usb 2-1.2: new high-speed USB device number 3 using musb-hdrc
[    4.117340] usb 2-1.2: New USB device found, idVendor=058f, idProduct=5608
[    4.124577] usb 2-1.2: New USB device strings: Mfr=3, Product=1, SerialNumber=0
[    4.132276] usb 2-1.2: Product: USB 2.0 Web Camera
[    4.137322] usb 2-1.2: Manufacturer: Alcor Micro, Corp.
[    4.217896] input: USB 2.0 Web Camera as /devices/ocp.3/47400000.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1.2/2-1.2:1.0/input/input1
root@am335x-evm:~# dmesg | grep hub
[    0.250482] usbcore: registered new interface driver hub
[    2.917427] hub 1-0:1.0: USB hub found
[    2.921458] hub 1-0:1.0: 1 port detected
[    2.977400] hub 2-0:1.0: USB hub found
[    2.981425] hub 2-0:1.0: 1 port detected
[    3.588407] hub 2-1:1.0: USB hub found
[    3.592472] hub 2-1:1.0: 4 ports detected

想问下:

1.硬件上是否可以这样设计?

2.如果可以,是否还有哪里需要设置或什么的?之前调试usb1的时候,由于下接hub不支持热插拔,打过一个patch,此外就没有修改过内核usb相关文件了。

期待各位的回复,先行谢过。

  • 现在想着打一下Sitara Linux SDK MUSB Issues里边的patch尝试一下,但是我这边一直打不开这些patch包的链接,各位谁能帮忙给贴出来??谢谢了。

  • 刚仔细过了一遍,发现dts中有问题,已经改过来了,如下:

    &usb {
        status = "okay";
    
        control@44e10620 {
            status = "okay";
        };
    
        usb-phy@47401300 {
            status = "okay";
        };
    
        usb-phy@47401b00 {
            status = "okay";
        };
    
        usb@47401000 {
            status = "okay";
            dr_mode = "peripheral";
        };
    
        usb@47401800 {
            status = "okay";
            dr_mode = "host";
        };
    
        dma-controller@47402000  {
            status = "okay";
        };
    };

    但是还是不行,不知道哪里还有问题?

  • 刚才仔细过了一遍,发现dts中有点问题,已经改过来了,如下:

    &usb {
    	status = "okay";
    
    	control@44e10620 {
    		status = "okay";
    	};
    
    	usb-phy@47401300 {
    		status = "okay";
    	};
    
    	usb-phy@47401b00 {
    		status = "okay";
    	};
    
    	usb@47401000 {
    		status = "okay";
    		dr_mode = "peripheral";
    	};
    
    	usb@47401800 {
    		status = "okay";
    		dr_mode = "host";
    	};
    
    	dma-controller@47402000  {
    		status = "okay";
    	};
    };

    但是还是不行,想要把usb0配成从模式的hid,与pc通信,不知道还有哪里有问题。

  • 硬件上不建议这么做的,您的这部分原理图能贴上来吗?

  • 感谢您的回复,原理图如下:( usb0中除了DM和DP,都是悬空的。)

     

     

     

     

     

     

    另外测试了下,将usb0 的id脚接地后,配置成host引脚,是正常工作的。期待您的回复!

  • 不好意思,上边写错了,是配置成host模式,usb0可以正常工作。

    在musb_dspc.c的dsps_interrupt函数中,添加了一条打印信息,在host模式的时候,会打印进入中断的信息;在配置成peripheral模式的时候,插入电脑usb口后,无进入此中断的信息。

    config配置信息大致如下:

  • 经修改hid.c文件,并且配置成模块的方式,linux启动后手动加载模块,已经可以被PC识别为HID,再次感谢回复。

  • 经修改hid.c文件,并且配置为模块,在linux启动后手动加载模块,已能被PC端检测为HID设备,再次感谢回复。

  • Hi, jinfeng
      你好,我遇到的现象和你类似,SDK8.0,Board参考TI AM335X SK board
      Device Tree 配置:
      usb@47401000 {
        status = "okay";
        dr_mode = "otg";
        };
     
      usb@47401800 {
        status = "okay";
        dr_mode = "host";
        };  
      USB0我想配置为OTG Mode, 因为需要HOST mode & Device mode的切换,So,SW setting USB0 mode is "OTG"
      进入系列之后,发现USB0中断的确没有进去,Insert U Disk没有任何反应
      修改DTS,USB0 Mode 配置为 HOST, 一切OK
      就是想请教一下,看到你Modify hid.c 文件,不知道Modify Code是否可以share一下,谢谢!
      My mial:renyanjinlong@163.com

  • 已发,请注意查收。

  • 你好。我现在也在做usb0是gadget模式   usb1是host模式

     DM385板卡设置一个usb控制器为host 模式。另一个usb控制器为gadget模式
        我按照手册做如下修改
         1) Select host and gadget support

        Menuconfig->Device Drviers->USB Support
              <*>   Support for Host-side USB  
              [ ]     USB verbose debug messages   
              [*]     USB announce new devices     
              *** Miscellaneous USB options ***   
              ......
              <*>   USB Gadget Support  ---> 

        2) Select USB OTG support (for TI814X/TI813X/TI811X)

          Menuconfig->Device Drviers->USB Support
              <*>   Inventra Highspeed Dual Role Controller (TI, ADI, ...)  
                           *** Platform Glue Layer *** 
              < >     TUSB6010                                                           
              < >     OMAP2430 and onwards                                               
              < >     AM35x                                                             
              <*>     TI81XX                                                            
                      TI816X usb connector's ID pin control (from usb connector)  ---> 
                      Driver Mode (Both host and peripheral:  USB OTG (On The Go) Device)  --->  
              [ ]   Disable DMA (always use PIO)                                          
              [*]   Enable debugging messages                   

    3) Select USB OTG support (for TI816X)
       Menuconfig->Device Drviers->USB Support
              <*>   Inventra Highspeed Dual Role Controller (TI, ADI, ...)  
                           *** Platform Glue Layer *** 
              < >     TUSB6010                                                           
              < >     OMAP2430 and onwards                                               
              < >     AM35x                                                             
              <*>     TI81XX                                                            
                      TI816X usb connector's ID pin control (from software setting)  ---> 
                                Force TI816X USB0 to  (Host mode)  ---> 
                                Force TI816X USB1 to  (Host mode)  --->                 
                      Driver Mode (Both host and peripheral:  USB OTG (On The Go) Device)  --->  
              [ ]   Disable DMA (always use PIO)                                          
              [*]   Enable debugging messages    
                                             

    4) Select Gadget device controller and gadget driver as modules
     Menuconfig->Device Drviers->USB Support
              <*>   USB Gadget Support  --->
                    --- USB Gadget Support                                
                    [ ]   Debugging messages (DEVELOPMENT) (NEW)           
                    [ ]   Debugging information files (DEVELOPMENT) (NEW)  
                    [ ]   Debugging information files in debugfs (DEVELOPMENT) (NEW)
                    (2)   Maximum VBUS Power usage (2-500 mA) (NEW)                 
                    USB Peripheral Controller (Inventra HDRC USB Peripheral (TI, ADI, ...))  --->
                   <M>   USB Gadget Drivers                                                          
                   <M>     Gadget Zero (DEVELOPMENT)                                                 
                   [ ]       HNP Test Device (NEW)                                                   
                   < >     Audio Gadget (EXPERIMENTAL) (NEW)                                         
                   <M>     Ethernet Gadget (with CDC Ethernet support)                               
                   [*]       RNDIS support (NEW)                                                     
                   [ ]       Ethernet Emulation Model (EEM) support (NEW)                            
                   < >     Gadget Filesystem (EXPERIMENTAL) (NEW)                                    
                   < >     Function Filesystem (EXPERIMENTAL) (NEW)                                  
                   <M>     File-backed Storage Gadget                                                
                   [*]       File-backed Storage Gadget testing version

    5) Unselect the OTG Targeted Peripherals list
         Menuconfig->Device Drviers->USB Support
              <*>   Support for Host-side USB
                    ....
                   [*] USB runtime power management (autosuspend) and wakeup  
                   -*- OTG support  
                   [ ]   Rely on OTG Targeted Peripherals List 
                   [ ]   Disable external hubs 
        
    6) Build uImage and usb gadget modules
    7)  Insert the gadget modules
         1. insmod g_ether.ko (usb0 port will be enabled as cdc/rndis gadget)
         2. insmod g_zero.ko (usb1 port will enabled as host mode and all devices (eg.USB-HDD/flash drive etc) connected
           to this port will be enumerated
        3. rmmod g_ether.ko (remove the gadget driver from usb0 port)
        4. insmod g_file_storage.ko file=/dev/sda stall=0 buflen=65536 (or use g_mass_storage.ko)
         Now the usb0 port can be connected to window/linux host as mass storage gadget with USB-HDD (/dev/sda) as
    storage media.
     结果:
        进行如上操作后。将U盘插入USB1.  将标准的usb电缆连接到pc端都没有任何的反应。没有识别
    请问你是如何修改让一个做主一个做从
  • 您好,我也遇到了相似的问题,可以把您修改的地方发我一份吗?我的邮箱:carl.wp@foxmail.com 谢谢