All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: at91_enthus <nwromania@domain.hid>
Cc: xenomai-help <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] Segmentation Fault when writing in registers (AT91SAM - ARM9)
Date: Tue, 25 Jan 2011 05:54:03 +0100	[thread overview]
Message-ID: <4D3E576B.7060208@domain.hid> (raw)
In-Reply-To: <AANLkTimxTLpGR6KvVBuermWiaqwkuod7QQxNVBXrmtyd@domain.hid>

at91_enthus wrote:
> On Mon, Jan 24, 2011 at 10:28 PM, Gilles Chanteperdrix <
> gilles.chanteperdrix@xenomai.org> wrote:
> 
>> at91_enthus wrote:
>>> On Mon, Jan 24, 2011 at 10:16 PM, Gilles Chanteperdrix <
>>> gilles.chanteperdrix@xenomai.org> wrote:
>>>
>>>> at91_enthus wrote:
>>>>> On Mon, Jan 24, 2011 at 9:25 PM, Gilles Chanteperdrix <
>>>>> gilles.chanteperdrix@xenomai.org> wrote:
>>>>>
>>>>>> at91_enthus wrote:
>>>>>>> On Mon, Jan 24, 2011 at 8:41 PM, Gilles Chanteperdrix <
>>>>>>> gilles.chanteperdrix@xenomai.org> wrote:
>>>>>>>
>>>>>>>> at91_enthus wrote:
>>>>>>>>> Hi.
>>>>>>>>>
>>>>>>>>> I  was testing Xenomai on my AT91SAM9G20-based board and tried to
>>>> adapt
>>>>>>>> the
>>>>>>>>> code found here:
>>>>>>>>> http://www.armadeus.com/wiki/index.php?title=Xenomai:Blinking_LEDs.
>>>>>>>> By the way, this code is ridiculous. It creates a real-time task to
>>>>>>>> write to some non real-time device, which makes the real-time task
>>>>>> useless.
>>>>>>> I know.
>>>>>> Yes, but this example is bad in many ways:
>>>>>> - first it uses xenomai api to create a real-time task, and uses write
>>>>>> which causes the real-time task to switch to secondary domain;
>>>>>> - the Makefile does not use xeno-config, which have been the
>> recommended
>>>>>> way of getting the compiler flags since day 1;
>>>>>> - it nullifies SIGTERM and SIGINT, which is a dubious decision, and
>>>>>> could lead people to believe that they should do the same when using
>>>>>> Xenomai, whereas there is no such requirement.
>>>>>> - the pointers point to outdated version of the documentation.
>>>>>> - it uses runinfo/xeno-load, which are kind of outdated too, make
>> things
>>>>>> uselessly complicated, and in any case, tell you to type Ctrl-C to
>>>>>> interrupt the program, which is bound to fail if anything goes wrong,
>>>>>> since SIGINT is neutralized in the program.
>>>>>>
>>>>>>> That's why I went to mmap().
>>>>>> That is not really the right solution either. I admit that for driving
>>>>>> leds, it may be a bit overkill, but anyway, what you should do is
>> write
>>>>>> an RTDM driver for driving the leds. Keeping the driver separated from
>>>>>> the application will allow the same program to run on other platforms
>>>>>> where driving the LEDS is done differently without changing much of
>> the
>>>>>> application code. In other word, the application/driver separation is
>> a
>>>>>> sane one.
>>>>>>
>>>>>> Anyway, mmap should work.
>>>>>>
>>>>>>  (I chose that sample code because, for
>>>>>>> now, I am only learning to use basic functions)
>>>>>>>> Wrong test here. Should be "if (aic_base == MAP_FAILED)"
>>>>>>> Indeed, my program fails miserably when I check the mapping of AIC,
>> not
>>>>>>> PIOB's. And yet, I just can't figure why in the non-Xenomai code, AIC
>>>>>>> mmap-ing works  fine.
>>>>>> Well errno might give you a clue. Do you have FCSE enabled?
>>>>>>
>>>>>> Regards.
>>>>>>
>>>>>> --
>>>>>>
>> Gilles.
>>>>> FCSE is enabled. errno returns  22 (invalid argument).
>>>> best effort or guaranteed?
>>>
>>> Best effort
>>>
>>>
>>>> Please activate FCSE messages.
>>>
>>> ... compiling new kernel
>>>
>>>
>>>> How big is
>>>> MAP_SIZE?
>>>>
>>>>
>>> 4096
>> Ok. Could you post your full kernel configuration, as well as the full
>> program?
>>
> 
> I put the .config and the code in the attachments.

If you remove all the native skin stuff, only keep main and
open_controller, do not link with the native library, you can confirm
that this same program runs without trouble?

-- 
                                                                Gilles.


  parent reply	other threads:[~2011-01-25  4:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25  2:33 [Xenomai-help] Segmentation Fault when writing in registers (AT91SAM - ARM9) at91_enthus
2011-01-25  2:36 ` Gilles Chanteperdrix
2011-01-25  2:41 ` Gilles Chanteperdrix
2011-01-25  3:13   ` at91_enthus
2011-01-25  3:25     ` Gilles Chanteperdrix
2011-01-25  4:14       ` at91_enthus
2011-01-25  4:16         ` Gilles Chanteperdrix
2011-01-25  4:23           ` at91_enthus
2011-01-25  4:28             ` Gilles Chanteperdrix
2011-01-25  4:44               ` at91_enthus
2011-01-25  4:49                 ` Gilles Chanteperdrix
2011-01-25  4:54                 ` Gilles Chanteperdrix [this message]
2011-01-25  5:00                   ` at91_enthus
2011-01-25  5:02                     ` Gilles Chanteperdrix
2011-01-25  5:08                       ` at91_enthus
2011-01-25  5:12                         ` Gilles Chanteperdrix
2011-01-25  5:32                           ` at91_enthus
2011-01-25  6:20                             ` Gilles Chanteperdrix
2011-01-25  6:45                               ` at91_enthus
2011-01-25  6:51                                 ` Gilles Chanteperdrix
2011-01-25  9:38                                   ` at91_enthus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D3E576B.7060208@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=nwromania@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.