Results 1 to 2 of 2
Hi ,
I executed the LED getting started code from atmel in the target board but it
was giving the following error:
root@at91sam9263ek:/var/volatile/tmp$
./getting-started-project-at91sam9260-ek-at91sam9260-sdram.elf
Segmentation fault
root@at91sam9263ek:/var/volatile/tmp$
this code has ...
- 11-28-2008 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 1
LED code error
Hi ,
I executed the LED getting started code from atmel in the target board but it
was giving the following error:
root@at91sam9263ek:/var/volatile/tmp$
./getting-started-project-at91sam9260-ek-at91sam9260-sdram.elf
Segmentation fault
root@at91sam9263ek:/var/volatile/tmp$
this code has been downloaded from
Atmel Products - Tools & Software
(AT91SAM9260-EK Software Package)
and code is below here
/******** LED PROGRAM ************/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include <strings.h>
#include <string.h>
#include <time.h>
#include "AT91SAM9260.h"
#define LED_MAX 2
static unsigned ledSignalMapping[] = { AT91C_PIO_PA5, AT91C_PIO_PA9};
#define GPIO_LED_MASK (AT91C_PIO_PA5 | AT91C_PIO_PA9)
//static int memMapFile;
static AT91PS_PIO at91cBasePIOA;
static void UpdateLED(unsigned ledIndex, unsigned on)
{
if (ledIndex >= LED_MAX)
return ;
if (on)
{
at91cBasePIOA->PIO_CODR = (ledSignalMapping[ledIndex]);
}
else
{
at91cBasePIOA->PIO_SODR = (ledSignalMapping[ledIndex]);
}
}
static int OpenSystemController(void)
{
if ((memMapFile = open("/dev/mem", O_RDWR | O_SYNC)) < 0)
{
printf("ERROR: Unable to open /dev/mem\n");
return (errno);
}
at91cBasePIOA = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, memMapFile, (unsigned)AT91C_BASE_PIOA);
if (at91cBasePIOA == MAP_FAILED)
{
printf("ERROR: Unable to mmap the system controller\n");
close (memMapFile);
memMapFile = -1;
return (errno);
}
at91cBasePIOA->PIO_CODR = GPIO_LED_MASK;
at91cBasePIOA->PIO_PPUDR = GPIO_LED_MASK;
at91cBasePIOA->PIO_PER = GPIO_LED_MASK;
at91cBasePIOA->PIO_OER = GPIO_LED_MASK;
return (0);
}
int main(int argc, char **argv)
{
unsigned ledIndex;
printf("Hello\n");
if (OpenSystemController())
{
printf("Unable to map hardware resources\n");
return (-1);
}
ledIndex = 0;
while (1)
{
UpdateLED(ledIndex, 1);
printf ("LED %d is now on\n", ledIndex);
usleep(500000);
UpdateLED(ledIndex, 0);
printf ("LED %d is now off\n", ledIndex);
usleep(500000);
if (++ledIndex >= LED_MAX)
ledIndex = 0;
}
return (0);
}
please help this issue.
- 11-28-2008 #2
Since not even the printf() at the beginning of main() seems to be working, this makes no sense at all. I have two suggestions.
- Run this program under gdb, stepping through each source code line to see how far you really get and where it blows up.
- If that doesn't help you at all, go to the amtel site's discussion forums and ask your question there.
--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote