Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    crash when read/write mapped io registers


    I am using mmap() in user space to access SPI registers in the OMAP3530.

    The physical address is 0x48098000 (OMAP_MCSPI1_BASE) which is the start of the McSPI1 registers. mmap works fine. But when I try to print out the register values I got

    Unhandled fault: external abort on non-linefetch (0x101 at 0x4002100c Bus error

    I have seen some posts which had the same issue but I haven't seen any reply or solution to it. Can anyone help please? Any suggestion would be appreciated.

    Here is the code:

    fd = open("/dev/mem", O_RDWR);
    if (fd == -1)
    printf("open() failed!\n");
    return -1;

    mmap_addr = mmap(NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd,mem_start);
    if (mmap_addr == MAP_FAILED) {
    printf("gpio mmap() failed!\n");

    ptr = (unsigned int *)(mmap_addr) ;
    printf(" 0x%08x mapped to %p (%p)\n", OMAP_MCSPI1_BASE, mmap_addr, ptr) ;

    ptr+=4 ; // skip the first 4 registers and start from SCR register
    printf("%p 0x08x\n", ptr, *ptr) ; ptr ++ ;
    printf("%p 0x08x\n", ptr, *ptr) ; ptr ++ ;


    I also tried similar code to map the GPIO registers, it worked fine and I could do read/write with those GPIO registers.

    Many thanks.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Are you sure that the start address is a multiple of the system page size (usually 4 kbytes)?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts