Interrupt timer managment

Hello,
I’m getting started with Colibri iMX7 + Aster.
I need to build a kernel module. Such module should implement a interrupt timer in order to simply toggling a GPIO.
This is pursued in order to test and measure (by an oscilloscope) the jitter in a Real Time enviroment,
when the thread are event driven.

There are some example in order to implement the Colibri iMX7 timer in an ISR?
Thanks

Hello @Edge,

Perhaps you have higher requirements, but ready to use LED class with GPIO LED and ledtrigger-timer should allow you to check jitter as well. All you need to do is device tree mod for selected pin. Then either specify “timer” trigger in DT or configure it at runtime via /sys/class/leds

https://developer.toradex.com/knowledge-base/gpio-linux

2 Likes

Hi @Edge,

Thanks for joining the Toradex Community :rocket:!

Could you please test @Edward’s suggestion by checking the article and the possibility of using timers? Would this fit your goal? To find more information on the triggers you could for instance check: common.txt « leds « bindings « devicetree « Documentation - linux-toradex.git - Linux kernel for Apalis and Colibri modules for the overall explanation on how to set your Device Tree with it.

In case this doesn’t help you reach your goal, could you please share with us the following information?

  • Which exact Colibri iMX7 version are you using?
  • Which exact Aster Carrier Board version are you using?
  • Which OS do you plan to have installed on your SoM?
  • Do you want to trigger the LED’s by inside an application or by using an external structure like a service?

This way we can better understand your goals and therefore support you.

And also, thanks Edward for helping :smiley:

1 Like

Thanks Edward and gclaudino.tx
I’m going to test the Edward’s suggestion finding to achieve a solution, I’ll let you know.
Here I answer to previous questions:

  • Colibri iMX7-1GB V1.1B
  • Aster c.b. V1.1B
  • Kernel 4.1.44-2.7.4 - armv7l GNU/Linux
  • I want to trigger a GPIO inside a kernel module (driver)

Looking forward from you
thanks

Being new on this machine, I apologize if I post basic questions but meanwhile I was reading about tree device customization I can’t find the folder with the dts location
in particular I find nowhere the “arch/arm/boot/dts/” path
…I’m a little bit disoriented.
Could you give me some hints, please?

Hi @Edge!

Thanks for the update. As we discussed by e-mail, it would be better if we knew exactly which image is running on your module. With the kernel information, I’d suppose you’re using BSP 3.0 which is a bit old (Embedded Linux Release Matrix | Toradex Developer Center).

Are you trying to find this on your local machine, right?

Hi @gclaudino.tx
First of all, I inform you that I’m using the Linux image v.2.8 with LXDE(last rev)
and I need to use this version.
Regarding my previous question I’m sorry I didn’t yet downloaded the source kernel image, well
I tought to done it but I realized that was the binary image from

meanwhile I discover the source is located on GIT

so I tried to clone the rep:
git clone -b toradex_4.9-2.3.x-imx git://git.toradex.com/linux-toradex.git

but after counting, compressing and retrieving it failed with this log:

Cloning into 'linux-toradex'...
remote: Counting objects: 10266281, done.
remote: Compressing objects: 100% (1558845/1558845), done.
remote: Total 10266281 (delta 8706184), reused 10206063 (delta 8647356)
Receiving objects: 100% (10266281/10266281), 2.06 GiB | 3.29 MiB/s, done.
error: index-pack died of signal 906184)   
fatal: index-pack failed

I don’t understand. What is wrong?

Hi @Edge,

Thanks for the update.

Is there a specific need for you to use this version? I.e., an older project that was built using it?

This seems to be that a SIGKILL was sent to the git process (console - Git Clone error: index-pack died of signal 9 - Stack Overflow). Are you running it inside a VM or something like that? Which image runs on your host OS?

I tried it on my computer and it worked.

Best regards,

1 Like

I have to work on a pre-existent project and based on that image indeed.
Regarding the git clone yes I use a VM xubuntu 16.4but the current space occupied is 8,9 G against 68G of virtual available size
But I tried to clone from windows GIT locally (followinf in case by an scp on the VM) and it give me again an error:

Cloning into 'linux-toradex'...
remote: Counting objects: 10266281, done.
remote: Compressing objects: 100% (1558845/1558845), done.
Receiving objects: 100% (10266281/10266281), 2.06 GiB | 3.35 MiB/s, done.
remote: Total 10266281 (delta 8706183), reused 10206064 (delta 8647356)
Resolving deltas: 100% (8706183/8706183), done.
error: invalid path 'drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

solved!..I intended there it would be a problem of space memory…but the article was intending RAM memory… indeed now it worked. Thanks

1 Like

Hi @Edge, glad to hear that the git clone is working now. Please keep us updated about your next steps and or blocking points to enable the interrupt timer.

Hello Edward,
thanks for your support. I guess you already worked on it.
I was working around this topic. Beside the toggling led purpose I will need to manage a timer…
Toggling a GPIO is an example but I would be integrate more later actions.
However I am stuck on this point. I suppost the GPT timer should suite fine…
but is all pretty new this enviroment and so far I didn’t get my goal
Do you have some example or indications about?
Thanks in advance

Hello Edge

In first thread message you wrote this

I believe interrupt jitter in your driver will be the same, no matter is it external event caught by GPIO interrupt or timer interrupt jitter. This is why I suggested you not write driver at all and instead use existing GPIO LED trigger (either timer trigger or external GPIO interrupt trigger) and measure your jitter.
No advice regarding driver writing, sorry.

I turn back on this point because altough I 'm being finnaly handled (thansk to Edward suggestions) the GPIO now I would like to interact with a timer event reference.
I’m not sure that a ledtrigger would aim to achieve that goal.
Let me explain:
My goal would be write a piece of code running into a routine which is called every tick timer = 122us
Once it is running as a task in high priority mode I would measure the jitter which is hormally introduced by the operating system scheduler.
Indeed the code has to elaborate a real-time datastream and perform all calculations within that time slot.
That’s the matter. I need to know the maximum jitter error.
The computing power of A7 suggests me that it should be possible… but before move in this direction (which imply a new design and semplification of my current hardware) I must be sure that it can be feasible.
How can I do it? How to manage an interrupt timer routine?
Thank you in advance

Hi @Edge,

Is it your first attempt to try something real timed on Linux? I wonder because of so tiny target time slot. Interrupt jitter on Linux is orders of magnitude worse than your aim. Why not to measure it the “leg” of simple blinking GPIO LED. Kernel LED class uses timer interrupt to toggle LED on and off. Why not triggering your scope from rising GPIO edge and figuring the jitter of falling edge? Interrupt jitter depends on all other ISR’s from numerous Linux kernel drivers and should be similar in all cases.

The computing power on Linux is dropping quickly at high interrupt rate. 1kHz is fine, but >10kHz is likely to make all computing power disappear. That’s not far from your 1/122us.

For real time needs you should definitely use Cortex-M4 available on your iMX7.

1 Like

Hi @Edge, how are you?

Do you have any news on this topic? Have you been able to look Edward’s suggestion?

Best regards,

Yes, I moved to M4 for such goal

1 Like