All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Segmentation Fault when writing in registers (AT91SAM - ARM9)
@ 2011-01-25  2:33 at91_enthus
  2011-01-25  2:36 ` Gilles Chanteperdrix
  2011-01-25  2:41 ` Gilles Chanteperdrix
  0 siblings, 2 replies; 21+ messages in thread
From: at91_enthus @ 2011-01-25  2:33 UTC (permalink / raw)
  To: xenomai-help

[-- Attachment #1: Type: text/plain, Size: 1347 bytes --]

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)) {
        ...
    }

     *((unsigned int *) (piob_base + PIO_IDR ))  = 1<<0; // Segmentation
Fault occurs here
     *((unsigned int *) (piob_base + PIO_PER))  = 1<<0;
     ...
}
---------------------------------------------------------

Thank you,
R.

[-- Attachment #2: Type: text/html, Size: 1648 bytes --]

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

end of thread, other threads:[~2011-01-25  9:38 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.