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 03:36:31 +0100 [thread overview]
Message-ID: <4D3E372F.8060500@domain.hid> (raw)
In-Reply-To: <AANLkTi=wo34Zr40GZ+HKegcFKYYcDqj8uzgEqyDCqDj=@mail.gmail.com>
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 .
> The only difference between my code and theirs was the access to hardware. I
> used open("/dev/mem", ...) and mmap().
> The program compiles fine and both functions are executed. However, when I
> place values in PIO registers, I get Segmentation Fault.
>
> I tested my code without Xenomai and it does what it is suppose to do.
>
> Here's the configuration of my system:
> Processor: AT91SAM9G20
> Xenomai version: 2.5.5.2
> Kernel: 2.6.33-5
> GCC 4.3.2 (I compile the code on the board)
>
> ---------------- Code snippet -------------------
> unsigned char *pioa_base, *aic_base;
>
> void open_controller(){
>
>
> if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1)
> {
> ....
> }
> printf("/dev/mem opened.\n");
>
> /* mapping of PIOB */
> aic_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
> AT91C_BASE_PIOB & (~MAP_MASK));
> piob_base = aic_base + AT91C_BASE_PIOB - AT91C_BASE_AIC;
>
> if( (pioa_base == (void *) -1)) {
> ...
> }
Wrong test here. Should be "if (aic_base == MAP_FAILED)"
--
Gilles.
next prev parent reply other threads:[~2011-01-25 2:36 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 [this message]
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
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=4D3E372F.8060500@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.