cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Explorer
Explorer
3,303 Views
Registered: ‎09-27-2013

petalinux including linux/interrupt.h

Jump to solution

I am just learning how to write interrupt handlers for fabric to processor interrupts (IRQ_F2P). I was trying to follow this example:

 

https://www.xilinx.com/support/answers/62363.html

 

The example source code has these kinds of includes:

 

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

 But I am unsure how to get these libraries included into my SDK project. I am getting "linux/module.h: No such file or directory".

 

I am doing my software programming using Xilinx SDK running on a Windows Host.

0 Kudos
Reply
1 Solution

Accepted Solutions
Observer
Observer
3,735 Views
Registered: ‎05-04-2017
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

These are all linux kernel includes which you would use if making a kernel driver. IMO it's not TOO tricky to make a very simple kernel driver since the boilerplate initialization code is done for you. See UG1144 on how to do this with petalinux (see section "Adding Custom Modules").

 

If you just want the headers you could download petalinux and "find . -name irq.h" in the source folder.

 

Best

View solution in original post

0 Kudos
Reply
9 Replies
3,261 Views
Registered: ‎04-20-2017
You mean in kernel space?

Are you sure that the Uio Framework will give you exactly the same with much less hassle?

I suppose the includes are burried in your sdk install folder. Have you searched it? I have been using /Linux includes from there (Sry don't have the exact paths at hand)
0 Kudos
Reply
Explorer
Explorer
3,248 Views
Registered: ‎09-27-2013

My app will be run in user space, but I'm not really sure if I need to do something special in kernel space. I just want to be able to write a user space linux c/c++ app that can respond to a IRQ_F2P interrupt in a high priority, asynchronous manner (just typical interrupt behavior). The IP module that is driving the IRQ_F2P is a custom IP, but I believe that I have modified the pl.dtsi file properly to achieve this (I added "interrupt-parent = < &gic >;" and "interrupts = < 0 61 4>;")

 

I'm not opposed to using UIO Framework. I'm just having trouble finding a good guide on how to do this, with C code example included.

 

I did search the sdk install folder, with no luck. If you do find the exact paths, let me know and I'll look again, or at least try to figure out why I don't have the same files.

0 Kudos
Reply
Observer
Observer
3,225 Views
Registered: ‎05-04-2017

If you create a new kernel module (driver) in petalinux it is initialized with example code that uses interrupts.

 

Also, you can take a look at code I wrote for the xilinx stream fifo IP block which uses interrupts:

https://github.com/jacobfeder/axisfifo

 

 

 

 

 

If you write a simple kernel driver for responding to interrupts, then you will need to figure out how to send signals to userland in response to the interrupt.

0 Kudos
Reply
3,194 Views
Registered: ‎04-20-2017

I am using under windows
..../Xilinx/SDK/2017.4/gnu/aarch32/nt/gcc-arm-linux-gnueabi/arm-linux-gnueabihf/libc/usr/include
.../Xilinx/SDK/2017.4/gnu/aarch32/nt/gcc-arm-linux-gnueabi/arm-linux-gnueabihf/include/c++/6.2.1

to include the headers...

the UIO framework is by magnitudes simpler to do (and esp to maintain) than doing your own kernel space IRQ handler...

steps are:
build driver into your petalinux (petalinux-config -c kernel -> drivers -> UIO -> uio_pdrv_genirq (the one with genirc irq handling

next: fiddle your device tree, so device node has compatible="generic-uio" and linux know to bind the uio driver to your device

open your device at /dev/uioX, map the memeory and use read / write calls to handle irq

you find more detailed info to each stept on myny posts in this forum

see eso chapter 4 here
https://www.osadl.org/fileadmin/dam/interface/docbook/howtos/uio-howto.pdf

or here starting slide 16 with code
https://elinux.org/images/b/b0/Uio080417celfelc08.pdf

and many more. that will give you exactly that you are looking for without much hassle

please accept solution if you find it is


0 Kudos
Reply
Explorer
Explorer
3,182 Views
Registered: ‎09-27-2013
I do have those directories, but I still can't find interrupt.h. Do you specifically have interrupt.h?
0 Kudos
Reply
3,169 Views
Registered: ‎04-20-2017
interrupt.h sounds more like its a kernel related source, I did not do any kernel driver development though. no its not there.

0 Kudos
Reply
Observer
Observer
3,736 Views
Registered: ‎05-04-2017
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

These are all linux kernel includes which you would use if making a kernel driver. IMO it's not TOO tricky to make a very simple kernel driver since the boilerplate initialization code is done for you. See UG1144 on how to do this with petalinux (see section "Adding Custom Modules").

 

If you just want the headers you could download petalinux and "find . -name irq.h" in the source folder.

 

Best

View solution in original post

0 Kudos
Reply
Contributor
Contributor
694 Views
Registered: ‎02-06-2019

I'm pretty new to the Vivado environments and I want to use interrupts for PL to PS DMA in Linux application, and I can find "/linux/interrupt.h" files in SDK also. 

Building Petalinux kernel module seems to overkill to develop an application. Is there any way faster than building petalinux every try? Because every petalinux building took 5 minutes at least. 

0 Kudos
Reply
Voyager
Voyager
681 Views
Registered: ‎08-02-2019

 

Hi @yasin.kagan,

1. If we are talking about user space level applications, it can be even user space level DMA driver.

I answered a similar question some days ago and it is marked as Solution.

You don't need to build petalinux for your every try. Instead you need to debug it by using Xilins SDK.

Same thing is possible for Petalinux and Bare Metal. 

About Petalinux you need an Ip Address(I prefer to set it static) and you need to check first connection, then you can easily Debug your applications similarly to PC softwares.  

You can follow instructions from that link.

2. About catching interrupts from PL side on Petalinux, I can recommend you to use a well-known userspace level driver, that located on git. I tested it it can perform 380MB/s dublex. If this speed is not enough for you, then kernel level driver sould be better solution for you. 

Because kernel level development can be painful as you mentioned.

 If you are new on Vivado e.t.c. I strongly recommend to you, using a DMA Reference Design. DMA is a really tricky development. Otherwise you need to invest really more time.

 

Saban

<------------------------------------------------------------------------------>

if(solves_problem) mark_as_solution <= 1 else if(helpful) Kudo <= Kudo + 1

<--- If reply is helpful, please feel free to give Kudos, and close if it answers your question --->