ML401 (Virtex 4 development board) as a USB peripheral

I'm trying to get the Cypress Ez-host working in peripheral mode on a Xilinx ML401 development board. The example code I have is for the actual cypress development board, but I don't see why anything should be different. When I program the USB controller chip with an HID example, and plug in a usb cable to a pc - windows says the usb device does not function correctly.

Can anyone point me in the right direction?

Thanks

Reply to
alleynb
Loading thread data ...

On Aug 22, 4:10 am, snipped-for-privacy@gmail.com wrote:

This is actually quite tricky! I'm not sure where the EZ part of the name came from. What you have to do essentially is:

1) Write some C code to implement your USB Peripheral. This C-Code will run on the EZ-Host's internal processor. The EZ-USB development kit (free download from Cypress website) has some example C-Code and other stuff the get you started (but it's still not EZ, the example fail to explain what the code is really doing and the documentation is pretty hard to follow). 2) Then once you have this C-Code, compile it, and then dump it to a binary file. This binary file is then dumped to a C sytle array, so every byte in the array is the hex representation of every byte in the binary file. There are some utilities provided to help with this in the cypress development kit. This binary file must be uploaded to the EZ-Host. This is done from the FPGA. I believe the ml401 keyboard demo does this - it does the following: Using he opb_emc peripheral, it connects to the EZ-Host using the HPI interface protocol. There is C-Code in some of example which implements some of the HPI protcocol commands (again, not easy if you are not familiar with it, and some of the HPI instructions are NOT in the cypress documentation, but only exist in header files in some of the examples, so a lot of digginf is required). Once you have HPI communication mastered, and know how to write to the EZ-Host program memor, you upload the contents of the compiled binary file. The best thing to do is to write some C-Routines that essentially implement a function you pass start address, data and length to the C function and it will figure out the necessary HPI commands to upload to the EZ- Host. Then pass the C-array version of the binary file to this - tell the EZ-Host to re-boot, and viola - you have the EZ-Host doing whatever you wrote the C code to do - be a peripheral, be a host, be 2 peripherals, whatever.

I suggest you try upload some of the example C-Code that comes with the EZ-Host development kit. You can then use some of the example demo applications that will do things like loop-back tests between the peripheral and the PC. You have to install usb drivers into your system too - so windows knows what the peripheral is, etc. The development kit comes with some example drivers for this too - ones than can talk to the peripheral and determine what way its configured

- but it can only do it if the driver has been told it can operate for a given vendorID and productID that the peripheral is setup as (I was unable to find a generic USB "spy" program that would simply interrogate and debug any attached USB device - which made the debug process all the more painful.

Once you have the ability to upload a program to the EZ-Host you are definitely doing well!

To make a long story short - this is tricky. Not EZ. Maybe if you are experienced in USB it is EZ! But trying to do what you are doing really turned me off using the EZ-Host. Because after wading through the docs and finally getting something up and running, I was able to achieve about 40Kbytes data transfer rate to my "peripheral". I was happy I had a proof of concept, but that was all. I abandoned it in favour of a really easy USB-FIFO chip, which comes with drivers and all you need to get data streaming between an FPGA and a host computer.

Unfortunately I don't have that project to hand right now - but it can be done. And maybe even with the right software written for the EZ- Host and uploaded you can get it to run faster than my paltry 40Kbytes/ sec (it should be capable of 900Kbytes/sec..or so).

Best of luck, and I hope this has helped a bit!

Reply to
John McGrath

Linux has a lsusb utility that tells you what is connected.

Sample printout: Bus 005 Device 001: ID 0000:0000 Bus 004 Device 001: ID 0000:0000 Bus 002 Device 001: ID 0000:0000 Bus 001 Device 008: ID 091e:0003 Garmin International GPSmap (various models) Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. Bus 001 Device 001: ID 0000:0000 Bus 001 Device 003: ID 0bc2:0502 Seagate RSS LLC Bus 001 Device 002: ID 05e3:070e Genesys Logic, Inc. Bus 003 Device 001: ID 0000:0000

--
These are my opinions, not necessarily my employer's.  I hate spam.
Reply to
Hal Murray

Hi Hal, Thanks for that - useful to know. Unfortunately I don't have root on my linux machine (work machine), and it's the 2.4 kernel (don't ask!) So I was not able to use any of those nice Linux utilities. Windows was all I had "root" on to install stuff. But lsusb sounds like the way to go if you can use it.

P.S. Sorry for the numerous typos in my previous post - I was rushing a bit. Also, I assume the OP has access to the EDK - which was what I used for talking to the EZ-Host on the FPGA side, I didn't make that clear in the original post. You don't have to use the MicroBlaze, some HDL could be written to implement the HPI protocol too. But it did make it a little easier to be able to use C code to implement the protocol.

John

Reply to
John McGrath

You don't need to be root. (at least on a vanilla Fedora 6 system)

There is more info in /proc/bus/usb/, things like this:

T: Bus=01 Lev=01 Prnt=01 Port=05 Cnt=02 Dev#= 3 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=0bc2 ProdID=0502 Rev= 2.00 S: Manufacturer=Seagate S: Product=ST94811U2-RK S: SerialNumber=344E463039384754 C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 4mA I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

--
These are my opinions, not necessarily my employer's.  I hate spam.
Reply to
Hal Murray

I think you need to be root to enable some usb features in the 2.4 kernel and I think lsusb only works with the 2.6 kernel - so I was caught both ways - could not change my linux version, and could not get the usb functions to work on the 2.4 kernel without root. I could be completely wrong - I'm far from a Linux guru - but that's more or less what I found at the time. It would have made my life a lot easier though - maybe I should have gotten a live linux cd for my laptop and saved all this trouble! Thanks again for the tip!

Reply to
John McGrath

Thanks,

Using the microblaze processor seems a bit like overkill. All I need to do is be able to send/receive bytes from the PC to the Cypress micro. The FPGA can then read/write from the micro over the GPIO pins. There is an example in the cypress docs which connects leds to the GPIOs of the micro and allows the PC to set/clear them by sending bytes over the USB. Supposidly the micro should appear as a standard HID device and the standard USB HID drivers can be used on windows. Unfortunately when I download that example code it does not work. Looking at USBview it appears that the Cypress micro has not been enumerated properly. All fields appear as zero, hence windows does not know what driver to use.

I'll try using linux to dump the raw transactions of the usb bus if this is possible, to attempt to debug it.

Reply to
alleynb

Well the Cypress device will appear like a standard HID device if you first program it to do so! You have to compile the source code for the microcontroller running inside the EZ-Host to make it behave like the USB Host or Peripheral you want it to be. So the first thing to do is to load this program into the EZ-Host (there is a default program running when it powers on, but I don't think it's a peripheral).

I used the MicroBlaze to upload this program to the EZ-Host. You don't need to do this, but you do need to upload something to the Cypress chip in order to get it working. I believe the Cypress Development kit does this uploading for you, when you use their development board, etc. The HPI protocol was the method I used to upload the program to the Cypress chip - but there are others too (SPI, etc). The reason I used this was because the ml401 usb-keyboard demo uses this setup to initialize the EZ-Host, so I built on that. The uploading of the program has to come from the FPGA side. Once done, the FPGA re-boots the Cypress chip and then it starts implementing the USB function that has been programmed into it.

Hope it's a little clearer now. John

Reply to
John McGrath

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.