Hi,
When you use mmap you should always use a page aligned base address
and then add an offset to the returned pointer.
Thus:
spi_ioptr = (unsigned long)mmap(0, getpagesize(),
PROT_READ|PROT_WRITE, MAP_SHARED, spi_fd, 0x600FF084);
should be:
volatile unsigned long *spi_ioptr
spi_ioptr = (unsigned long)mmap(0, getpagesize(),
PROT_READ|PROT_WRITE, MAP_SHARED, spi_fd, 0x600FF000);
<check it's assigned correctly here>
spi_ioptr += spi_ioptr (0x84/sizeof(unsigned long));
You then access the data via spi_ioptr[offset];
Hope this helps.
PJE
--- In "jtckendrick" <> wrote:
>
> I am having an issue with getting access to the memory area
specified.
> When I try to write to that area of memory I get SIGSEGV faults. I
am
> referencing the TS7350 preliminary manual. Here is a sample of the
code.
> spi_fd is integer type and spi_ioptr it unsigned long. SPI_IOBASE
is
> defined as 0x600FF084.
>
> spi_fd = open("/dev/mem", O_RDWR|O_SYNC);
>
> spi_ioptr = (unsigned long)mmap(0, getpagesize(),
PROT_READ|PROT_WRITE,spi_fd, SPI_IOBASE);
>
>
> assert(&spi_ioptr != MAP_FAILED);
>
> PEEK32(spi_ioptr,1);
>
> SIGSEGV is thrown on PEEK32
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|