Sunday, January 18, 2009

Beagleboard GPIO Input (driverless)

This blog post has moved HERE

15 comments:

Anonymous said...

Hi!
I'm trying to set up an SPI communication with a peripheral on BeagleBoard and I'm trying to figure out how to do it by using what you suggest in your comment.
Your code is very useful also to newbie like me!
There is something I don't understand, especially regarding the line:

gpio[0x6034/4] = 0xFFFFFFFF;

and

if(gpio[0x6038/4] == 201390076) printf("1\n");

How did you get the 6034 and 6038 values?

Thank you very much in advance

F

Anonymous said...

Ok, I solved!
Just take a look at:
http://focus.ti.com/lit/ug/sprufd5a/sprufd5a.pdf

F

Jon Elson said...

Hi,

Thanks VERY much for posting this code example. I have a Beagle Board that was set up with a Debian install on an SD card. I tried your example code, and it locks up the system. I understand that it takes over bank 5 I/O, which maybe interferes with using the SD card slot. Can you comment on this?

I am working on the first experiments aimed at building an EPP (IEEE-1284) parallel port emulator for the Beagle, to support some existing devices that communicate over a PC's par port.
I need extremely fast I/O, able to transfer a byle in less than a us. Eventually, this driver will be run as a real-time kernel module, but I want to have a user-mode version for diagnostics, too.

I will need to use about 13 signals on the expansion header.
I have already noticed that there is no continuous, aligned byte available on the expansion header, but I think I can get around that with a bit shift.

Thanks,

Jon

new said...

I don't know why that code should take the system out. It could be due to a difference in board revisions (I was using B2 IIRC). Perhaps they've wired things differently on newer revisions.

IIRC I was also using the handhelds mojo distribution, though this shouldn't make any difference.

v4vendetta said...

Hi,

I have question that I did you land up with this values?

pinconf[0x2158/4] = 0x011C011C;
pinconf[0x215C/4] = 0x011C011C;
pinconf[0x2160/4] = 0x011C011C;
pinconf[0x2164/4] = 0x011C011C;
pinconf[0x2168/4] = 0x011C011C;
pinconf[0x216C/4] = 0x011C011C;
pinconf[0x2170/4] = 0x011C011C;
pinconf[0x2188/4] = 0x011C011C;

Can you please explain???

v4vendetta said...

Hi,

When i tried to compile this ..it is giving me this errors??

build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
make: execvp: /bin/bash: Argument list too long
target thumb C: gpiodriver <= external/gpiodriver//gpiodriver.c
external/gpiodriver//gpiodriver.c: In function 'main':
external/gpiodriver//gpiodriver.c:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
external/gpiodriver//gpiodriver.c:19: error: 'pinconf' undeclared (first use in this function)
external/gpiodriver//gpiodriver.c:19: error: (Each undeclared identifier is reported only once
external/gpiodriver//gpiodriver.c:19: error: for each function it appears in.)
external/gpiodriver//gpiodriver.c:20: error: 'ulong' undeclared (first use in this function)
external/gpiodriver//gpiodriver.c:20: error: expected expression before ')' token
external/gpiodriver//gpiodriver.c:41: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
external/gpiodriver//gpiodriver.c:41: error: 'gpio' undeclared (first use in this function)
external/gpiodriver//gpiodriver.c:42: error: expected expression before ')' token
make: *** [out/target/product/generic/obj/EXECUTABLES/gpiodriver_intermediates//gpiodriver.o] Error 1

Unknown said...

Hey v4vendetta!

Just put main(){ ... } around it and it will compile.

But that didn't keep the mmap() from failing on me :(

Chao said...

I have the same problem as Jon. The access to /dev/mem RDWR will lock up the system.

Is there a work around?

Jon, how did you work it out?

Thanks

Tallak Tveide said...

On my beagleboard running the program caused some errors regarding USB. My board still runs fine from the serial console. If your communication is via USB this could explain the lockup.


[ 2331.830169] hub 1-0:1.0: port 2 disabled by hub (EMI?), re-enabling...
[ 2331.846527] usb 1-2: USB disconnect, address 2
[ 2331.857147] usb 1-2.1: USB disconnect, address 3

Milo_Nurv said...

Hi! How did you get those values?

new said...

from the TI datasheet.

Anonymous said...

Hi, I tried your code but I receive an error opening /dev/mem

Do you have any suggestion on how to overcame this problem?

I'm using last Angstrom image

SilverWolf78

new said...

erm chmod 777 /dev/mem ? or run the code as root? I've not used this code for quite a while.

cp said...

This was an excellent post, thanks so much. I adapted it for my own uses (digital output) and posted tidbits of my code. In case that's useful for anyone else, it can be found here:

http://x4350.blogspot.com/2011/01/digital-io-on-beagleboard-using-gpio.html

drwho said...

"You need to use O_SYNC when you do this to tell mmap the memory is uncacheable. It'll work /a bit/ without but you'll get weird artifacts."

Wow, right in the nail! That's the problem I was having in my "userland" home-made driver.

Thank you very much for sharing this information!

-scop.