FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
6124 Discussions

How to setup a time interrupt on de10 standard using C language

CAlex
New Contributor II
5,928 Views

Hi, I'm a rookie of the SoCFPGA and I wanted to use it to build a FSM in HPS.
I have already finished building the system design as "User Manu" said and get the hps_0.h header file out.
I built my system based on the GHRD, and added a timer(100ms) using the Altera IP.
Now I want to play with it,yet there are little information about a timer or an interrupt working on SOC.
The board I'm using is a DE10-standard board.
Could anyone show me where to start?
And it will be better if you can provide a document/example on how to play with the Altera IP on C.
Thank you for your help.

0 Kudos
36 Replies
JingyangTeh
Employee
1,894 Views

Hi Alex


What do you mean the KML?

Could you explain more what error you got or what you are trying to achive?


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
1,885 Views

Hi,

My bad,

I mean I'm trying to use <linux/interrupt.h> but it seems can't call in user space code. I supposed to be done in Linux Kernel module.

So I want to use the kernel source code to compile my kernel module.

What I need for the compile is the kernel source code supposed located on /usr/src/$(uname -r). 

Yet it is empty, so I download the Kernel source code and make it as zImage as my embedded system did.

 

What I want to know is that is there an easier way to compile the KML(I mean kernel module)?

Or can <linux/interrupt.h> can be used on user space code?

 

reguards.

0 Kudos
CAlex
New Contributor II
1,879 Views

And what I really confused is that I wrote my own IP device on FPGA, in order to use it in kernel module(basicly it only sends out the interrupt signal to irq_0 every 50 us), what should I do? 

Do I need to update the Device Tree and refresh the u-boot?

Do I need to write my own driver for my timer IP?

What should I treat this IP, is it a device_platform?

How to communicate with my user space code. make a char device? Use /proc? Or is there a easy way that can achieve the goal: To tell the userspace it is the time to go.

 

 

Sorry for so many questions.

 

reguards.

 

0 Kudos
JingyangTeh
Employee
1,851 Views

Hi Alex


Sorry for the confusion.

We could not register a call back directly from hardware.

You would need to create your own kernel driver to send a signal your user application.

In the user application you would wait for the signal from the kernel to handle.

Below are some useful links regarding this :


https://embetronicx.com/tutorials/linux/device-drivers/linux-device-driver-tutorial-part-13-interrupt-example-program-in-linux-kernel/


https://man7.org/linux/man-pages/man7/signal.7.html


Regards

Jingyang, Teh


0 Kudos
JingyangTeh
Employee
1,827 Views

Hi Alex


Any update on this case?


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
1,818 Views

Hi,

 

Yes, I wrote a kernel module to create an interrupt request.(which should be irq 73)

But I can't insmod the module for stack overflow.

Then I checked the other GIC turtour and it turns to be 72+personal_irq_num-32 = 41.

And when I checked the /proc/interrupt, there is an irq already. I assume it's duel to the DTB setting.

 

Now I wonder is that means I have to update the DTB file for my linux?

 

Thank you for all your help by the way.

Having a nice day

 

Reguards.

0 Kudos
JingyangTeh
Employee
1,786 Views

HI Alex


Could you try the GIC number 75?

From your design in previous case. Your interrupt is connected to f2h_iirq0 number 3.

From the GIC table, it should be 75.

https://www.intel.com/content/www/us/en/docs/programmable/683126/21-2/gic-interrupt-map-for-the-soc-hps.html


Regards

Jingyang, Teh



0 Kudos
CAlex
New Contributor II
1,769 Views

Hi,

when I use 75 as the number in my kernel module,

the insmod failed

insmod: ERROR: could not insert module p3.ko: Invalid parameters

duel to request_irq()

 

Reguards.

0 Kudos
CAlex
New Contributor II
1,767 Views

Hi,

to make sure we are on the same page,

I attached the kernel module for anyone else want to see what happened on this case.

 

Reguards.

0 Kudos
CAlex
New Contributor II
1,758 Views

The return Error is -22

Which indicate handler is NULL(checked) or IRQ can't be used.

And when I checked the /proc/interrupts , the result is as followed:

CAlex_0-1681215733100.png

 

But as the DTB on my board shows,there should be at least 3 FPGA interrupts.

When I use linux module to install the irq, it is not relay on DTB right?

 

0 Kudos
JingyangTeh
Employee
1,683 Views

Hi


Could you try adding the timer into the linux device tree?

I am not quite familiar with linux device tree, but could you try the following:


timer4@FF200000 {

compatible = "snps,dw-apb-timer";

interrupts = <0x0 0x6B 0x4>;

reg = <0xFF200000 0x1F>;

clocks = <0x38>;

};


Regards

Jingyang, Teh


0 Kudos
JingyangTeh
Employee
1,652 Views

Hi Alex


Did you manage to test out the suggested changes?


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
1,651 Views

Hi,

I'm a little busy on other things right now,

please give me a couple of days.

Reguards.

0 Kudos
JingyangTeh
Employee
1,594 Views

Hi Alex


Did you managed to test out the device tree?


Regards

Jingyang, Teh


0 Kudos
JingyangTeh
Employee
1,559 Views

Hi Alex


Do you still need some extra time for this case?


Regards

Jingyang, Teh


0 Kudos
JingyangTeh
Employee
1,532 Views

Hi


Since there are no feedback for this thread, I shall set this thread to close pending. Please login to ‘https://supporttickets.intel.com’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.


If you happened to close this thread you might receive a survey. If you think you would rank your support experience less than 10 out of 10, please allow me to correct it before closing or if the problem can’t be corrected, please let me know the cause so that I may improve your future service experience.


Regards

Jingyang, Teh


0 Kudos
Reply