gpio-keys with xenomai
Hello,
I finally had the time to test some different settings...
I wrote the following program:
#include <sys/mman.h>
#include <native/task.h>
#include <native/intr.h>
#define IRQ_NUMBER 100 /* Intercept interrupt */
#define IRQ_MODE I_NOAUTOENA //I_PROPAGATE //0 #define TASK_PRIO 99 /* Highest RT priority */ #define TASK_MODE T_FPU /* */
#define TASK_STKSZ 0 /* Stack size (use default one) */ #define PIPE_MINOR 0
RT_INTR intr_desc;
RT_TASK server_desc;
void irq_server (void *cookie)
{
int err =
rt_intr_create(&intr_desc,"MyIrq",IRQ_NUMBER,IRQ_MODE);
printf("int create: %d\n", err);
err = rt_intr_enable(&intr_desc);
printf("enable int: %d\n", err);
printf("begin..\n");
err = rt_intr_wait(&intr_desc,TM_INFINITE);
printf("int wait:%d\n", err);}
int main (int argc, char *argv[])
{
int err;
int a;
printf("Programmstart\n");
mlockall(MCL_CURRENT|MCL_FUTURE);
err = rt_task_create(&server_desc,
"MyIrqServer",
TASK_STKSZ,
TASK_PRIO,
TASK_MODE);
printf("task create: %d\n", err);
rt_task_start(&server_desc,&irq_server,NULL);
}void cleanup (void)
{
rt_intr_delete(&intr_desc);
rt_task_delete(&server_desc);
}When I start it with the compiled xenomai, it runs until the rt_intr_wait() and then quits, without any message. It doesnt even execute printf("int wait:%d\n", err)create_task, create_intr and enable_intr all return 0.
When I start the programm with a kernel, where xenomai isnt compiled in, then it quits and complains about it.
When I start the programm with xenomai debug settings compiled in the kernel, the system freezes at task creating. Heres the output:
Programmstart
taskXenomai: fatal: bug at kernel/xenomai/nucleus/shadow.c :1128 (!irqs_disabled_hw())
CPU PID PRI TIMEOUT STAT NAME
0 0 -1 0 00400088 ROOT
Quoted 1 line
0 923 99 0 00300180 MyIrqServer
Master time base: clock=114327768
[<c002bde4>] (show_stack+0x0/0x48) from [<c006e69c>] (xnshadow_harden +0x1d0/0x21c)
[<c006e4cc>] (xnshadow_harden+0x0/0x21c) from [<c006ec00>] (xnshadow_wait_barrier+0x124/0x138)
[<c006eadc>] (xnshadow_wait_barrier+0x0/0x138) from [<c006fbe4>] (xnshadow_sys_barrier+0x14/0x18)
r6:c309a000 r5:c309bfb0 r4:00000001
[<c006fbd0>] (xnshadow_sys_barrier+0x0/0x18) from [<c006ff70>] (losyscall_event+0xb4/0x1ac)
[<c006febc>] (losyscall_event+0x0/0x1ac) from [<c0061214>] (__ipipe_dispatch_event+0xd0/0x1c8)
[<c0061144>] (__ipipe_dispatch_event+0x0/0x1c8) from [<c002cc5c>] (__ipipe_syscall_root+0x80/0x100)
[<c002cbdc>] (__ipipe_syscall_root+0x0/0x100) from [<c0028108>] (vector_swi+0x68/0xa8)
Any ideas?
is the irq-number, that I need for the rt_intr_create() the same number that is shown in /proc/interrupts?
thx, greetings,
Peter
Am Donnerstag, den 18.03.2010, 21:14 +0100 schrieb Gilles Chanteperdrix:
Quoted 4 lines
Quoted 3 lines · Peter Breuer
Hello everyone,
I am new to xenomai, so please be patient.
I am working with an AT91SAM9621S (Board SBC6000X) and I
successfully
Quoted 1 line
Quoted 1 line
patched my linux 2.6.24 with xenomai 2.4.9.1. I also have a signal
on on
Quoted 25 lines
Quoted 25 lines
of the GPIOs and I want a program to react, every time the signal arrives (~10Hz).
Before compiling I added some lines to the board description file (arch/arm/mach-at91/board-sbc9621.c):
...
static structgpio_keys_buttonsbc9261_buttons[] = {
...
//begin changes{ .gpio = AT91_PIN_PC4, .code = BTN_2, .desc = "GPIO 1", .active_low = 1, },//end changes
};
...
static void__initsbc9261_add_device_buttons(void){
...
//begin changesat91_set_gpio_input(AT91_PIN_PC4, 1); /* btn1 */ at91_set_deglitch(AT91_PIN_PC4, 1);//end changes
Quoted 5 lines
Quoted 5 lines
platform_device_register(&sbc9261_button_device); }Now a new event showed up in
/dev/input/
Without the xenomai patch there was an interrupt, that I could
listen to
Quoted 1 line
Quoted 1 line
with a program (open(/dev/input/event2) and select for listening)
and
Quoted 3 lines
Quoted 1 line
react to the signal.
That is one thing. It could be due to a edge vs level issue. First
when
Quoted 1 line
you tell this, you must be 100% sure that you are exactly using the
same
Quoted 5 lines
configuration except for the xenomai settings. Second, please try and recompile a kernel with only
CONFIG_IPIPEenabled, but not withCONFIG_XENOMAI.Quoted 1 line
With the xenomai patch nothing is coming trough, and even though
GPIO 1
Quoted 4 lines
Quoted 2 lines
still shows up in
/proc/interrupts, it doesnt show up in/proc/xenomai/irq.That is not your problem. Irqs appear in
/proc/xenomai/irqonly when
the
Quoted 3 lines
IRQ is used in the real-time domain.
Quoted 1 line
I tried to use the native API (I used the
usr_irq.c) to create and
wait
Quoted 4 lines
Quoted 1 line
for the signal, but nothin happend (
rt_intr_wait()returned -1).That is yet another story. Error codes are documented in the API documentation. -1 is
-EPERM. It usually means that the task calling
the
Quoted 7 lines
function is not a real-time task and should be one.
Quoted 5 lines
I would be very happy about every hint in the right direction. greetings,
Peter
Quoted 89 lines · Peter Breuer
Hello,
I finally had the time to test some different settings...I wrote the following program:
#include <sys/mman.h>
#include <native/task.h>
#include <native/intr.h>#define
IRQ_NUMBER100 /* Intercept interrupt */#define IRQ_MODE I_NOAUTOENA //I_PROPAGATE //0 #define TASK_PRIO 99 /* Highest RT priority */ #define TASK_MODE T_FPU /* */#define
TASK_STKSZ0 /* Stack size (use default one) */ #definePIPE_MINOR0
RT_INTRintr_desc;
RT_TASKserver_desc;void
irq_server(void *cookie){
int err =rt_intr_create(&intr_desc,"MyIrq",IRQ_NUMBER,IRQ_MODE); printf("int create: %d\n", err); err = rt_intr_enable(&intr_desc); printf("enable int: %d\n", err); printf("begin..\n"); err = rt_intr_wait(&intr_desc,TM_INFINITE); printf("int wait:%d\n", err);}
int main (int argc, char *argv[])
{ int err; int a; printf("Programmstart\n"); mlockall(MCL_CURRENT|MCL_FUTURE); err = rt_task_create(&server_desc, "MyIrqServer", TASK_STKSZ, TASK_PRIO, TASK_MODE); printf("task create: %d\n", err); rt_task_start(&server_desc,&irq_server,NULL); }void cleanup (void)
{ rt_intr_delete(&intr_desc); rt_task_delete(&server_desc); }When I start it with the compiled xenomai, it runs until the
rt_intr_wait()and then quits, without any message. It doesnt even executeprintf("int wait:%d\n", err)create_task,create_intrandenable_intrall return 0.
When I start the programm with a kernel, where xenomai isnt compiled in, then it quits and complains about it.
When I start the programm with xenomai debug settings compiled in the kernel, the system freezes at task creating. Heres the output:
Programmstart
taskXenomai: fatal: bug atkernel/xenomai/nucleus/shadow.c:1128 (!irqs_disabled_hw())
CPU PID PRI TIMEOUT STAT NAME
0 0 -1 0 00400088 ROOTQuoted 1 line
0 923 99 0 00300180 MyIrqServer
Master time base: clock=114327768
[<c002bde4>] (show_stack+0x0/0x48) from [<c006e69c>] (xnshadow_harden+0x1d0/0x21c)
[<c006e4cc>] (xnshadow_harden+0x0/0x21c) from [<c006ec00>] (xnshadow_wait_barrier+0x124/0x138)
[<c006eadc>] (xnshadow_wait_barrier+0x0/0x138) from [<c006fbe4>] (xnshadow_sys_barrier+0x14/0x18)
r6:c309a000 r5:c309bfb0 r4:00000001
[<c006fbd0>] (xnshadow_sys_barrier+0x0/0x18) from [<c006ff70>] (losyscall_event+0xb4/0x1ac)
[<c006febc>] (losyscall_event+0x0/0x1ac) from [<c0061214>] (__ipipe_dispatch_event+0xd0/0x1c8)
[<c0061144>] (__ipipe_dispatch_event+0x0/0x1c8) from [<c002cc5c>] (__ipipe_syscall_root+0x80/0x100)
[<c002cbdc>] (__ipipe_syscall_root+0x0/0x100) from [<c0028108>] (vector_swi+0x68/0xa8)
Quoted 5 lines
Any ideas?
is the irq-number, that I need for thert_intr_create()the same number that is shown in/proc/interrupts?
thx, greetings,
Peter
You are using a too old patch. Please use an I-pipe patch for linux 2.6.28 or above.
Signature · 1 line
Gilles.