Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

Stream data from USB device to FPGA

Hi,

I have DE1-SoC dev board, which has the Cyclone V SoC device. The USB interface is connected with the HPS.

I want to stream data from USB to FPGA, I tried to map the FPGA address to the userspace using mmap() but this is causing the

Linux kernel to crash. I also tried to write a device driver for my FPGA component and write to the module file: /sys/bus/platform/driver/fpga_component

But this also fails and causes the kernel to crash.

I feel that this method is not reliable, some have suggested using DMA so that: USB <--> DMA <--> FPGA. But I am not sure how to realize this.

I read in the Cyclone V handbook that USB OTG is on the L3 Master Peripheral Switch, and HPS-to-FPGA is on L3 Main Switch. Table 4-2 Interconnect connectivity matrix

shows that there is a connection between USB OTG and HPS-to-FPGA bridge. I wonder how can I use that to transfer data from USB to my FPGA component.

If there is any useful resources for using utilizing that or if there is any good and robust method to transfer data between USB and FPGA please tell me.

Thanks.

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Linux has a USB system already built. It's mostly used for host mode, but there are several drivers to make linux into a USB device that will be visible to a PC etc. I don't know if linux has a driver for the SOC's USB core when operating as a device. Even if it doesn't, it would be easier to add that to the existing USB device mode framework than constructing something from scratch that doesn't crash Linux. A bonus is that DMA will work from the start. The HPS DMA core will be able to access any devices in the FPGA that the ARM can see. Make sure you have proper entries in the dtb file for your FPGA device(s).

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Galfonz,

    Actually I have a USB device that I connect to the HPS, and I want to stream data from that device to my FPGA component.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Device has a particular meaning in USB. It is something that normally connects to a USB host port on a PC/mac. For example keyboard, mouse, web-cam, printer etc. If this is what you have connected to HPS, you want ordinary host mode linux USB. If you are connecting HPS to a PC/mac USB host, then you need the setup I mention above. Find a Linux expert to help with USB aspects, then worry about the device driver for your FPGA component.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Siraj,

    I have attached one image here. Is that what you are trying? Are you trying to transfer some data from USB Mass storage device to FPGA?

    Warm Regards,

    Bhaumik