News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Unstable USB connetion

Started by jlamp, June 06, 2018, 03:51:10 PM

Previous topic - Next topic

jlamp

Hi,

I have the TE0720-03-1CFA module with TE0706 Carrier and I have been experiencing strange USB behavior when I try to connect an Asus Xtion Camera to the USB port.

Here the log example and the differences when I plug and unplug a Rii KEYBOARD WIRELESS RT-MWK01+ and Asus Xtion Camera with the reference image.



// Plug Rii Keyboard
root@plnx_arm:~# usb 1-1: new full-speed USB device number 2 using ci_hdrc
input:   Mini Keyboard as /devices/soc0/amba/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0/0003:1997:2433.0001/input/inp0
hid-generic 0003:1997:2433.0001: input: USB HID v1.01 Keyboard [  Mini Keyboard] on usb-ci_hdrc.0-1/input0
input:   Mini Keyboard as /devices/soc0/amba/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1:1.1/0003:1997:2433.0002/input/inp1
hid-generic 0003:1997:2433.0002: input: USB HID v1.01 Mouse [  Mini Keyboard] on usb-ci_hdrc.0-1/input1

// Unplug the keyboard
usb 1-1: USB disconnect, device number 2

// Plug the keyboard again
usb 1-1: new full-speed USB device number 3 using ci_hdrc
input:   Mini Keyboard as /devices/soc0/amba/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0/0003:1997:2433.0003/input/inp2
hid-generic 0003:1997:2433.0003: input: USB HID v1.01 Keyboard [  Mini Keyboard] on usb-ci_hdrc.0-1/input0
input:   Mini Keyboard as /devices/soc0/amba/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1:1.1/0003:1997:2433.0004/input/inp3
hid-generic 0003:1997:2433.0004: input: USB HID v1.01 Mouse [  Mini Keyboard] on usb-ci_hdrc.0-1/input1

// Unplug it again
usb 1-1: USB disconnect, device number 3

// Plug the Asus Xtion Camera
usb 1-1: new high-speed USB device number 4 using ci_hdrc

//Unplug Asus Xtion Camera
???Nothing happens, USB is not disconnecting


And if I type lsusb command after unplug  the device still remains there!


root@plnx_arm:~# lsusb
Bus 001 Device 004: ID 1d27:0601  <- Astra camera
Bus 001 Device 001: ID 1d6b:0002


It seems that USB gets stuck in this case and is not updating.

Also sometimes when I unplug the camera I can see the USB disconnect message but this is very aleatory and I need the camera USB connection to be stable for my application.

Can someone point me in the right direction and help me debugging this issue?

Thank you very much,

Jorge

JH

Hi,
which reference image? the newest one?
but I think this can be a driver problem. Reference designs are only configured with basic drivers, it can be that you need special driver for this camera.
brJohn

jlamp

Hi John,

Yes the reference image is the newest one, the one you provide.

I have created a custom image using Yocto and I am experiencing the same behavior with the module. But when I tried  it in the zc702 development board the camera works without any problem so I think that the problem is more hardware or device-tree problem (I have reused the root file system and the kernel in both cases) than drivers.

Comparing the device-trees I have seen that zc702 uses pinctrl:

pinctrl_usb0_default: usb0-default {
mux {
groups = "usb0_0_grp";
function = "usb0";
};

conf {
groups = "usb0_0_grp";
slew-rate = <0>;
io-standard = <1>;
};

conf-rx {
pins = "MIO29", "MIO31", "MIO36";
bias-high-impedance;
};

conf-tx {
pins = "MIO28", "MIO30", "MIO32", "MIO33", "MIO34",
       "MIO35", "MIO37", "MIO38", "MIO39";
bias-disable;
};
};


Do I need to add them?

From Hardware side I see that the used usb chip is USB3320 and the schematic are very similar but the SOM uses a CPLD for the USB Reset could be this a problem?

This are for now two options that come to my mind to solve the problem but any help would be very appreciated.

Thank you very much for your help,

Jorge


JH

Hi,
you must try out. I didn't have this camera, so that I can't try out on my place.
At the moment I think it's not a reset problem. More Kernel and Device tree configuration.

pinctrl device tree entry seem to be ok for TE0720,  (TE0720 used also USB0 with MIO 28...39, so values should be work). But you must also check kernel config changes from zc702. or if they add something else which is needed for this camera (rootfs...).

Our Linux used default petalinux with our HDF import and additional changes listet here:
brJohn



jlamp

Hi John,

Kernel config is the same in both boards and also the rootfs, I created them for the TE0720 and seeing that I had no success I put the same in zc702 SDCard so I don't think the problem is here.

Another question, why I need to add

    /*
     * Reset pulse to USB PHY
         */
        Status = XEmacPs_PhyWrite(&Emac, 0x1A,  7, 0x0010); if(Status != XST_SUCCESS){ return XST_FAILURE; }
        Status = XEmacPs_PhyWrite(&Emac, 0x1A,  7, 0x0000); if(Status != XST_SUCCESS){ return XST_FAILURE; }


code in FSBL to recognize the USB? I dont' see it in the zc702 board.

Thank you very much,

Jorge

jlamp

I have also created a small program to reset the USB

#include <stdio.h>
#include <fcntl.h>  // cor open
#include <unistd.h> // for close
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>

void main(int argc, char **argv){

        const char *filename;
        int fd;
        filename = argv[1];

        fd = open(filename, O_WRONLY);
        ioctl(fd, USBDEVFS_RESET, 0);
        close(fd);

        return;

}


And when the USB gets stuck I execute it and I see how is reset

root@hros-trenz-som:~# ./reset /dev/bus/usb/001/002
usb 1-1: USB disconnect, device number 2
root@hros-trenz-som:~# usb 1-1: new high-speed USB device number 3 using ci_hdrc


So why is not a reset problem?

Thank you very much,

Jorge

JH

Hi,

i think only that's not a reset problem, because in the most cases it's a driver problem. But it can be also a reset problem. there are also much more reasons possible, which can effect this issue.
Did you checked the sources from same Vivado/Petalinux release, as you compared ZC702 and TE0720 petalinux configuration?

To your first post question:


    /*
     * Reset pulse to USB PHY
         */
        Status = XEmacPs_PhyWrite(&Emac, 0x1A,  7, 0x0010); if(Status != XST_SUCCESS){ return XST_FAILURE; }
        Status = XEmacPs_PhyWrite(&Emac, 0x1A,  7, 0x0000); if(Status != XST_SUCCESS){ return XST_FAILURE; }


Here FSBL write to CPLD and reset USB on power up. This is user code to get access to TE0720 CPLD, so it's not on zc702.

br
John

jlamp

#7
Hi,

Right now I am using Yocto to generate Linux distribution not Petalinux. With Yocto zc702 works but TE0720 gets stuck.

I have check Vivado project and the only difference between two boards is this MIO configuration part. Where the USB0 Reset is defined to use MIO7 zc702 but in the TE0720 not.



I can see this usb reset pin in the schematics of the zc702



In TE0720 I see that the USB reset is done through the CPLD,



So my question is how knows the CPLD when to do the reset when I unplug the camera from the USB connector and update the lsusb command?

Thanks,
Jorge

Modified, now images should be viewed

Antti Lukats

USB PHY does not need the reset to be toggled after initial power up. So if it works it must work without any software controlled resets applied during operation.

jlamp

Okey, I have read the datasheet and also with your explanation I have more clear how works the USB phy now. But there is a line in page 24 that I don't understand very well:

QuoteIf the Link is not ready to interface the USB3320, the Link may choose to hold the RESETB  pin low until it is ready to control the ULPI interface.

Is this only in power on the phy or can be also when I plug and unplug a device?

Could you help me and tell which is the easiest way to debug usb-phy code?

Could be that te0720 and zc702 had different release usb-phy and this phy release has a errata?

Thanks  a lot!

Jorge

jlamp

More input,

I have tried the camera connecting it to a zynqberry and it works correctly!!

I have used  the same rootfs and kernel image that I am using in the te0720 and I have changed only the device-tree and the fpga design where the zynqberry uses a mio pin for the usb-reset as the zc702.

So now I am not sure that the problem is in the driver (this driver also works in raspberry pi) and the only difference is in hardware with the CPLD usb reset.

Is the  XC7Z015-1CLG485I module suitable TE0706 carrier?

Thanks

JH

Hi,

can you open Vivado IP and add USB Reset to MIO7 (on MIO Configuration --> GPIO ). Set Reset Polarity to active high, instead of Low. Because there is a pulldown on MIO7 on the module.
Regenerate all Files and try out if it works.
Maybe it must be only assigned.
Only information: I detect such a kind of problem for example on ZynqBerry and QSPI Flash with Vivado 2017.3 and newer. New Xilinx Micro Uboot get only access to QSPI Flash, if QSPI Feedback-CLK is enabled (but on HW this mio is normally used for UART). With older Vivado Version this was no problem and Feedback CLk is optional. For ZynqBerry you need this only for Flash Programming (see ZynqBerry test_board design description), so in this case i generate the special FSBL for programming only with feedback CLK enabled.

Let me know, if this helps.

br
John

jlamp

Hi John,

No luck, same behavior as in older posts.

As a workaround solution I have seen that TE0715-04-15-1I module is using MIO50 for OTG_Reset, is this module compatible with the TE0706 Carrier right?

Thanks for your time,

Jorge


JH

Hi,
i can generate you a CPLD Firmware with Reset from MIO7  connected to OTG Reset.
You can reconfigure CPLD with TE0706:
Lattice programmer tools are free available.

Send me email to support@trenz-electronic.de
TE0715 and TE0706 is compatible, see also:brJohn

jlamp

Hi John,

I am trying to program the CPLD but I am having som problems connecting to the device.

I have downloaded Diamond Programmer but after it finishes scanning for devices I got an error saying that Scan Failed.

Then I am trying to program the device but I am having other error in both ports (FTUSB-0 and FTUSB1):



I have added this udev rules but it seems that the programmer is not recognized:

ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0666" ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", ATTRS{product}=="Lattice FTUSB Interface Cable", RUN+="/bin/sh -c 'echo $kernel > /sys/bus/usb/drivers/ftdi_sio/unbind'"


Also the switch S1 configuration in TE0706 is 1-ON 2-OFF 3-ON 4-OFF

Can you help me with the programming?

Thank you very much,

Jorge

JH

#15
Hi,
on my place it works with TE0706, see screenshot.
TE0706 DIPs: S1-1 OFF (not connected), S1-2 OFF(CPLD in chain), S1-3 ON, S1-4 OFF  .  S1-1,S1-3 and S1-4 should be don't care. your DIP should be also correct.

I see you use Linux. Native or VM? Which Linux? Is it supported by Lattice?

PS: In case of Ubuntu, i found: https://ycnrg.org/lattice-diamond-on-ubuntu-16-04/

Did you close all Xilinx programs? On Win OS Xilinx "HW_server.exe" crash sometimes and if this exe is not close, it's not possible for  Diamond Programmer to get access to CPLD. I use only Win OS, so I did not now, if it's the same on linux.
br
John

jlamp

Hi John,

Yes I am using Ubuntu 16.04 natively.

I have also tried in a computer with Windows 10 installed and I am having the same behavior.

Thanks!

JH

Hi,

on Win it should work. I've also Win 10 (Version 1803 Build 17134.112) --> you can check with "winver".
Your Diamond is version is 3.10?

Can you change USB cable(shorter maybe)?
Can you use another USB connector on your PC?
Can you reboot your WinOS one time?
Do not open Vivado and connect only the TE0720 with the TE0706 after reboot.

br
John

JH

Hi,
which programmer did you used on the TE0706?
Our TE0790 (XMOD)?

br
John

jlamp

Hi John,

I managed to flash it correctly under Windows, I wasn't connecting the power correctly, my fault.

I will try now with the depthsensor.

Thank you very much!

jlamp

Hi John,

I have tried again with the depthsensor and the new image files but nothing I am experiencing  the same behavior as in the past posts.

Any new idea?

Thank you for your help

JH

You has inverted USB Reset on PS IP?
Did you recompiled all? Also linux?
Did you check USB with other usb mass storage device with the new design?

Short summary:

So on Zynqberry it works without any changes on following design:
https://shop.trenz-electronic.de/en/Download/?path=Trenz_Electronic/Modules_and_Module_Carriers/special/TE0726/Reference_Design/2017.4/test_board
te0726-test_board-vivado_2017.4-build_08_20180517084735.zip

It didn't work on TE0720 without any changes on following design:
https://shop.trenz-electronic.de/en/Download/?path=Trenz_Electronic/Modules_and_Module_Carriers/4x5/TE0720/Reference_Design/2017.4/test_board
te0720-test_board-vivado_2017.4-build_07_20180426144351.zip

It didn't work on TE0720 with changed CPLD Firmware for OTG reset and changed design and linux generated with new HDF based onfollowing design:
https://shop.trenz-electronic.de/en/Download/?path=Trenz_Electronic/Modules_and_Module_Carriers/4x5/TE0720/Reference_Design/2017.4/test_board
te0720-test_board-vivado_2017.4-build_07_20180426144351.zip

Is this correct?

br
John

jlamp

Hi John,

Yes, I have  inverted USB Reset.



And recompiled Linux image again using Yocto with the new design.

I have tried with the mini keyboard, usb memory,also connecting my mobile to the usb port and they have worked.

Yocto image is based on the .zip files you have point me so:


  • Zynqberry - OK
  • TE0720 without any changes - Not working
  • TE0720 with changed CPLD Firmware  - Not working

Can I remove the R13 resistor and change the gpio to active low?

Thanks,

JH

Hi,
ZynqBerry: Did you try out this with our 2017.4 reference design without any changes? Or some other?

Different is also kernel configuration, because on Zynqberry ETH over USB is activated: Additional Manuel changes: https://wiki.trenz-electronic.de/display/PD/TE0726+Test+Board#TE0726TestBoard-Kernel

Remove resistor will be possible, but you CPLD code must be also changed, in case you would change the polarity again. See description in the email i've send you.

br
John

jlamp

Hi,

No I haven't tried with the 2017.4 reference designs in the zynqberry I have taken the same sd card I am inserting to the TE0706 with the uImage and rootfs(Yocto created) and insert it to the zynqberry. The only change between each others is the device-tree for zynqberry.

Thanks

jlamp

I am checking the lsusb -v and this are the differences between zynqberry and te0706:

* zynqberry:



Bus 001 Device 004: ID 1d27:0601 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x1d27
  idProduct          0x0601
  bcdDevice            0.01
  iManufacturer           5 PrimeSense
  iProduct                4 PrimeSense Device
  iSerial                 0
  bNumConfigurations      1

......

Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)





* te0706



Bus 001 Device 002: ID 1d27:0601 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x1d27
  idProduct          0x0601
  bcdDevice            0.01
  iManufacturer           5 (error)
  iProduct                4 (error)
  iSerial                 0
  bNumConfigurations      1

can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
cannot read device status, Resource temporarily unavailable (11)



Any idea why in the te0706 I got an error for iManufacturer and iProduct?

Also it seems that te0706 is not able to get the device qualifier and the device status for the usb, do you know why can be this?

Thanks!

jlamp

Update,

I have configure the kernel with this configurations


CONFIG_BLK_DEBUG_FS=y
CONFIG_DEBUG_FS=y
CONFIG_USB_MON=y


And using tcpdump I have taken some USB Request Block (URB) packages after writing lsusb -v in the terminal.


  • te0706

I can see how in the te0706 for example when it tries to get the status response the URB status is:  No such file or directory (-ENOENT)(-2) and same with the qualifier and descriptor.





  • zynqberry

On the other hand in the zynqberry I have URB status: Success (0)



JH

Hi,

other different between ZynqBerry and TE0720 with TE0706:

       
  • Additional "LAN9514" (USB-HUB with ETH controller) on TE0726
  • Signal routing length is shorter on TE0726
Can you try to connect usb memory stick and copy a larger files between TE0720 and the memory stick. Check with tcpdump if you can detect some errors like this.
br
John

jlamp

Hi John,

When I came to the office I powered on the board, connected the camera and voila it has worked at first.

I have tried another time to see if I it works again but nothing, still having the same problems. I will leave the board untouched until lunch time and I will try again to see if it works.

Thanks!

jlamp

Hi,

I 've been trying and this has very random behavior. Sometimes when I connect the camera and just then launch the application, the camera start working and I can see see the infrared led, also lsusb -v is okey but other times it seems that the camera doesn't want to start.

JH

Hi,

do you have an USB hub with external power supply?
Can you connect this between TE0706 and your camera?

br
John

jlamp

Finally I am able to run the camera without a random behavior. The problem is related to board powering.

I have sold tree pins to the J6A row 5V and GND like you can see in the image.



And with this connector



My application and lsusb -v work without problems and they are not stuck.

Thank you very much John for your help, I am very grateful.

Best regards,

Jorge