You can try only map 4Bytes

2015-05-22 3:13 GMT+08:00 Jacek Radzikowski <jacek.radzikow...@gmail.com>:

> Clocks for some of the GPIO modules are not enabled by default, and
> accessing them will cause BUS error. The easiest workaround is to
> export one pin from each of the modules using /sys interface:
> https://groups.google.com/d/msg/beagleboard/OYFp4EXawiI/Mq6s3sg14HoJ
> Here is a short script which does the job:
> https://github.com/piranha32/IOoo/blob/master/tools/bbb_enable_gpio.sh
>
> Regards,
> j.
>
>
> On Thu, May 21, 2015 at 2:59 PM,  <ja...@dfsoftware.com> wrote:
> > I've been working to get the access to the GPIO registers to replace the
> > existing sys access we are using now. However, I'm crashing accessing
> both
> > GPIO 2 and 3 (1 and 2 appear fine). I'm sure I'm just doing something
> > stupid. Here is some basic setup:
> >
> > __off_t MUX_OFFSET[] = {
> >     0x44E07000, // GPIO 0
> >     0x4804C000, // GPIO 1
> >     0x481AC000, // GPIO 2
> >     0x481AE000  // GPIO 3
> > };
> >
> > struct MUX_LAYOUT
> > {
> >     uint8_t *gpio_addr;
> >     uint32_t *gpio_oe_addr;
> >     uint32_t *gpio_setdataout_addr;
> >     uint32_t *gpio_cleardataout_addr;
> >     uint32_t *gpio_dataout_addr;
> >     uint32_t *gpio_datain_addr;
> > };
> >
> > MUX_LAYOUT MUXes[4];
> >
> > #define GPIO_MEM_LENGTH 0xfff
> > #define GPIO_OE 0x134
> > #define GPIO_SETDATAOUT 0x194
> > #define GPIO_CLEARDATAOUT 0x190
> > #define GPIO_DATAOUT 0x13C
> > #define GPIO_DATAIN 0x138
> >
> > Then here is example code that will always crash on accessing GPIO 2:
> >
> > fd = open("/dev/mem", O_RDWR);
> >
> > for( size_t gpio = 0; gpio < 4; ++gpio)
> > {
> >     MUX_LAYOUT& mux = MUXes[gpio];
> >
> >     mux.gpio_addr = (uint8_t*)mmap(0, GPIO_MEM_LENGTH, PROT_READ |
> > PROT_WRITE, MAP_SHARED, fd, MUX_OFFSET[gpio]);
> >
> >     if(mux.gpio_addr == MAP_FAILED)
> >     {
> >         throw MSC_EXCEPTION("Unable to map texpr PIO");
> >     }
> >
> >     mux.gpio_oe_addr           = (uint32_t *)(mux.gpio_addr + GPIO_OE);
> >     mux.gpio_setdataout_addr   = (uint32_t *)(mux.gpio_addr +
> > GPIO_SETDATAOUT);
> >     mux.gpio_cleardataout_addr = (uint32_t *)(mux.gpio_addr +
> > GPIO_CLEARDATAOUT);
> >     mux.gpio_dataout_addr      = (uint32_t *)(mux.gpio_addr +
> GPIO_DATAOUT);
> >     mux.gpio_datain_addr       = (uint32_t *)(mux.gpio_addr +
> GPIO_DATAIN);
> >
> >     // Crashes here when gpio == 2
> >     uint32_t temp = *mux.gpio_datain_addr;
> > }
> >
> > In this case I'm crashing dereferencing gpio_datain_addr, but it will
> crash
> > accessing any of the pointers created when setting up GPIO 2 and 3. Any
> > thoughts? I'm running a relatively current debian build.
> >
> > Thanks for the help,
> >
> > Jared
> >
> > --
> > 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 beagleboard+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Given a choice between two theories, take the one which is funnier
>
> --
> 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 beagleboard+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 beagleboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to