mithro / valentyusb

USB Full-Speed core written in migen/LiteX
BSD 3-Clause "New" or "Revised" License
17 stars 3 forks source link

Create special USB SETUP packet to wishbone thing #10

Closed mithro closed 5 years ago

mithro commented 5 years ago

@xobs came up with the idea of using Etherbone over the USB SETUP packets using a vendor extension.

mithro commented 5 years ago

@xobs can you dump some extra info here so I can implement it?

mithro commented 5 years ago

Maybe we should implement software emulation using tinyusb first and then I can do a hardware version?

xobs commented 5 years ago

That should work, unless you want to debug the CPU. It'll be a great way to prototype, though.

xobs commented 5 years ago

The basic idea is that we use a SETUP packet on EP0 to drive the communication.

We ought to be able to specify a bmRequestType with a Type of Vendor and a Recipient of Device. We then specify wLength of 8.

We can define some requests that we support:

bRequest = 0: Set/get address register
bRequest = 1: Set/get value
bRequest = 2: Set value + address

Ordinarily you'd write a value by doing a "Set value + address" request.

To read a value, you'd set the internal "address" register with a bRequest 0, then read the current register's contents with a bRequest 1.

If the top bit of bmRequestType is 1, then we read from the specified address. Otherwise we write to it.

Your state machine should look for a SETUP packet of c1 f0 00 00 00 00 04 00

xobs commented 5 years ago

This is done now!

mithro commented 5 years ago

Congratulations!

ewenmcneill commented 5 years ago

@xobs, sounds great that it's done.

Out of curiosity, where is the implementation? Last changes I can see on this repo seem to be 2018-12-23 (on master), and 2019-02-11 (on usb12), and the last commit I can see upstream is 2018-10-15.

Somewhere in https://github.com/xobs/valentyusb/commits/master maybe? Or in https://github.com/xobs/valentyusb/commits/wishbone-debug maybe? (Possibly we need an upstream that'll take merged in code like this? Maybe something in https://github.com/im-tomu/? Which AFAICT doesn't have a valentyusb repo at present...)

Anyway I'm curious how it got implemented / how it might be possible to use it :-)

Ewen

GitHub
xobs/valentyusb
USB Full-Speed core written in migen/LiteX. Contribute to xobs/valentyusb development by creating an account on GitHub.
GitHub
xobs/valentyusb
USB Full-Speed core written in migen/LiteX. Contribute to xobs/valentyusb development by creating an account on GitHub.
GitHub
I'm Tomu
Tim's Open Micro USB. I'm Tomu has 19 repositories available. Follow their code on GitHub.
xobs commented 5 years ago

Yes, it's in my github repo. I can create a repo in this organization and push it there. That would be most canonical.

I do need to document the protocol in the valentyusb repo somewhere. For now, the best documentation is at https://github.com/enjoy-digital/litex/blob/master/litex/tools/remote/comm_usb.py

GitHub
enjoy-digital/litex
Build your hardware, easily! Contribute to enjoy-digital/litex development by creating an account on GitHub.
ewenmcneill commented 5 years ago

Thanks for the pointers!

FWIW, this particular issue is on Mithro's personal GitHub account, hence my puzzlement about where to find the code, and the suggestion maybe to create an integration repo in the im-tomu organisation... :-)

Ewen

xobs commented 5 years ago

The repository is up now at https://github.com/im-tomu/valentyusb

GitHub
im-tomu/valentyusb
FPGA USB stack written in LiteX. Contribute to im-tomu/valentyusb development by creating an account on GitHub.