All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] loading module
@ 2007-05-23 12:16 Rodolfo
  2007-05-23 12:34 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 8+ messages in thread
From: Rodolfo @ 2007-05-23 12:16 UTC (permalink / raw)
  To: xenomai

Hi,
I am totally new to Xenomai and have no experience with RTAI. I'm trying
to load a kernel module that uses the native API for testing, but I get
the following segmentation fault. Can anyone help me out??
Thanks


Running 2.6.20 Kernel and Xenomai is statically built into the Kernel,
on a VIA Eden

----------------------------------------------------------------------------------------------------------------------------
Jun 13 03:58:04 login[345]: root login on 'ttyS0'


BusyBox v1.5.0 (2007-05-16 14:24:12 CEST) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# cd usr
# insmod hallo.ko
task start<1>BUG: unable to handle kernel NULL pointer dereference at
virtual address 00000068
 printing eip:
c0157cd9
*pde = 00000000
Oops: 0000 [#1]
SMP
Modules linked in: hallo
CPU:    0
EIP:    0060:[<c0157cd9>]    Not tainted VLI
EFLAGS: 00010286   (2.6.20-default #4)
EIP is at rt_task_start+0x25/0x13e
eax: 00000060   ebx: 00000000   ecx: 00000000   edx: 00000286
esi: c8010780   edi: c118716c   ebp: 00000000   esp: c119de88
ds: 007b   es: 007b   ss: 0068
Process insmod (pid: 346, ti=c119c000 task=c77ccb10 task.ti=c119c000)
Stack: c011d8ea c800f088 c119deb0 c800f031 c118714c c1187000 c118716c
c800f580
       c800f021 c800f088 c0136cc4 c800f5c8 c033bda6 c800f58c 00000000
00001524
       00000230 c77fbba0 00000260 c0190271 00000000 00000000 00000000
00000000
Call Trace:
 [<c011d8ea>] printk+0x62/0xd6
 [<c800f031>] fun+0x0/0x57 [hallo]
 [<c800f021>] hello_init+0x20/0x30 [hallo]
 [<c0136cc4>] sys_init_module+0x1771/0x18b8
 [<c0190271>] do_sync_read+0xc7/0x10a
 [<c019f0bb>] dput+0x49/0x11f
 [<c0102dbf>] syscall_call+0x7/0xb
 =======================
Code: d8 5b 5e 5f 5d c3 55 57 56 53 83 ec 10 89 c6 8b 1d bc bc 46 c0 89
cd 89 54 24 0c ff 15 44 aa 37 c0 69 c0 c0 03 00 00 8d 44 18 60 <8b> 40
08 85
EIP: [<c0157cd9>] rt_task_start+0x25/0x13e SS:ESP 0068:c119de88
 Segmentation fault




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

* Re: [Xenomai-help] loading module
  2007-05-23 12:16 [Xenomai-help] loading module Rodolfo
@ 2007-05-23 12:34 ` Gilles Chanteperdrix
  2007-05-23 12:49   ` Rodolfo
       [not found]   ` <46543535.5090106@domain.hid>
  0 siblings, 2 replies; 8+ messages in thread
From: Gilles Chanteperdrix @ 2007-05-23 12:34 UTC (permalink / raw)
  To: Rodolfo; +Cc: xenomai

Rodolfo wrote:
> Hi,
> I am totally new to Xenomai and have no experience with RTAI. I'm trying
> to load a kernel module that uses the native API for testing, but I get
> the following segmentation fault. Can anyone help me out??

Please post here the sources of your module.

-- 
                                                 Gilles Chanteperdrix


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

* Re: [Xenomai-help] loading module
  2007-05-23 12:34 ` Gilles Chanteperdrix
@ 2007-05-23 12:49   ` Rodolfo
  2007-05-23 13:13     ` Gilles Chanteperdrix
       [not found]     ` <1179925338.6119.56.camel@domain.hid>
       [not found]   ` <46543535.5090106@domain.hid>
  1 sibling, 2 replies; 8+ messages in thread
From: Rodolfo @ 2007-05-23 12:49 UTC (permalink / raw)
  To: xenomai

here's the source of the testing module.

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <native/task.h>
#include <native/types.h>
#include <native/timer.h>
#include <rtdm/rtdm_driver.h>
#include <nucleus/pod.h>

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Hello World Xenomai Application");

/************************* Global Variables ******************************/

RT_TASK thread;
RTIME timer_period_ns;
RTIME task_period_ns;
RTIME expected;
int timer_period_counts;
unsigned long overrun; // rt_task_wait_period() writes here overrun
count.0 if everything OK

/************************* Periodic realtime thread **********************/

void fun(int dummy) {
    int count = 0;
    while(1) {
        ++count;
        rt_task_wait_period(&overrun);
        if ((count%100)==0) {
            rtdm_printk("Periode %d ist abgelaufen\n",count);
        }
    }
}

/************************* Initialisation *******************************/

static int hello_init(void)
{
    //testing rt_task_create(...);
    int count = 0;
    printk("task create");
    rt_task_create(&thread,"fun_task",3000,1,0);
    printk("created..");
    printk("task start");
    rt_task_start(&thread,fun,0);
    printk("started........");



    //timer_period_ns = 10000000;/*10ms*/
    /*timer_period_counts = start_rt_timer(nano2count(timer_period_ns));*/

//timer_period_counts=rt_timer_set_mode(rt_timer_ns2tsc(timer_period_ns));
    /* Calculate the start time for the task. */
    /* We set this to "now plus 10 periods"   */
    //expected = xnpod_get_time()  + 10 * timer_period_counts;

    /* Task period initialization */
    //task_period_ns =50000000;/*5ms*/
    /*rt_task_make_periodic(&thread, expected,
nano2count(task_period_ns));*/
    //rt_task_set_periodic(&thread, expected,
rt_timer_ns2tsc(task_period_ns));
    return 0;
}

/************************* Cleanup *********************************/

static void hello_exit(void)
{
  /*stop_rt_timer();*/

  /* Now delete our task */
 // rt_task_delete(&thread);
}

module_init(hello_init);
module_exit(hello_exit);


Gilles Chanteperdrix wrote:
> Rodolfo wrote:
>   
>> Hi,
>> I am totally new to Xenomai and have no experience with RTAI. I'm trying
>> to load a kernel module that uses the native API for testing, but I get
>> the following segmentation fault. Can anyone help me out??
>>     
>
> Please post here the sources of your module.
>
>   




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

* Re: [Xenomai-help] loading module
       [not found]   ` <46543535.5090106@domain.hid>
@ 2007-05-23 13:07     ` Gilles Chanteperdrix
  2007-05-23 13:32       ` Rodolfo
  0 siblings, 1 reply; 8+ messages in thread
From: Gilles Chanteperdrix @ 2007-05-23 13:07 UTC (permalink / raw)
  To: Rodolfo; +Cc: Xenomai help

Rodolfo wrote:
> Gilles Chanteperdrix wrote:
> 
>>Rodolfo wrote:
>>  
>>
>>>Hi,
>>>I am totally new to Xenomai and have no experience with RTAI. I'm trying
>>>to load a kernel module that uses the native API for testing, but I get
>>>the following segmentation fault. Can anyone help me out??
>>>    
>>
>>Please post here the sources of your module.
>>
>>  
> 
> 
> 
> here's the source of the testing module.
> 
> #include <linux/module.h>
> #include <linux/kernel.h>
> #include <linux/proc_fs.h>
> #include <native/task.h>
> #include <native/types.h>
> #include <native/timer.h>
> #include <rtdm/rtdm_driver.h>
> #include <nucleus/pod.h>
>  
> MODULE_LICENSE("GPL");
> MODULE_DESCRIPTION("Hello World Xenomai Application");
>  
> /************************* Global Variables ******************************/
>  
> RT_TASK thread;
> RTIME timer_period_ns;
> RTIME task_period_ns;
> RTIME expected;
> int timer_period_counts;
> unsigned long overrun; // rt_task_wait_period() writes here overrun
> count.0 if everything OK
>  
> /************************* Periodic realtime thread **********************/
>  
> void fun(int dummy) {
>     int count = 0;
>     while(1) {
>         ++count;
>         rt_task_wait_period(&overrun);

Before calling rt_task_wait_period, you should have called
rt_task_set_periodic. Here, rt_task_wait_period will continuously return
 -EWOULDBLOCK and you will get a hard lockup.

>         if ((count%100)==0) {
>             rtdm_printk("Periode %d ist abgelaufen\n",count);
>         }
>     }
> }
>  
> /************************* Initialisation *******************************/
>  
> static int hello_init(void)
> {
>     //testing rt_task_create(...);
>     int count = 0;
>     printk("task create");
>     rt_task_create(&thread,"fun_task",3000,1,0);
>     printk("created..");
>     printk("task start");
>     rt_task_start(&thread,fun,0);

At this point you do not know if rt_task_create succeeded, since you did
not check its return value.

>     printk("started........");
>  
>      
>  
>     //timer_period_ns = 10000000;/*10ms*/
>     /*timer_period_counts = start_rt_timer(nano2count(timer_period_ns));*/
>    
> //timer_period_counts=rt_timer_set_mode(rt_timer_ns2tsc(timer_period_ns));

Setting the timer to periodic mode results in a lower timer resolution.
Aperiodic mode, the default is usually fine.

>     /* Calculate the start time for the task. */
>     /* We set this to "now plus 10 periods"   */
>     //expected = xnpod_get_time()  + 10 * timer_period_counts;

xnpod_get_time is not part of the native API, what you want is
rt_timer_read.

>  
>     /* Task period initialization */
>     //task_period_ns =50000000;/*5ms*/
>     /*rt_task_make_periodic(&thread, expected,
> nano2count(task_period_ns));*/
>     //rt_task_set_periodic(&thread, expected,
> rt_timer_ns2tsc(task_period_ns));
>     return 0;
> }
>  
> /************************* Cleanup *********************************/
>  
> static void hello_exit(void)
> {
>   /*stop_rt_timer();*/
>  
>   /* Now delete our task */
>  // rt_task_delete(&thread);
> }
>  
> module_init(hello_init);
> module_exit(hello_exit);

Why do you want to use Xenomai in kernel-space ? Since, as you said it,
you are a beginner, you should use Xenomai in user-space. There, gdb
will help you debug your segmentation faults.

-- 
                                                 Gilles Chanteperdrix


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

* Re: [Xenomai-help] loading module
  2007-05-23 12:49   ` Rodolfo
@ 2007-05-23 13:13     ` Gilles Chanteperdrix
       [not found]     ` <1179925338.6119.56.camel@domain.hid>
  1 sibling, 0 replies; 8+ messages in thread
From: Gilles Chanteperdrix @ 2007-05-23 13:13 UTC (permalink / raw)
  To: Rodolfo; +Cc: xenomai

Rodolfo wrote:
> //timer_period_counts=rt_timer_set_mode(rt_timer_ns2tsc(timer_period_ns));

See
http://www.xenomai.org/documentation/branches/v2.3.x/html/api/group__native__timer.html#gffcb5eaef6c3a64a05445f6dafdbb155

the parameter of rt_timer_set_mode is a count of nanoseconds.

>     //rt_task_set_periodic(&thread, expected,
> rt_timer_ns2tsc(task_period_ns));

the task period passed to rt_task_set_periodic is a count of ticks,
which should be obtained with rt_timer_ns2ticks.

-- 
                                                 Gilles Chanteperdrix


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

* Re: [Xenomai-help] loading module
       [not found]     ` <1179925338.6119.56.camel@domain.hid>
@ 2007-05-23 13:31       ` Rodolfo
  0 siblings, 0 replies; 8+ messages in thread
From: Rodolfo @ 2007-05-23 13:31 UTC (permalink / raw)
  To: Xenomai-help

I got it to work with your example module, I recompiled the kernel
without SMP support and it loaded.
I have to take a closer look at my own code now.
Thank you Peter and Gilles for your help.

Peter Feuerer wrote:
> Hi Rudolfo,
>
> I wrote a little text module some days ago, which does nearly the same
> like yours. I uploaded it to http://piie.net/files/xn-krn.tar.gz for
> you.
>
> You should edit the line with the kernelpath of the Makefile.
> gl & hf
> --peter
>
> On Wed, 2007-05-23 at 14:49 +0200, Rodolfo wrote:
>   
>> here's the source of the testing module.
>>
>> #include <linux/module.h>
>> #include <linux/kernel.h>
>> #include <linux/proc_fs.h>
>> #include <native/task.h>
>> #include <native/types.h>
>> #include <native/timer.h>
>> #include <rtdm/rtdm_driver.h>
>> #include <nucleus/pod.h>
>>
>> MODULE_LICENSE("GPL");
>> MODULE_DESCRIPTION("Hello World Xenomai Application");
>>
>> /************************* Global Variables ******************************/
>>
>> RT_TASK thread;
>> RTIME timer_period_ns;
>> RTIME task_period_ns;
>> RTIME expected;
>> int timer_period_counts;
>> unsigned long overrun; // rt_task_wait_period() writes here overrun
>> count.0 if everything OK
>>
>> /************************* Periodic realtime thread **********************/
>>
>> void fun(int dummy) {
>>     int count = 0;
>>     while(1) {
>>         ++count;
>>         rt_task_wait_period(&overrun);
>>         if ((count%100)==0) {
>>             rtdm_printk("Periode %d ist abgelaufen\n",count);
>>         }
>>     }
>> }
>>
>> /************************* Initialisation *******************************/
>>
>> static int hello_init(void)
>> {
>>     //testing rt_task_create(...);
>>     int count = 0;
>>     printk("task create");
>>     rt_task_create(&thread,"fun_task",3000,1,0);
>>     printk("created..");
>>     printk("task start");
>>     rt_task_start(&thread,fun,0);
>>     printk("started........");
>>
>>
>>
>>     //timer_period_ns = 10000000;/*10ms*/
>>     /*timer_period_counts = start_rt_timer(nano2count(timer_period_ns));*/
>>
>> //timer_period_counts=rt_timer_set_mode(rt_timer_ns2tsc(timer_period_ns));
>>     /* Calculate the start time for the task. */
>>     /* We set this to "now plus 10 periods"   */
>>     //expected = xnpod_get_time()  + 10 * timer_period_counts;
>>
>>     /* Task period initialization */
>>     //task_period_ns =50000000;/*5ms*/
>>     /*rt_task_make_periodic(&thread, expected,
>> nano2count(task_period_ns));*/
>>     //rt_task_set_periodic(&thread, expected,
>> rt_timer_ns2tsc(task_period_ns));
>>     return 0;
>> }
>>
>> /************************* Cleanup *********************************/
>>
>> static void hello_exit(void)
>> {
>>   /*stop_rt_timer();*/
>>
>>   /* Now delete our task */
>>  // rt_task_delete(&thread);
>> }
>>
>> module_init(hello_init);
>> module_exit(hello_exit);
>>
>>
>> Gilles Chanteperdrix wrote:
>>     
>>> Rodolfo wrote:
>>>   
>>>       
>>>> Hi,
>>>> I am totally new to Xenomai and have no experience with RTAI. I'm trying
>>>> to load a kernel module that uses the native API for testing, but I get
>>>> the following segmentation fault. Can anyone help me out??
>>>>     
>>>>         
>>> Please post here the sources of your module.
>>>
>>>   
>>>       
>>
>> _______________________________________________
>> Xenomai-help mailing list
>> Xenomai-help@domain.hid
>> https://mail.gna.org/listinfo/xenomai-help
>>
>>     
>
>
>   



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

* Re: [Xenomai-help] loading module
  2007-05-23 13:07     ` Gilles Chanteperdrix
@ 2007-05-23 13:32       ` Rodolfo
  2007-05-23 13:44         ` Gilles Chanteperdrix
  0 siblings, 1 reply; 8+ messages in thread
From: Rodolfo @ 2007-05-23 13:32 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai help

Gilles Chanteperdrix wrote:
> Why do you want to use Xenomai in kernel-space ? Since, as you said it,
> you are a beginner, you should use Xenomai in user-space. There, gdb
> will help you debug your segmentation faults.
I actually want to compare latencies between User-Space RT Tasks and
Kernel RT Tasks.


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

* Re: [Xenomai-help] loading module
  2007-05-23 13:32       ` Rodolfo
@ 2007-05-23 13:44         ` Gilles Chanteperdrix
  0 siblings, 0 replies; 8+ messages in thread
From: Gilles Chanteperdrix @ 2007-05-23 13:44 UTC (permalink / raw)
  To: Rodolfo; +Cc: Xenomai help

Rodolfo wrote:
> Gilles Chanteperdrix wrote:
> 
>>Why do you want to use Xenomai in kernel-space ? Since, as you said it,
>>you are a beginner, you should use Xenomai in user-space. There, gdb
>>will help you debug your segmentation faults.
> 
> I actually want to compare latencies between User-Space RT Tasks and
> Kernel RT Tasks.
> 

I would advise starting in user-space, adapting from user-space to
kernel-space will then be straightforward.

If you want to compare latencies between user-space and kernel-space,
you may have a look at the "latency" test. latency -t 0 outputs the
user-space latency, latency -t 1 outputs the kernel-space latency.

-- 
                                                 Gilles Chanteperdrix


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

end of thread, other threads:[~2007-05-23 13:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-23 12:16 [Xenomai-help] loading module Rodolfo
2007-05-23 12:34 ` Gilles Chanteperdrix
2007-05-23 12:49   ` Rodolfo
2007-05-23 13:13     ` Gilles Chanteperdrix
     [not found]     ` <1179925338.6119.56.camel@domain.hid>
2007-05-23 13:31       ` Rodolfo
     [not found]   ` <46543535.5090106@domain.hid>
2007-05-23 13:07     ` Gilles Chanteperdrix
2007-05-23 13:32       ` Rodolfo
2007-05-23 13:44         ` Gilles Chanteperdrix

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.