Hello everyone,

I am a little bit late in this topic, but I would like to share what I have 
found.
The problem is basically the clock. Once we boot our BBB, clocking systems 
for GPIO 1, 2 and 3 are disabled (GPIO0 will be always enabled).

We can enable them by:
- Exporting any pin on each port (and then the system enables the clock 
automatically);
- Modifying and setting some bits in the register CM_PER_GPIOx_CLKCTRL 
(AM335x Technical Ref Manual - pages 1195, 1196 and 1197).


Some registers from CM_PER (Clock Management - Peripherals) will enable the 
clock for each module.
You can find GPIO1 with an offset 0xAC, for example.
Setting bit 1 will enable the clock for this module so that we will be able 
to read/write GPIO0 through memory mapping.


You can change the values from this register by mapping it, just like you 
did for setting/clearing a bit on a gpio.



Hope it helps!


Regards,
Patricia.




Luigi very good, I also had this problem, and your solution worked for me 
> also.
>
> But I still do not understand why it is necessary to export at least one 
> pin on each port to be able to access the GPIO with mmap.
> Someone can explain me?
>
> Em terça-feira, 11 de junho de 2013 23h41min10s UTC-3, Jacek Radzikowski 
> escreveu:
>>
>> Hello, 
>>
>> I'm getting bus errors whenever my program tries to access registers 
>> controlling pins on GPIOs 0,2 or 3. I'm not trying to set pinmuxing, I 
>> try to write to registers controlling the pins. 
>> GPIO1 works fine and I can enable outputs by writing to the OE 
>> register and change the values on the pins by writing to the OUT 
>> register. 
>>
>> Here are some details of my simple test program: 
>> The base addresses for the GPIO blocks are defined as follows: 
>>         const uint32_t gpioAddrs[] = 
>>                 { 0x44E07000, 0x4804C000, 0x481AC000, 0x481AE000 }; 
>>
>> The memory blocks are mapped to process address space with the following 
>> mmap: 
>>         gpios[i] = (uint32_t *) mmap(NULL, 0xfff, 
>>                  PROT_READ | PROT_WRITE, MAP_SHARED, gpioFd, 
>> gpioAddrs[i]); 
>>
>> Printing values from OE, IN and OUT registers: 
>>         printf("i=%i\n",i); 
>>         printf("OUT[%i]=0x%08x\n",i,gpios[i][DATA_OUT_REG/4]); 
>>         printf("IN[%i]=0x%08x\n",i,gpios[i][DATA_IN_REG/4]); 
>>         printf("OE[%i]=0x%08x\n",i,gpios[i][GPIO_OE_REG/4]); 
>>
>> The full source is on gist: 
>> https://gist.github.com/piranha32/4fd285cc8333eeb4ec39 
>>
>> Program works fine when 'i' is set to 1, crashes for 'i' set to 0,2 or 3. 
>> Am I missing something obvious, or is this an overzealous memory 
>> protection? 
>>
>> Board: BBBlack 
>> Kernel: Linux beaglebone 3.8.13 #1 SMP Fri Jun 7 09:49:12 CEST 2013 
>> armv7l GNU/Linux 
>>
>> thx, 
>> j. 
>>
>>
>> -- 
>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to