Skip to contentSkip to conversation

Error: could not insert module kernel-task.ko: Unknown symbol in module

Xenomai [email protected] 2 participants 4 messages Apr 18, 2015 – Apr 20, 2015

lore
Share & tools
lore
#0 lore raw

----- Reply message -----
From: "Helder Daniel" <[email protected]>
To: "Ruika You" <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: [Xenomai] Error: could not insert module kernel-task.ko: Unknown symbol in module
Date: Sat, Apr 18, 2015 5:35 PM

Hi,
Are you using Xenomai version 3.x or 2.6.x?

My xenomai version is 2.6.4

In version 3.x the native API is no longer exported to kernel, only the RTDM API.

//NOT EXPORTED in 3.x: #include <native/task.h>

Helder

On 18 April 2015 at 03:52, Ruika You <[email protected]> wrote:
Dear all,

I just start to explore xenomai with compile a kernel module as simple as

"hello world". After compile successful, sudo insmod kernel-task.ko,

failed, error message as follow:

Error: could not insert module kernel-task.ko: Unknown symbol in module

Dmesg result as belllow:

[52170.262642] kernel_task: Unknown symbol rt_task_create (err 0)
[52170.262688] kernel_task: Unknown symbol rt_task_start (err 0)
[52170.262722] kernel_task: Unknown symbol rt_task_delete (err 0)

Source code:

#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);

return 1;

/* ... */

}

void cleanup_module (void)

{

rt_task_delete(&task_desc);

}

As I analyzed the reason might be :

1. kernel build configure problem ?

2. xenomai userland configure problem?

3. any xenomai module not loaded? native?

4. have to export all these unknow symbol to kernel?

Please advise!

Thank you very much!

-chengxi

_______________________________________________

Xenomai mailing list

[email protected]

http://www.xenomai.org/mailman/listinfo/xenomai

Signature · 5 lines
Helder Daniel
UALG - FCT
DEEI

http://w3.ualg.pt/~hdaniel
#1 lore raw

Maybe in the makefile you do not included the right path for headers. A generic makefile for simple kernel modules (2.6.x and 3.x), which gets correct path from Xenoma, using xeno-config, is:

obj-m := kernel-task.o

$(eval EXTRA_CFLAGS := $(shell xeno-config --kcflags)) #or
#$(eval ccflags-y = $(shell xeno-config --kcflags))

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

Note: Is is assumed that Xenomai binary path, which is where xeno-config is stored, is in the search PATH.
The default path should be:

/usr/xenomai/bin

Quoted 92 lines · On 18 April 2015 at 11:32, [email protected] <[email protected]>…

----- Reply message -----
From: "Helder Daniel" <[email protected]>
To: "Ruika You" <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: [Xenomai] Error: could not insert module kernel-task.ko: Unknown symbol in module
Date: Sat, Apr 18, 2015 5:35 PM

Hi,

Are you using Xenomai version 3.x or 2.6.x?

My xenomai version is 2.6.4

In version 3.x the native API is no longer exported to kernel, only the RTDM API.

//NOT EXPORTED in 3.x: #include <native/task.h>

Helder

Quoted 47 lines · Ruika You

Dear all,

I just start to explore xenomai with compile a kernel module as simple as "hello world". After compile successful, sudo insmod kernel-task.ko, failed, error message as follow:
Error: could not insert module kernel-task.ko: Unknown symbol in module

Dmesg result as belllow:

[52170.262642] kernel_task: Unknown symbol rt_task_create (err 0)
[52170.262688] kernel_task: Unknown symbol rt_task_start (err 0)
[52170.262722] kernel_task: Unknown symbol rt_task_delete (err 0)

Source code:
#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);
return 1;
/* ... */
}
void cleanup_module (void)
{
rt_task_delete(&task_desc);
}

As I analyzed the reason might be :

1. kernel build configure problem ?
2. xenomai userland configure problem?
3. any xenomai module not loaded? native?
4. have to export all these unknow symbol to kernel?

Quoted 8 lines

Please advise!
Thank you very much!
-chengxi
_______________________________________________
Xenomai mailing list
[email protected]
http://www.xenomai.org/mailman/listinfo/xenomai

--
Helder Daniel
UALG - FCT
DEEI

http://w3.ualg.pt/~hdaniel

Signature · 5 lines
Helder Daniel
UALG - FCT
DEEI

http://w3.ualg.pt/~hdaniel
author
#2 lore raw

Dear Helder Daniel,

Thanks for your guide, I solve this issue.

MODULES =hello
PWD := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
KSRC ?= /lib/modules/$(shell uname -r)/build
obj-m += ${patsubst %, %.o, $(MODULES)}

#comment this line change to your proposal
#EXTRA_CFLAGS = -I$(KSRC)/include/xenomai -D_GNU_SOURCE -D_REENTRANT
-D__XENO__

EXTRA_CFLAGS:=$(shell /usr/xenomai/bin/xeno-config --skin native --cflags) all:

    make -C $(KSRC) M=$(PWD) modules
clean::
    $(RM) $(CLEANMOD) *.o *.ko *.mod.c Module*.symvers Module.markers
modules.order
    $(RM) -R .tmp*

make -C /lib/modules/3.14.0/build M=/home/edm/test/hello modules make[1]: Entering directory `/home/edm/linuxcnc/linux-kernel'
CC [M] /home/edm/test/hello/hello.o
In file included from /home/edm/test/hello/hello.c:4:0:
/usr/xenomai/include/native/task.h: In function ‘rt_task_spawn’:
/usr/xenomai/include/native/task.h:319:5: warning: ‘rt_task_create’ is deprecated (declared at /usr/xenomai/include/native/task.h:252) [-Wdeprecated-declarations]
/home/edm/test/hello/hello.c: In function ‘init_module’:
/home/edm/test/hello/hello.c:24:1: warning: ‘rt_task_create’ is deprecated (declared at /usr/xenomai/include/native/task.h:252) [-Wdeprecated-declarations]
Building modules, stage 2.
MODPOST 1 modules
CC /home/edm/test/hello/hello.mod.o
LD [M] /home/edm/test/hello/hello.ko
make[1]: Leaving directory `/home/edm/linuxcnc/linux-kernel'

By the way, I am wondering are there warning OK?

-chengxi

#3 lore raw

Hi,

The warnings about ‘rt_task_spawn’, ‘rt_task_create’, etc., ... is deprecated
are giving you an hint that the native API will not be supported in version 3.x.

You can change this function rt_xxxxxx to similar functions from the RTDM API (rtdm_xxxx) which is supported in version 2.6.x and 3.x.

Below is an example of a simple RTDM module for Xenomai 2.5.x and 2.6.x. For Xenomai 3.x is a liittle different the location of the headers for RTDM, and also we must take care to terminate a thread that is killed with rtdm_task_destroy(). I also included the Xenomai 3.x example if you are willing to take a look.

regards,

Helder

===============
Xeno 2.6.x version
===============

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <rtdm_driver.h> //RTDM support includes also: <rtdm.h>

#define TASK_PRIO 10 // 99 is Highest RT priority
#define TASK_MODE 0 // No flags
#define TASK_STKSZ 0 // default Stack size

#define TASK_PERIOD 500000000ll // in nano seconds = 500 ms

static rtdm_task_t td; //RTDM Real time task pointer

void periodic (void *arg) {
for (;;) {
rtdm_task_wait_period(); //deschedule until next period

      printk(KERN_ALERT "Hi there!");

}
}

int init_module(void) {
return rtdm_task_init (&td, "periodic", &periodic, NULL, TASK_PRIO,
TASK_PERIOD);
}

void cleanup_module(void) {
rtdm_task_destroy(&td);
}

MODULE_LICENSE("GPL"); //To access Xenoma symbols

===============
Xeno 3.x version
===============
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <rtdm/driver.h> //defines: rtdm_task_t, rtdm_sem_t, ... (also includes rtdm.h)

#define TASK_PRIO 10 // 99 is Highest RT priority
#define TASK_MODE 0 // No flags
#define TASK_STKSZ 0 // default Stack size

#define TASK_PERIOD 500000000ll // in nano seconds = 500 ms

static rtdm_task_t td; //RTDM Real time task pointer

void periodic (void *arg) {
for (;;) {
if (rtdm_task_should_stop()) //to avoid kernel crash when rmmod and break; //rtdm_task_destroy is called, this
//function should exit
rtdm_task_wait_period(); //deschedule until next period

printk(KERN_ALERT "Hi there!");
}
}

int init_module(void) {
return rtdm_task_init (&td, "periodic", &periodic, NULL, TASK_PRIO,
TASK_PERIOD);
}

void cleanup_module(void) {
rtdm_task_destroy(&td);
}

MODULE_LICENSE("GPL"); //To access Xenoma symbols

Quoted 45 lines · Ruika You

Dear Helder Daniel,

Thanks for your guide, I solve this issue.

MODULES =hello
PWD := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd;
fi)
KSRC ?= /lib/modules/$(shell uname -r)/build
obj-m += ${patsubst %, %.o, $(MODULES)}

#comment this line change to your proposal
#EXTRA_CFLAGS = -I$(KSRC)/include/xenomai -D_GNU_SOURCE -D_REENTRANT
-D__XENO__

EXTRA_CFLAGS:=$(shell /usr/xenomai/bin/xeno-config --skin native --cflags) all:

    make -C $(KSRC) M=$(PWD) modules
clean::
    $(RM) $(CLEANMOD) *.o *.ko *.mod.c Module*.symvers Module.markers
modules.order
    $(RM) -R .tmp*

make -C /lib/modules/3.14.0/build M=/home/edm/test/hello modules make[1]: Entering directory `/home/edm/linuxcnc/linux-kernel'
CC [M] /home/edm/test/hello/hello.o
In file included from /home/edm/test/hello/hello.c:4:0:
/usr/xenomai/include/native/task.h: In function ‘rt_task_spawn’:
/usr/xenomai/include/native/task.h:319:5: warning: ‘rt_task_create’ is deprecated (declared at /usr/xenomai/include/native/task.h:252) [-Wdeprecated-declarations]
/home/edm/test/hello/hello.c: In function ‘init_module’:
/home/edm/test/hello/hello.c:24:1: warning: ‘rt_task_create’ is deprecated (declared at /usr/xenomai/include/native/task.h:252) [-Wdeprecated-declarations]
Building modules, stage 2.
MODPOST 1 modules
CC /home/edm/test/hello/hello.mod.o
LD [M] /home/edm/test/hello/hello.ko
make[1]: Leaving directory `/home/edm/linuxcnc/linux-kernel'

By the way, I am wondering are there warning OK?

-chengxi

Signature · 5 lines
Helder Daniel
UALG - FCT
DEEI

http://w3.ualg.pt/~hdaniel