FPGA inputs directly from Linux on the snickerdoodle

286 views
Skip to first unread message

Kfeeeee

unread,
Feb 14, 2018, 7:27:34 AM2/14/18
to snickerdoodle forum
Hi all,

I am very new to the whole topic of FPGAs and HDL but thought the snickerdoodle is a nice board to start playing around a bit.

So here is a quick question: Is there any way to directly send input bits to the fpga from Ubuntu running on the snickerdoodle ?

I was thinking about a simple script randomly generating bits that shall be evaluated on the fpga side and then send back to the host to be prompted...just for practicing.

I think I need something like UART is this correct? I would be glad if someone could clear this up a little bit. thank you.

weath...@krtkl.com

unread,
Feb 14, 2018, 4:41:49 PM2/14/18
to krtkl-sni...@googlegroups.com
Hi Kfeeeee,

The official way that the ARM processors running linux and the FPGA are connected is via multiple high performance AXI bus interfaces. 
This is a relatively advanced topic from the perspective of Linux though because Linux is a protected operating system and there are complicated mechanisms that need to be employed to directly access the internal AXI bus interfaces from the Linux user space due to operating system permissions and virtual memory organization.

If you are just starting out and just want to have some simple interactions with the FPGA like flipping bits on and off that are connected to some logic you've put in the FPGA I recommend utilizing the built in Zynq GPIO peripheral hooked up via EMIO (internal I/O connections to FPGA).  This is basically a set of GPIO "pins" that you can wire internal in the chip to the FPGA.  It's not going to provide massive performance like you would need to move around video frames but it will get you started with something without needing to write Linux device drivers or get into the nitty gritty of dealing with memory mapped peripherals etc. 

You can actually do a very similar thing with the built in SPI peripherals if that meets your requirements.  They already have Linux device drivers and you can internally connect them to the FPGA and utilize the existing Linux device drivers.

Below I am attaching an image in the Vivado block diagram that shows what this looks like.

My colleague, Bush can provide some additional information regarding where in the linux /dev filesystem these ports appear.

-Jamil





Auto Generated Inline Image 1
Auto Generated Inline Image 2
Auto Generated Inline Image 3

johannes....@gmail.com

unread,
Feb 15, 2018, 11:37:08 AM2/15/18
to snickerdoodle forum
Hi Jamil,

Thank you very much for your fast and detailed response.I think I will try your suggested way of utilizing SPI. Thanks again!

Kfeeeee

Bush

unread,
Feb 16, 2018, 2:10:15 AM2/16/18
to snickerdoodle forum
This is an example project I created with SPI0 connected to FPGA pins using the EMIO: https://github.com/krtkl/sdspi

It uses a single chip select pin and has the following pin constraints:

set_property PACKAGE_PIN E18 [get_ports SPI0_MISO_I];           # JA1.5
set_property PACKAGE_PIN D20 [get_ports SPI0_MOSI_O];           # JA1.6
set_property PACKAGE_PIN E19 [get_ports SPI0_SCLK_O];           # JA1.7
set_property PACKAGE_PIN D19 [get_ports SPI0_SS_O];             # JA1.8


There is a bootloader that you can copy into your SD card to enable the SPI peripheral and load the bitstream that routes the port pins in the repo subdirectory sdspi.sdk/fsbl/bootimage. There is also a devicetree that can be copied to the SD card which should give you a /dev/spiXXX device that can be used for reading/writing. I added a small Linux application that demonstrated the device transfer calls and provides a way to test the peripheral. You can call the Linux application with the name of the device file (you will need root permissions) followed by up to 4 space-delimited hex-formatted bytes:

snickerdoodle@snickerdoodle:~$ sudo ./spitest /dev/spidev-0 aa 55 aa 55

Let me know if this helps you get started.

johannes....@gmail.com

unread,
Feb 17, 2018, 12:06:56 PM2/17/18
to snickerdoodle forum
Hi Bush,

Thank you so much for the detailed project that was of much help!!!

Best regards

johannes....@gmail.com

unread,
Mar 15, 2018, 6:48:34 AM3/15/18
to snickerdoodle forum
Hi Bush,
Could you please elaborate a little more on how you have created the working devictree and how the blob is then further used to make the SPI useable?
I am somehow stuck now - sorry for my silly questions -.-
kfeeeeee


Am Freitag, 16. Februar 2018 08:10:15 UTC+1 schrieb Bush:

johannes....@gmail.com

unread,
Mar 15, 2018, 9:53:57 AM3/15/18
to snickerdoodle forum
Soory for writing .. again.
Forgot to say that I am on a Prime LE  there it does not seem to work (I changed the board in vivado and regenerated the bitstream). MISO always returns 0x00.
Reply all
Reply to author
Forward
0 new messages