All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Xenomai Kernel Module & Watchdogs
@ 2008-11-12  8:41 Adrian Boeing
  2008-11-12 20:03 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian Boeing @ 2008-11-12  8:41 UTC (permalink / raw)
  To: xenomai-help

[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]

Hi,

I'm new to Xenomai, and wanted to know how to create a watchdog. It is my
understanding that high priority periodic watchdog alarms need to be created
in kernel mode.

I would like to know:
1. Are there any tutorials/examples for Xenomai? I am aware of the examples
at:
http://www.xenomai.org/documentation/branches/v2.4.x/html/api/index.html
and
http://www.captain.at/xenomai.php

2. How do I create a kernel module? (what is the compiler command?)
If I try defining "__KERNEL__" and "MODULE" then I get a large number of
errors in the xenomai/linux includes.

I would like to create a simple 'hello world' module:

#include <nucleus/module.h>
#include <native/task.h>

int init_module(void) {
 printk("<1>Hello World 1.\n");
 return 0;
}

void cleanup_module(void) {
 printk(KERN_ALERT,"Goodbye world 1.\n");
}
(The first error I recieve on compiling is "error: variable or field
'xnpod_declare_tbase_proc' declared void", using
g++ hello.c -c -I/usr/include/xenomai -D_GNU_SOURCE -D_REENTRANT -D__XENO__
)

Thanks!
-Adrian

[-- Attachment #2: Type: text/html, Size: 1405 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Xenomai Kernel Module & Watchdogs
  2008-11-12  8:41 [Xenomai-help] Xenomai Kernel Module & Watchdogs Adrian Boeing
@ 2008-11-12 20:03 ` Gilles Chanteperdrix
       [not found]   ` <c024fefc0811130016u526a45a9q4f587679e75c381c@domain.hid>
  0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2008-11-12 20:03 UTC (permalink / raw)
  To: Adrian Boeing; +Cc: xenomai-help

Adrian Boeing wrote:
> Hi,
> 
> I'm new to Xenomai, and wanted to know how to create a watchdog. It is my
> understanding that high priority periodic watchdog alarms need to be created
> in kernel mode.

Not necessarily, the same priority scale is available in kernel-space
and user-space. However, are you aware that Xenomai already has a
watchdog? It is selectable in Linux configuration once linux sources
have been prepared.

> 
> I would like to know:
> 1. Are there any tutorials/examples for Xenomai? I am aware of the examples
> at:
> http://www.xenomai.org/documentation/branches/v2.4.x/html/api/index.html
> and
> http://www.captain.at/xenomai.php

See the examples directory in xenomai distribution.

> 
> 2. How do I create a kernel module? (what is the compiler command?)
> If I try defining "__KERNEL__" and "MODULE" then I get a large number of
> errors in the xenomai/linux includes.

This question is off-topic on Xenomai mailing list, it is not related to
xenomai at all. But you have to get the module compiled by Linux kernel
makefiles. See Documentation/kbuild/modules.txt in the kernel sources.

> 
> I would like to create a simple 'hello world' module:
> 
> #include <nucleus/module.h>
> #include <native/task.h>
> 
> int init_module(void) {
>  printk("<1>Hello World 1.\n");
>  return 0;
> }
> 
> void cleanup_module(void) {
>  printk(KERN_ALERT,"Goodbye world 1.\n");
> }
> (The first error I recieve on compiling is "error: variable or field
> 'xnpod_declare_tbase_proc' declared void", using
> g++ hello.c -c -I/usr/include/xenomai -D_GNU_SOURCE -D_REENTRANT -D__XENO__
> )

the linux kernel is C only, there is no C++, and actually, trying to
compile C++ in kernel-space is a major PITA.

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Xenomai Kernel Module & Watchdogs
       [not found]   ` <c024fefc0811130016u526a45a9q4f587679e75c381c@domain.hid>
@ 2008-11-13 16:39     ` Gilles Chanteperdrix
  2008-11-14  0:50       ` Adrian Boeing
  0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2008-11-13 16:39 UTC (permalink / raw)
  To: Adrian Boeing; +Cc: Xenomai help

Adrian Boeing wrote:
> Hi Gilles,
> 
> Thank you for your reply.
> 
> Not necessarily, the same priority scale is available in kernel-space
>> and user-space. However, are you aware that Xenomai already has a
>> watchdog? It is selectable in Linux configuration once linux sources
>> have been prepared.
> 
> 
> Yes, I saw it mentioned in an older version of the documentation, however I
> was unable to find the option. (The documentation mentions 'expert mode' in
> the 'general' menu - I was not able to find it.)

You need to enable xenomai debugging.

> 
> I would like to create a watchdog that watches my other real & non-realtime
> threads to make sure they are not starved/stuck/error etc. and reset them if
> necessary.
> 
> The documentation on 'alarm' mentions "Create an alarm object from kernel
> space". So I assumed they must be created in a kernel module.

No, as can be seen in the documentation, there are two rt_alarm_create
functions, one for user-space, one for kernel-space

> 
> 
>> 2. How do I create a kernel module? (what is the compiler command?)
>>
>> This question is off-topic on Xenomai mailing list, it is not related to
>> xenomai at all. But you have to get the module compiled by Linux kernel
>> makefiles. See Documentation/kbuild/modules.txt in the kernel sources.
> 
> 
> Thanks for the hints. One of the examples in the Xenomai documentation is
> "kernel_task.c"
> How should I compile and run this example? I assumed it was a kernel module.
> 
> This is how I compile it at the moment:
> gcc -I/usr/include/xenomai -D_GNU_SOURCE -D_REENTRANT -D__XENO__
> -L/usr/lib -lpthread  -lnative -Xlinker -rpath -Xlinker /usr/lib  -c kmod.c
> 
> Try to run it:
> sudo insmod ./kmod.o
> 
> I get this error:
> insmod: error inserting './kmod.o': -1 Invalid module format

I repeat myself: "you have to get the module compiled by Linux kernel
makefiles. See Documentation/kbuild/modules.txt in the kernel sources."

Please do not drop the mailing list from the CC.

-- 
                                                 Gilles.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Xenomai Kernel Module & Watchdogs
  2008-11-13 16:39     ` Gilles Chanteperdrix
@ 2008-11-14  0:50       ` Adrian Boeing
  0 siblings, 0 replies; 4+ messages in thread
From: Adrian Boeing @ 2008-11-14  0:50 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai help

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

Hi Giles,

You need to enable xenomai debugging.
>

Ok, thanks.



> I repeat myself: "you have to get the module compiled by Linux kernel
> makefiles. See Documentation/kbuild/modules.txt in the kernel sources."
>

Yes, sorry. The problem I am having was in including Xenomai into the kernel
module.
I have figured out how to do this, below is the solution:

If I compile a vanilla linux kernel, I do this:

hello.c:
#include <linux/module.h>
#include <linux/kernel.h>

int init_module(void) {
 printk(KERN_INFO "Hello World 1.\n");
 return 0;
}

void cleanup_module(void) {
 printk(KERN_INFO "Goodbye world 1.\n");
}

Makefile:
obj-m += hello.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

commands:
make
sudo insmod ./hello.ko
lsmod |grep hello

To include xenomai calls, add:
#include <nucleus/module.h>
#include <native/task.h>

to the kernel module 'hello.c' source listed above.

and modify the makefile to include
EXTRA_CFLAGS = -I/usr/include/xenomai -D_GNU_SOURCE -D_REENTRANT -D__XENO__

And it works now.

Please do not drop the mailing list from the CC.

Sorry, missed it.

[-- Attachment #2: Type: text/html, Size: 1903 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-14  0:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-12  8:41 [Xenomai-help] Xenomai Kernel Module & Watchdogs Adrian Boeing
2008-11-12 20:03 ` Gilles Chanteperdrix
     [not found]   ` <c024fefc0811130016u526a45a9q4f587679e75c381c@domain.hid>
2008-11-13 16:39     ` Gilles Chanteperdrix
2008-11-14  0:50       ` Adrian Boeing

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.