Pada Selasa, 28 Oktober 2014 01.39.00 UTC+8, Nic Cyn  menulis:
> I am trying to access, via mmap on /dev/mem, the GPIOs at addresses 
> 0x44e07000, 0x4804c000, 0x481ac000 and 0x481ae000. These are GPIO banks 0,1,2 
> and 3 respectively. 
> 
> Access is successful on GPIO bank 0 and 1 (0x44e07000 and 0x4804c000) but 
> fails consistently with a "Bus Error" on GPIO bank 2 and 3 (0x481ac000 and 
> 0x481ae000). 
> 
> Does anybody have any idea why this might be happening? Sample C code which 
> reproduces the error below - basically it is trying to read the GPIO_REVISION 
> at offset 0 at the start of each GPIO bank. The expected value returned 
> should be 0x50600801 - but a "Bus Error" is returned for GPIO banks 2 and 3.
> 
> This seems to happen on standard 3.8.13-bone47 on a BBB rev C right out of 
> the CircuitCo box and also on an 3.14 ubuntu kernel.
> 
> I would really appreciate any insights you may have
> 
> 
> 
> // c code to test access to the /dev/mem file
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <sys/mman.h>
> 
> #define GPIO_BANK_0           0x44E07000
> #define GPIO_BANK_1           0x4804C000
> #define GPIO_BANK_2           0x481AC000
> #define GPIO_BANK_3           0x481AE000
> 
> int gpio_mmap_test(int gpioBank, int sizeToFetch);
> 
> int main()
> {
>     gpio_mmap_test(GPIO_BANK_0, 0xfff);
>     gpio_mmap_test(GPIO_BANK_1, 0xfff);
>     gpio_mmap_test(GPIO_BANK_2, 0xfff);
>     gpio_mmap_test(GPIO_BANK_3, 0xfff);
>     return 0;
> }
> 
> int gpio_mmap_test(int gpioBank, int sizeToFetch)
> {
> 
>    int gpio_fd2 = open("/dev/mem", O_RDWR | O_SYNC);
> 
>    if (gpio_fd2 < 0)
>    {
>       printf("Could not open GPIO memory fd\n");
>       return 0;
>    }
> 
>    volatile ulong *gpio;
> 
>    gpio = (ulong*) mmap(NULL, sizeToFetch, PROT_READ | PROT_WRITE, 
> MAP_SHARED, gpio_fd2, gpioBank);
>    if (gpio == MAP_FAILED)
>    {
>       printf ("GPIO Mapping failed\n");
>       close(gpio_fd2);
>       return 0;
>    }
> 
>    //  offset 0 is the GPIO_REVISION field
>    //  expected value is 0x50600801
>    int gpioRevision = gpio[0];
> 
>    printf("bank %04x, gpioRevision = %04x\n", gpioBank, gpioRevision);
> 
>    close(gpio_fd2);
> }

World Bank 

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/5fe6a150-e7cd-43f5-a427-2cad15993285%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to