alvieboy

USB controller / wing

39 posts in this topic

So,

 

Back a while ago I ordered some USB wings to play with, with just an USB 1.1 transceiver (TUSB1106PWR). Easy to solder. Only supports 12Mbit though, but the advantage is you can fit everything on a 8-bit wing.

 

Jack actually did a demo of the PCB as an example for the 3D brd Viewer a while ago (you can watch it here:

).

 

Since the transceiver is not actually a PHY, I've used a PHY from Opencores [1], with only some small modifications so I could use 96MHz as clock instead of the usual 48/60MHz. This PHY presents a UTMI interface which allows me to switch to a hard PHY in the future with minimal modifications.

 

I then needed a packet decoder of some sort. I used [2] also from Opencores, and translated it (the packet decoder only) to VHDL (original is Verilog). This helps decode the PID from USB packets and perform CRC checks.

 

Still a lot to go though.

 

I then wrote a packet engine, that understands all important USB transactions, implements endpoint buffers and endpoint configuration. This took me a while, and required me to understand almost all of USB1.1 (with exception of hub transfers). Learned a lot. This packet engine is tied to a wishbone interface that goes directly into a ZPUino slot, so it can be controlled.

 

All upper layer (descriptors, data transfer, so on) are handed in software, as typical microcontrollers do.

 

Right now it works! The device can be enumerated, in Windows and Linux, and things look promising for the next days:

[1547151.706742] usb 2-1.5: new full-speed USB device number 74 using ehci-pci[1547151.801847] usb 2-1.5: New USB device found, idVendor=efbe, idProduct=adde[1547151.801853] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3[1547151.801856] usb 2-1.5: Product: USB Wing[1547151.801859] usb 2-1.5: Manufacturer: Alvie[1547151.801861] usb 2-1.5: SerialNumber: Rev 1.0[1547151.802582] cdc_acm 2-1.5:1.0: ttyACM0: USB ACM device

Still needs a proper PID/VID though :)

Another test was to present it as a CDC device, so we could use it as a serial port. Things are looking great too in that area, should be fully working tomorrow after some software changes. Lots of interrupts going on.

I'll keep you posted :)

 

Alvie

 

[1] http://opencores.org/project,usb11_phy_translation

[2] http://opencores.org/project,usb1_funct

 

Share this post


Link to post
Share on other sites

Ok, let's do something a bit more interesting.

 

Can you give me a couple of use-cases you'd like implemented for USB ? The idea is to test the robustness of the system (and its performance).

 

Remember we only have 12Mbit, which gives an unidirectional speed of about 8Mbit (half of that if bi-directional).

 

Some use cases that come to mind, as examples:

 

- Add SD card, use USB to present SD card as a generic block device.

- Add Wii Chuck wing, present as Mouse :)

- Add virtual filesystem with a single file, use it as Flash for main SPI (like, open the device in windows, drop the bitfile, that's all - you just reprogrammed the FPGA :P )

- Same as above for sketches: drop a bin file, it will reprogram the sketch only.

 

No audio/video for now, please. That will force me to implement the complex isochronous endpoints :P

 

Alvie

Share this post


Link to post
Share on other sites

Man,

 

This has my head spinning... Could we have it work so that you plug in the Papilio and a serial port and a USB drive show up at the same time? The USB drive would have the software you need to use the Papilio, like Papilio Loader and drivers, or the Logic Analyzer client...

 

Or how about copying a bit file to the USB drive and it programs the FPGA?

 

Jack.

Share this post


Link to post
Share on other sites

 

Or how about copying a bit file to the USB drive and it programs the FPGA?

That's what I meant by "Add virtual filesystem with a single file, use it as Flash for main SPI".

So, yes :) Will be a cool, novel feature :)

Share this post


Link to post
Share on other sites

all the virtual drive solutions i have ever seen similar to this (mostly based from LUFA now that i think about it..) have very limited space.  

 

enough for a config file, but thats about it.

 

it will be interesting to see what you come up with 

Share this post


Link to post
Share on other sites

Images often speak for themselves.

 

pprowindows.png

 

I had to manually assign the MTP driver in Windows, but otherwise things are looking great.

 

Alvie

Share this post


Link to post
Share on other sites

Ok, I just assembled and tested 5 boards (I had ordered components for 10 of them). The assembly is for USB device, but they can be reworked for USB host if needed (although we don't have any controller for it yet). These boards are transceivers, and support FS only (12Mbit/s). The bottom silkscreen is also wrong, but does not impact functiality. All boards have been hand assembled by me.

 

I don't need all those boards, so I'll be selling them for a symbolic cost (USD$9) plus packaging+śhipping (not yet sure about how much it will be, will have to dispatch those from UK).

 

Let me know if you want one for your experiences.

 

I'll post some pics of the boards later today (I just realised I did not photograph them yet). Oh, yes, and PCB+śchematics too. And ZPUino code. :)

 

Alvie

 

(edit: fix "FS")

Share this post


Link to post
Share on other sites

i will take one if you don't mind shipping it to Germany.  just pm me your paypal and total cost. //F

Share this post


Link to post
Share on other sites

Ok, here's an example sketch that allows you to expose the FPGA firmware in SPI flash to PC.

#include "mtp.h"
#include "spiflash.h"

using namespace ZPUino;

static SPIFlash_class SPIFlash;

class MyMTP: public MTPUSBDevice_class
{
protected:

    int getNumHandles()
    {
        return 1;
    }

    const char *getFilename(int object)
    {
        return "spartan6.bin";
    }

    const char *getTimeCreated(int object)
    {
        return "20160101T000000Z";
    }

    const char *getTimeModified(int object)
    {
        return "20160101T000000Z";
    }

    unsigned getFilesize(int object)
    {
        return 340884;
    }

    void readObject(unsigned object, uint8_t *target)
    {
        SPIFlash.read( 0x0, target, getFilesize(object));
    }
};

static MyMTP MTPUSBDevice;

void setup()
{
    Serial.begin(115200);
    MTPUSBDevice.begin();
    SPIFlash.begin();
}

void loop()
{
    delay(100);
}

Still working on flashing a new bitfile, dual-bitfile support and other goodies/examples.

Alvie

Share this post


Link to post
Share on other sites

Heh... you won't believe about next one, once I get it working (not USB blocking the actual demo though). Let me say just that it may include a lens. :P

:)

Share this post


Link to post
Share on other sites

I'm awful at demos....

 


What is going on on that video ?

1- am connecting to Papilio Pro FTDI serial port (COM4), as usual.

2- Resetting the FPGA, using the BREAK.

3- Pressing ENTER twice, so twice magic happens....

4- Connecting the USB wing to Windows (on this case, through virtualbox)

5- Opening the device....

6- Yes, that's me, live :P JPEG compression done with ZPUino, pure software. RAW image also available (600K size) - look at how much time it takes to transfer it :P

Was not able yet to get notifications to work, so if I capture more images, windows does not refresh the list. Will look at that with more detail on next few days.

 

Alvie

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now