Skip to contentSkip to conversation

Kompiling an RT Kernel Module

Xenomai-help Axel Beierlein 3 participants 3 messages Jun 29, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

Now a few hours i try to compile a simple file as an RT Kernel Module and i get errors over errors.
I have included the kernel sources and the xenomai sources in different ways. I get many "in file includes" and other errors.

What are the minimal requirements to compile such a native rt module? (include path, lib path ....)
I can´t use the output of xeno-config cause the rootfs on my target(ppc) is mounted over NFS from my development host(i386). I have a look at the makefile http://svn.gna.org/svn/xenomai/trunk/examples/common/Makefile but that solved not my probs. On the contrary it confuses me more and more cause i don´t understand why the Makro KSRC is defined as an pointer to the librarys and this Makro was also used to point to the Kernelheaders.

Is there anywhere an example working with support for cross-developement?

I´ve compiled the running kernel with all xenomai stuff inside (no modules) but with module load support on.

Axel

sorry for my terrible English ;-)

--------------------------------------------------------------------

The Example-Source of Kernel Module:

#include <native/task.h>

#define TASK_PRIO  99              /* Highest RT priority */
#define TASK_MODE  T_FPU|T_CPU(0)  /* Uses FPU, bound to CPU #0 */
#define TASK_STKSZ 4096            /* Stack size (in bytes) */

RT_TASK task_desc;

void task_body (void *cookie)
{

   for (;;) {
     /* ... "cookie" should be NULL ... */
     }
}

int init_module (void)

 {
	int err;

     /* ... */

    err = rt_task_create(&task_desc,
                          "MyTaskName",
                         TASK_STKSZ,
                         TASK_PRIO,
                         TASK_MODE);
     if (!err)
         rt_task_start(&task_desc,&task_body,NULL);

    /* ... */

}

void cleanup_module (void)

 {
     rt_task_delete(&task_desc);

}

#1 lore raw
Quoted 9 lines · Axel Beierlein

Hello,

Now a few hours i try to compile a simple file as an RT Kernel Module and i get errors over errors.
I have included the kernel sources and the xenomai sources in different ways. I get many "in file includes" and other errors.

What are the minimal requirements to compile such a native rt module? (include path, lib path ....)

Just a standard kernel module makefile you'll find almost anywhere + a Xenomai include path, ie.

EXTRA_CFLAGS := -I$(KSRC)/include/xenomai
(taken from your cited example)

Quoted 2 lines

I can?t use the output of xeno-config cause the rootfs on my target(ppc) is mounted over NFS from my development host(i386). I have a look at the

You don't need to for a pure kernel module target. Just pick that example and follow its instructions: Clear APPLICATIONS, put your module into MODULES, then run make: "make KSRC=<kernel-src>". Must work, really.

Quoted 4 lines

makefile http://svn.gna.org/svn/xenomai/trunk/examples/common/Makefile but that solved not my probs. On the contrary it confuses me more and more cause i don?t understand why the Makro KSRC is defined as an pointer to the librarys and this Makro was also used to point to the Kernelheaders.

Try to find out what is behind /lib/modules/uname -r/build on your box... :->
(Note that "$(shell <command>)" in a makefile means <command> in your shell.)

Quoted 2 lines

Is there anywhere an example working with support for cross-developement?

If you use a cross-compiler, additionally pass its prefix like this:

make KSRC=... CROSS_COMPILE=...

If you compile for a different arch, add ARCH=... as well.

Quoted 7 lines

I?ve compiled the running kernel with all xenomai stuff inside (no modules) but with module load support on.

Axel

sorry for my terrible English ;-)

It's very well readable! I guess you haven't seen truly terrible English on mailing lists yet. ;)

Jan

PS: If someone feels like adding a few words / references about "how do I compile a kernel module for Xenomai?" to the wiki, please go ahead!

#2 lore raw
In reply to Axel Beierlein
Quoted 2 lines · Axel Beierlein

I can´t use the output of xeno-config cause the rootfs on my target(ppc) is mounted over NFS from my development host(i386).

As said by others, xeno-config is not meant to be used for building modules. However xeno-config is meant to be used in the cross-compiling case: this is what its DESTDIR variable is for.

Signature · 1 line
                                              Gilles Chanteperdrix