Sorry, you need to enable JavaScript to visit this website.

Communication between Linux and FPGA

Unsolved
7 posts / 0 new
sticken's picture
sticken
Junior(0)
Communication between Linux and FPGA

Hello everybody! I followed zynqgeek's useful tutorial on how to create custom peripheral using PL and to communicate using a bare metal application. Now I'm trying to do something more, like creating a linux application to read/write the registers in the peripheral. My questions are:

1) I'd like to use mmap to map the device into user space, such that is possible to read and write data. Is this correct?

2) Assuming point 1 is ok, is possible to send an interrupt from FPGA to Linux application to inform that some data are available?

3) Do I have to create a Bare Metal application able to communicate to Linux app? If yes, how can the communication be established? If no, I think that can be used mmap + interrupt..

4) Finally I'd like to run the application after the kernel has been loaded. Should I include u-boot.elf during the creation of BOOT.BIN? I tried to include "system.bit", "my_application.elf" and "zynq_fsbl_0.elf", but it seems that Linux is not loaded..

Waiting for your answers!!

Thank you,

sticken

m.russell's picture
m.russell
Junior(0)
Hi

Hi

1. It is OK to use mmap, but the recommended procedure is to write a device driver for your peripheral. Chapter 9 of UG873 (link below) has a basic example of how to do this. Whilst this does not go into a tutorial on how to write a driver, they do provide an example.

2. I haven't tried this myself, but in the same guide (Chapter 6) Xilinx give an example of a CDMA which generates an interrupt after it has finished transferring data which may be similar to what you need to do. I am not sure what other steps you would need to do to make your own interrupt.

3. You do not need to create a Bare Metal application to talk to Linux.

4. The easiest way to run a program immediately after the kernel has been fully loaded and configured is to add a call to your program in the startup script. ZynqGeek has a blog post on how to do this (link below).
If you are booting from SD Card this requires a new BOOT.bin file with the FSBL, system.bit and u-boot.elf in that order.

UG873:
http://www.xilinx.com/support/documentation/sw_manuals/xilinx14_3/ug873-...

ZynqGeek's blog post:
http://zedboard.org/content/zedboard-modifying-your-ram-disk-image

Hope that helps
Matthew

sticken's picture
sticken
Junior(0)
Hello

Hi Matthew,

thank you for your answer. I'll read those documents as soon as possible.
I found this: http://forums.xilinx.com/t5/7-Series-FPGAs/Problems-configuring-PL-gener...

and I'm trying to follow those steps to manage interrupts. Non I'm able to add an external port which is used to raise an interrupt request and to interconnect my custom component to a interrupt controller which is connected to processing_system. Next step will be the implementation of interrupt handler using Linux.

Point 4: Do I have to add "my_application.elf" to generate BOOT.BIN? I think so..

Thank you,

sticken

m.russell's picture
m.russell
Junior(0)
Hi again

Hi again

I'm glad you found something useful about the interrupts. u-boot.elf is used to boot Linux, so this should be the last item in BOOT.bin. The only reason you would want to add your application to BOOT.bin instead of u-boot would be if you didn't want Linux. Once Linux boots it runs the startup script which you can edit to launch one of your own programs, like ZynqGeek does in the blog.

Matthew

sticken's picture
sticken
Junior(0)
Maybe I miss a piece..

I thought it was passible to run Linux AND a bare metal application by creating BOOT.BIN from u-boot.elf, my_app.elf, fsbl.elf and sys.bit. Am I wrong?

sticken's picture
sticken
Junior(0)
Ok, no problem

I tried to create BOOT.BIN with:

- fsbl.elf
- sys.bit (containing PS + simple_register as ZynqGeek did)
- u_boot.elf

but Linux doesn't boot..can someone provide me useful links/steps to solve this issue?

madcow's picture
madcow
Junior(0)
Can you be more verbose?

Can you be more verbose?

Do you get an error? Is the FPGA fully programmed? (blue LED lights up)