timvideos / HDMI2USB-fx2-firmware

HDMI2USB firmware for the Cypress FX2 found on the Digilent Atlys and Numato Opsis boards.
24 stars 11 forks source link

WIP: Migration from fx2lib to whitequark's libfx2 #47

Closed mithro closed 4 years ago

todo[bot] commented 5 years ago

remove when fx2regs.h from libfx2 will be used in this file

https://github.com/timvideos/HDMI2USB-fx2-firmware/blob/d3c2b7df6bbf357dde50bc6b60f09ba7a7a11ec2/hdmi2usb/firmware.c#L37-L42


This comment was generated by todo based on a TODO comment in d3c2b7df6bbf357dde50bc6b60f09ba7a7a11ec2 in #47. cc @antmicro.
todo[bot] commented 5 years ago

remove when eputils.h have been ported

https://github.com/timvideos/HDMI2USB-fx2-firmware/blob/d3c2b7df6bbf357dde50bc6b60f09ba7a7a11ec2/hdmi2usb/uvc.c#L20-L25


This comment was generated by todo based on a TODO comment in d3c2b7df6bbf357dde50bc6b60f09ba7a7a11ec2 in #47. cc @antmicro.
todo[bot] commented 4 years ago

check size, should be 0x50+1 (as in previous code + 1 byte added to processing unit)

https://github.com/timvideos/HDMI2USB-fx2-firmware/blob/8823d01537bafa52565200fae5e5b2170e5fdf2b/cdc/descriptors.c#L365-L370


This comment was generated by todo based on a TODO comment in 8823d01537bafa52565200fae5e5b2170e5fdf2b in #47. cc @antmicro.
todo[bot] commented 4 years ago

change CDC endpoint 6

https://github.com/timvideos/HDMI2USB-fx2-firmware/blob/8823d01537bafa52565200fae5e5b2170e5fdf2b/cdc/descriptors.c#L393-L398


This comment was generated by todo based on a TODO comment in 8823d01537bafa52565200fae5e5b2170e5fdf2b in #47. cc @antmicro.
jedrzejboczar commented 4 years ago

This is a version of FX2 firmware ported to use libfx2 instead of fx2lib.

Firmware enumerates as a device supporting CDC, UVC and UAC. Communication with FPGA goes through slave FIFO interface and the Glasgow Migen FX2 crossbar.

FPGA's DNA being published using USB device serial number. FPGA sends DNA marked with a special non-ASCII starting byte through CDC IN endpoint FIFO. FX2 inspects the data in the buffer and re-enumerates with modified serial number.

NOTE: this PR requires libfx2 modification to be able to modify serial number: whitequark/libfx2#3

It is still WIP, because crossbar supports only 2 OUT and 2 IN FIFOs, and we need 3 OUT FIFOs and one IN, so the crossbar has to be further modified.

mithro commented 4 years ago

Hi @jedrzejboczar,

Could we split this pull request into one pull request for each of the firmwares / demos?

I would like seperate demos for;

Thanks,

Tim @mithro Ansell

jedrzejboczar commented 4 years ago

Sure, I'll split this into separate pull requests.

Some questions:

mithro commented 4 years ago

On Wed, Dec 4, 2019, 1:44 AM Jędrzej Boczar notifications@github.com wrote:

Sure, I'll split this into separate pull requests.

Each demo should be a seperate pull request.

One for each type of serial listed below. One for audio. One for video. One for DFU. One for the fx2crossbar demo. One for the combined HDMI2USB firmware, etc.

The current pull requests are to big to review easily.

Some questions:

-

What do you mean by demo for interfacing to fx2crossbar? I ask because audio, video and serial use fx2crossbar for interfacing with FPGA. Do we want a demo/example of just the FX2 configuration for fx2crossbar interface? Should the audio/video/serial demos be just device enumeration examples with no actual FPGA interface, or rather complete firmwares on their own?

Correct. The audio / video "demos" should work on any FX2 board without an FPGA connected. They are basically examples of how to do such a USB device with the FX2 and should be candidates for sending upstream into libfx2 in the future.

They should also work on the FX2 emulator that you are working on without needing anything special.

For serial it is a little more complicated, the options are; A) Serial just using software internal loopback - no external hardware. B) Serial using bitbanging IO - should work with any device connected to the correct pins (including FPGA). C) Serial using hard UART - should work with any device connected to the correct pins (including FPGA). D) Serial using fx2crossbar on an FPGA.

Ideally there should be demo gateware which works with the demos in B, C, D. Something like seeing the LiteX BIOS would be fine.

There should also be a seperate demo for the fx2crossbar which doesn't enumerate as any specific device but just as a high speed FIFO that can be used with a python libusb script to send data quickly.

Ideally, all the demos should have the option to plug in a module which patches the serial number with the device DNA number from the FPGA.

-

Do we want DFU capability in HDMI2USB firmware (shouldn't be difficult to achieve) or we are fine using a separate DFU firmware and just a Makefile target that will load that DFU firmare into RAM and then just flash the actual firmware?

We do want to add the DFU firmware to the HDMI2USB firmware but it is a little complicated.

The DFU firmware should provide multiple interfaces which do the following; A) Flash FX2 firmware into the fx2 eeprom B) Load a bitstream onto the FPGA RAM C) Flash FPGA bitstream and associated stuff onto the SPI flash through the FPGA.

See how the ECP5 badge from HackADay works. Talk to tnt on IRC for help around multiple DFU interfaces.

To do (C) you will have to first load an FPGA image called a "SPI flash proxy".

Ideally, (B) would be the default interface. The (C) would only appear if the SPI flash proxy has been loaded. (A) would only appear in some type of special situations - flashing the FX2 firmware is rarely done and you don't want it to happen accidentally.

There may not be enough code space to support the DFU functionality with all the other features. In that case we can just make it a seperate firmware that also has serial port support.

Does that make sense?

jedrzejboczar commented 4 years ago

Thanks, it cleared everything up.

Just to make sure I understand crossbar demo correctly - FX2 will just enumerate with vendor-specific interface and we will send raw data to its endpoints, right?

mithro commented 4 years ago

Just to make sure I understand crossbar demo correctly - FX2 will just enumerate with vendor-specific interface and we will send raw data to its endpoints, right?

Yes.

jedrzejboczar commented 4 years ago

I've created pull request for audio and video examples in antmicro/HDMI2USB-fx2-firmware, so that it is easier to review, as only the changes relative to libfx2-migration branch are visible.

The pull requests are:

The main question is about the code structure. As described in https://github.com/antmicro/HDMI2USB-fx2-firmware/pull/1, I wonder if this approach is ok, or should we require more code from the user side, as this is most probably not flexible enough for merging into libfx2.

mithro commented 4 years ago

I believe this is obsolete now, right?