Xenomai on Freescale i.MX21 (ARM926J)
Hi Philippe,
Any chance to see our work integrated within an official distribution?
Are you still reviewing the code?
Thanks for your feedback
Daniel
Quoted 146 lines
-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part de ROSSIER Daniel
Envoyé : mardi, 25. avril 2006 15:17
À : Philippe Gerum
Cc : [email protected]
Objet : RE: [Xenomai-core] Xenomai on Freescale i.MX21 (ARM926J)Quoted 7 lines
-----Message d'origine-----
De : Philippe Gerum [mailto:[email protected]]
Envoyé : jeudi, 20. avril 2006 15:43
À : ROSSIER Daniel
Cc : [email protected]
Objet : Re: [Xenomai-core] Xenomai on Freescale i.MX21 (ARM926J)Quoted 11 lines
Quoted 4 lines · ROSSIER Daniel
Dear all,
We finally succeeded in the port of Xenomai on our Freescale i.MX21
board (ARM-926J);
Quoted 1 line
(The board used is the CSB535FS issued from Cogent with the BSP from
Microcross)
Quoted 2 lines
To have further technical references, please see there:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=i.MX_LITEKI
Quoted 6 lines
T&parentCode=i.MX21&nodeId=0162468rH31143ZrDR
Quoted 2 lines
So, you will find two patches: the first one (patch-linux-
2.6.14.imx21_1.0.0) is used to patch the Linux 2.6.14 for supporting the board. Then, the second one (adeos-ipipe-2.6.14-arm-imx21-0.1.00.patch) can be used against the imx21-enabled kernel for Xenomai, simply using
the
Quoted 4 lines
prepare-kernel.shscript. The patch was originally inspired from the Integrator/ARM11 patch; thanks to its author :-)Quoted 2 lines
We will publish soon some results regarding the different latencies,
but
Quoted 2 lines
so far we measured about 2us between the IRQ and the timer reprogramming (at the ipipe level). The problem now is the jitter which is pretty
high:
Quoted 2 lines
about 1-2us, with some occasional peaks up to 5us.
Quoted 1 line
Having quite a few experience with this kind of board, we don't know
if
Quoted 15 lines
it comes from the code itself, or purely from the hardware. Any idea/suggestions would be welcome. For periodic tasks around 20us, everything works perfecly.
Quoted 1 line
Those results are pretty impressive actually. Assuming that you compare those figures with those obtained from traditional standalone RTOS e.g. VxWorks on the same board, the critical difference with Xenomai is that Linux is competing for the hw resources, and for instance, happily trashes the cache under Xenomai's feet when scheduling its own tasks during Xeno's idle time. Additionally, Adeos adds a small overhead due to the interrupt virtualization, in exchange of real-time predictability for their delivery. Therefore, in this respect, 5 us does not look that bad already.
Quoted 4 lines
Are 20 us a measure of the worst-case interrupt latency (i.e. running latency -t2), or scheduling latency in user-space (i.e. running latency -t0)?
No, I think we can go lower; the measure we actually got between the IRQ and the timer reprogramming is about 2 us with some jitters up to 5 us; we could
normally guarantee not to exceed 5 us between the IRQ and timer reprogramming. Now, considering the ISR itself, we could get some time under 10us provided that the ISR remains short.So far, we measured the reaction time with the oscillo; we are now about to check the latencies with the latency utility from Xenomai.
Quoted 1 line
Quoted 1 line
I don't know to what extent this (1 or 2) patch(es) can be integrated
in
Quoted 7 lines
the official distribution;
but of course we are willing to make any adaptations to fulfill the requirements for that.For the technical part, I guess that anyone interested in the ARM support for Adeos/Xenomai will review this code; I'll be one of these people, for sure. The usefulness of such contribution looks obvious to
me.
Quoted 9 lines
For the non-technical part, a pre-requisite for adding code to the Adeos or Xenomai codebases is to properly identify it as coming from a legitimate source, so if you, as a submitter, can confirm that you may freely contribute it on behalf of the HEIG-VD (I guess?) or yourself, that's fine with us. Btw, at first glance, I did not find any additional GPL copyrights coming with your changes in the patches, it would be better to have them, so that we always know who contributed to what, as much as possible.
Yes, it's ok. HEIG-VD is the University of Applied Sciences of Western Switzerland in Yverdon (http://www.heig-vd.ch) and I'm working at the REDS Institute (http://reds.eivd.ch, unfortunately in French only at the moment). We are granted to publish our work, at least all part which are not directly bound to some industrial projects (I'm trying to keep the stuff as open and public as possible ;-).
Quoted 6 lines
Quoted 3 lines
It's a first step; I hope it will help some other ARM9 developers and
look forward to reading some feedbacks.
Quoted 2 lines
I profit to thank a lot the Xenomai team (Philippe, Jan, Gilles and
the
Quoted 7 lines
others) for their excellent work and support).
Quoted 1 line
Xenomai exists because people participate in the Sisyphean task of making it better, like you just did. In other words, welcome to the band. Let's roll the rock.
Cool.
Quoted 7 lines
Quoted 7 lines
Kind regards
Daniel
----------------------------------------------------------------------
--
Quoted 10 lines
Quoted 5 lines
_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core--
Philippe.
Daniel
_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core
Quoted 6 lines · ROSSIER Daniel
Hi Philippe,
Any chance to see our work integrated within an official distribution?
Are you still reviewing the code?
It's reviewed and mostly ok, except the "poll mode" boot parameter which is not there (i.e. adding a static compilation option is not the way to go). The main issue that remains is to merge it properly with the latest Adeos codebase (i.e. w/ pipeline head optimizations and wired IRQ support), and optionally, with the existing ARM port for the ARM1136, but since the i.MX21 support needs to be provided by an additional patch, the latter seems unlikely, unfortunately.
Quoted 174 lines
Thanks for your feedback
Daniel
Quoted 167 lines
-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part de ROSSIER Daniel
Envoyé : mardi, 25. avril 2006 15:17
À : Philippe Gerum
Cc : [email protected]
Objet : RE: [Xenomai-core] Xenomai on Freescale i.MX21 (ARM926J)Quoted 11 lines
-----Message d'origine-----
De : Philippe Gerum [mailto:[email protected]]
Envoyé : jeudi, 20. avril 2006 15:43
À : ROSSIER Daniel
Cc : [email protected]
Objet : Re: [Xenomai-core] Xenomai on Freescale i.MX21 (ARM926J)Quoted 2 lines · ROSSIER Daniel
Dear all,
Quoted 10 lines
Quoted 1 line
We finally succeeded in the port of Xenomai on our Freescale i.MX21
board (ARM-926J);
Quoted 1 line
(The board used is the CSB535FS issued from Cogent with the BSP from
Microcross)
Quoted 1 line
To have further technical references, please see there:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=i.MX_LITEKI
Quoted 7 lines
T&parentCode=i.MX21&nodeId=0162468rH31143ZrDR
Quoted 1 line
So, you will find two patches: the first one (patch-linux-
2.6.14.imx21_1.0.0) is used to patch the Linux 2.6.14 for supporting the board. Then, the second one (adeos-ipipe-2.6.14-arm-imx21-0.1.00.patch) can be used against the imx21-enabled kernel for Xenomai, simply using
the
Quoted 4 lines
prepare-kernel.shscript. The patch was originally inspired from the Integrator/ARM11 patch; thanks to its author :-)Quoted 1 line
We will publish soon some results regarding the different latencies,
but
Quoted 2 lines
so far we measured about 2us between the IRQ and the timer reprogramming (at the ipipe level). The problem now is the jitter which is pretty
high:
Quoted 3 lines
about 1-2us, with some occasional peaks up to 5us.
Quoted 1 line
Having quite a few experience with this kind of board, we don't know
if
Quoted 14 lines
it comes from the code itself, or purely from the hardware. Any idea/suggestions would be welcome. For periodic tasks around 20us, everything works perfecly.
Those results are pretty impressive actually. Assuming that you compare those figures with those obtained from traditional standalone RTOS e.g. VxWorks on the same board, the critical difference with Xenomai is that Linux is competing for the hw resources, and for instance, happily trashes the cache under Xenomai's feet when scheduling its own tasks during Xeno's idle time. Additionally, Adeos adds a small overhead due to the interrupt virtualization, in exchange of real-time predictability for their delivery. Therefore, in this respect, 5 us does not look that bad already.
Quoted 4 lines
Are 20 us a measure of the worst-case interrupt latency (i.e. running latency -t2), or scheduling latency in user-space (i.e. running latency -t0)?
No, I think we can go lower; the measure we actually got between the IRQ and the timer reprogramming is about 2 us with some jitters up to 5 us; we could
normally guarantee not to exceed 5 us between the IRQ and timer reprogramming. Now, considering the ISR itself, we could get some time under 10us provided that the ISR remains short.So far, we measured the reaction time with the oscillo; we are now about to check the latencies with the latency utility from Xenomai.
Quoted 1 line
Quoted 1 line
I don't know to what extent this (1 or 2) patch(es) can be integrated
in
Quoted 7 lines
the official distribution;
but of course we are willing to make any adaptations to fulfill the requirements for that.For the technical part, I guess that anyone interested in the ARM support for Adeos/Xenomai will review this code; I'll be one of these people, for sure. The usefulness of such contribution looks obvious to
me.
Quoted 8 lines
For the non-technical part, a pre-requisite for adding code to the Adeos or Xenomai codebases is to properly identify it as coming from a legitimate source, so if you, as a submitter, can confirm that you may freely contribute it on behalf of the HEIG-VD (I guess?) or yourself, that's fine with us. Btw, at first glance, I did not find any additional GPL copyrights coming with your changes in the patches, it would be better to have them, so that we always know who contributed to what, as much as possible.
Yes, it's ok. HEIG-VD is the University of Applied Sciences of Western Switzerland in Yverdon (http://www.heig-vd.ch) and I'm working at the REDS Institute (http://reds.eivd.ch, unfortunately in French only at the moment). We are granted to publish our work, at least all part which are not directly bound to some industrial projects (I'm trying to keep the stuff as open and public as possible ;-).
Quoted 5 lines
Quoted 1 line
It's a first step; I hope it will help some other ARM9 developers and
look forward to reading some feedbacks.
Quoted 1 line
I profit to thank a lot the Xenomai team (Philippe, Jan, Gilles and
the
Quoted 6 lines
others) for their excellent work and support).
Xenomai exists because people participate in the Sisyphean task of making it better, like you just did. In other words, welcome to the band. Let's roll the rock.
Cool.
Quoted 7 lines
Quoted 7 lines
Kind regards
Daniel
----------------------------------------------------------------------
--
Quoted 9 lines
Quoted 4 lines
_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core--
Philippe.
Daniel
_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core
Signature · 1 line
Philippe.
Hi,
I recently worked on the integration of the i.MX21 support into the Adeos codebase. The basic idea is to reduce the amount of platform-specific code in your original patch, so that changes happening in the generic Adeos core will be immediately available to the Freescale platform too. Since the core i.MX21 support is not mainline yet AFAICS, we will have to deal with three patches instead of one, all to be applied against 2.6.14 vanilla, in this order:
- The patch called patch-linux-2.6.14.imx21_1.0.0 you posted to this list, providing the i.MX21 core bits for the Linux kernel.
- the vanilla Adeos patch for 2.6.14 over ARM [1]
- the attached patch completing the i.MX21 support for Adeos.
What remains:
- the "idle=poll" bootparam, for using a busy loop in the idle task, instead of the default idle method.
- some cleanups in a few areas of the 3rd patch, which still emits various warnings (gcc 3.4.1). Some of them may not be that innocuous, so they deserves to be fixed, I think.
When time allows, I'd like you try rebuilding a complete kernel using the patch list above, and let me know if your i.MX21 board still runs with it. From that point, we should be able to refine the Adeos support for this platform, enough to bundle it with Xeno.
[1] http://download.gna.org/adeos/patches/v2.6/arm/adeos-ipipe-2.6.14-arm-1.3-02.patch
Signature · 1 line
Philippe.
home/sgerber/arm-iMx/xenomai/linux/linux-2.6.14_imx21_ipipe/arch/arm/mach-imx21/time.c renamed from home/sgerber/arm-iMx/csb535/linux/linux-2.6.14_imx21/arch/arm/mach-imx21/time.c +160 -28
@@ -10,7 +10,16 @@* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. +* +* April 2006 : +* Adapted to ARM9 i.MX21/CSB535FS board with Xenomai by S.Gerber, G.Boutillier and D.Rossier +* University of Applied Sciences Western Switzerland +* Reconfigurable & Embedded Digital Systems, REDS Institute +* +* * 24.04.06 : modification of value __ipipe_mach_ticks_per_jiff +* the value dependent of timer clock frequency and HZ constant */ +#include <linux/config.h> #include <linux/kernel.h> #include <linux/sched.h>
@@ -24,56 +33,165 @@#include <asm/irq.h> #include <asm/mach/time.h> +#include <asm/arch/csb535.h> + +static unsigned long timer_reload; +static unsigned long timer_interval; +static unsigned long timer_lxlost; +static int tscok; + +#ifdef CONFIG_IPIPE +int __ipipe_mach_timerint =INT_GPT1 ; +static unsigned long long __ipipe_mach_tsc; +static DEFINE_SPINLOCK (timer_lock); +int __ipipe_mach_timerstolen =0 ; +EXPORT_SYMBOL (__ipipe_mach_timerstolen); +/* +* timer_frequency = 17'616'076,8 Hz +* ticks/jiffy = timer_freq / Hz +*/ +unsigned int __ipipe_mach_ticks_per_jiffy =CLKPERCLK1 /HZ ; +EXPORT_SYMBOL (__ipipe_mach_ticks_per_jiffy); +#endif /* CONFIG_IPIPE */ +/* -* Returns number of us since last clock interrupt. Note that interrupts -* will have been disabled by do_gettimeoffset() +* Called with IRQ disabled from do_gettimeofday(). */ -static unsigned long imx21_gettimeoffset (void ) +static inline unsigned long imx_getticksoffset (void ) { -unsigned long ticks; +if (!tscok) +return 0 ; + +//Return the value of Timer 1 +return IMX21_TCN (GPT1 ); + +} + +/* +* Reprogram the timer +*/ +static inline void set_dec (unsigned long reload) +{ + +//Configure timer in a now state +IMX21_TCTL (GPT1 ) =0 ; +//Load the compare value (next IRQ) +IMX21_TCMP (GPT1 ) = reload; +//Restart the timer (in free run mode (FRR)) +IMX21_TCTL (GPT1 ) =TCTL_CLK_PCLK1 |TCTL_IRQ_COMP |TCTL_TEN |TCTL_FRR |TCTL_OM |TCTL_CC ; + + timer_reload = reload; + +} + +#ifdef CONFIG_IPIPE +void inline __ipipe_mach_acktimer (void ) +{ +/* -* Get the current number of ticks. Note that there is a race -* condition between us reading the timer and checking for -* an interrupt. We get around this by ensuring that the -* counter has not reloaded between our two reads. -*/ +* TODO : Could be optimize +*/ +if (IMX21_TSTAT (GPT1 ) ) +IMX21_TSTAT (GPT1 ) =TSTAT_COMP ; + +} +EXPORT_SYMBOL (__ipipe_mach_acktimer); + +unsigned long long __ipipe_mach_get_tsc (void ) +{ + +unsigned long long result; +unsigned long flags; + +spin_lock_irqsave_hw (&timer_lock, flags); + result = __ipipe_mach_tsc +imx_getticksoffset (); +spin_unlock_irqrestore_hw (&timer_lock, flags); +return result; + +} +EXPORT_SYMBOL (__ipipe_mach_get_tsc); + +void __ipipe_mach_set_dec (unsigned long reload) +{ +unsigned long ticks; +unsigned long flags; + +spin_lock_irqsave_hw (&timer_lock, flags); + ticks =imx_getticksoffset (); + __ipipe_mach_tsc += ticks; +set_dec (reload); + timer_lxlost += ticks; +spin_unlock_irqrestore_hw (&timer_lock, flags); + +} +EXPORT_SYMBOL (__ipipe_mach_set_dec); + +unsigned long __ipipe_mach_get_dec (void ) +{ +unsigned ticks; + ticks =IMX21_TCN (GPT1 ); -/* -* Interrupt pending? If so, we've reloaded once already. -*/ -if (IMX21_TSTAT (GPT1 ) &TSTAT_COMP ) - ticks +=LATCH ; +if (ticks < timer_reload) { +return timer_reload - ticks; + } +else { +return 0xffffffff + timer_reload - ticks; + } +} +EXPORT_SYMBOL (__ipipe_mach_get_dec); +#endif /* CONFIG_IPIPE */ + +unsigned long imx21_gettimeoffset (void ) +{/* -* Convert the ticks to usecs +* Convert ticks to usecs */ -return (1000000 /CLK32 ) * ticks; +return ((10000 * (timer_lxlost +imx_getticksoffset ())) / __ipipe_mach_ticks_per_jiffy); + } -/* -* IRQ handler for the timer -*/ static irqreturn_t imx21_timer_interrupt (int irq,void *dev_id,struct pt_regs *regs) {write_seqlock (&xtime_lock); -/* if any bits set, rupt has occurred, clear it by writing a 1 */ -if (IMX21_TSTAT (GPT1 ) ) { -IMX21_TSTAT (GPT1 ) =TSTAT_CAPT |TSTAT_COMP ; + timer_lxlost =0 ; + +#ifdef CONFIG_IPIPE +/* +* If Linux is the only domain, ack the timer and reprogram it +*/ +if (!__ipipe_mach_timerstolen) { + __ipipe_mach_tsc +=imx_getticksoffset (); +#else +if (IMX21_TSTAT (GPT1 ) ) { +IMX21_TSTAT (GPT1 ) =TSTAT_COMP ; + } +#endif +/* +* Reprogram timer with "__ipipe_mach_ticks_per_jiffy"; +*/ +IMX21_TCTL (GPT1 ) =0 ; +IMX21_TCMP (GPT1 ) = __ipipe_mach_ticks_per_jiffy; +IMX21_TCTL (GPT1 ) =TCTL_CLK_PCLK1 |TCTL_IRQ_COMP |TCTL_TEN |TCTL_FRR |TCTL_OM |TCTL_CC ; + +#ifdef CONFIG_IPIPE } - +#endif +timer_tick (regs);write_sequnlock (&xtime_lock);return IRQ_HANDLED ; + }static struct irqaction imx21_timer_irq = { - .name ="i.MX21 Timer Tick" , - .flags =SA_INTERRUPT , + .name ="i.Mx21 Timer Tick" , + .flags =SA_INTERRUPT |SA_TIMER , .handler = imx21_timer_interrupt };
@@ -82,21 +200,35 @@*/ static void __init imx21_timer_init (void ) { +/* -* Initialise to a known state (all timers off, and timing reset) +* Configure all timers in a now state */ IMX21_TCTL (GPT1 ) =0 ; +IMX21_TCTL (GPT2 ) =0 ; +IMX21_TCTL (GPT3 ) =0 ; +/* +* Configure the timer +*/ IMX21_TPRER (GPT1 ) =0 ; -IMX21_TCMP (GPT1 ) =LATCH -1 ; -IMX21_TCTL (GPT1 ) =TCTL_CLK_32 |TCTL_IRQEN |TCTL_TEN ;/* * Make irqs happen for the system timer */ setup_irq (INT_GPT1 , &imx21_timer_irq); + +/* +* Reprogram the timer and start it ! +*/ +set_dec (__ipipe_mach_ticks_per_jiffy); + + tscok =1 ; + }struct sys_timer imx21_timer = { .init = imx21_timer_init, .offset = imx21_gettimeoffset, }; + +
home/sgerber/arm-iMx/xenomai/linux/linux-2.6.14_imx21_ipipe/include/asm-arm/arch-imx21/csb535.h renamed from home/sgerber/arm-iMx/csb535/linux/linux-2.6.14_imx21/include/asm-arm/arch-imx21/csb535.h +15 -1
@@ -20,6 +20,16 @@* along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* April 2006 : +* Adapted to ARM9 i.MX21/CSB535FS board with Xenomai by S.Gerber, G.Boutillier and D.Rossier +* University of Applied Sciences Western Switzerland +* Reconfigurable & Embedded Digital Systems, REDS Institute +* +* 24.04.06 : define the value : TICKS_PER_uSEC +* adapted by S�bastien Gerber +* 25.04.06 : add a constant for the timer clock (CLKPERCLK1) +* adapted by S�bastien Gerber +* */ #ifndef __ASM_ARCH_CSB535_H
@@ -34,7 +44,11 @@#define IMX_FB_PHYS (0x0C000000 - 0x40000) -#define CLK32 32768 +#define CLK32 32768 +#define CLKPERCLK1 16515072 + +#define TICKS_PER_uSEC CLKPERCLK1 / 1000000 +#define CSB535_ETH_VIRT IMX21_CS1_VIRT#define CSB535_ETH_PHYS IMX21_CS1_PHYS
home/sgerber/arm-iMx/xenomai/linux/linux-2.6.14_imx21_ipipe/include/asm-arm/arch-imx21/imx-regs.h renamed from home/sgerber/arm-iMx/csb535/linux/linux-2.6.14_imx21/include/asm-arm/arch-imx21/imx-regs.h +38 -11
101 lines not on this page · raw message