Problems compiling with BitBake - Can't find header file gpio.h

View: New views
6 Messages — Rating Filter:   Alert me  

Problems compiling with BitBake - Can't find header file gpio.h

by kindredvendetta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'm completely new to the Gumstix so sorry if this has been answered elsewhere, but I haven't found anything to help fix my problem! It's probably something obvious...

I'm trying to write an application in C which interfaces with the Gumstix Overo's GPIO pins, exposed on the pin header on an attached Summit board. I've successfully managed to manipulate the GPIO pins from the terminal by echoing the appropriate data to the files in sys/class/gpio, but from the C program I'd like to access the pins by calling functions such as gpio_request and gpio_set_value, which I guess necessitates a "#include <path/gpio.h>" at the beginning of the file.

However, I can't get it to compile. Bitbake returns an error: "No such file or directory". Examples I see on the Internet suggest things such as linux/gpio.h, mach/gpio.h and asm/gpio.h, none of which work. I did a search for gpio.h on my system and there are 160 copies... not sure which one is the correct one. They are in subfolders named for different architectures under four main paths:

/overo-oe/tmp/work/armv7a-angstrom-linux-gnueabi/linux-libc-headers-2.6.23-r4/linux-2.6.23/include/
/overo-oe/tmp/work/overo-angstrom-linux-gnueabi/linux-omap3-2.6.30-r47/staging-pkg/staging/overo-angstrom-linux-gnueabi/kernel/
/overo-oe/tmp/work/overo-angstrom-linux-gnueabi/linux-omap3-2.6.30-r47/git/arch/
/overo-oe/tmp/staging/overo-angstrom-linux-gnueabi/kernel/

Does anyone have an idea which one is correct? I've tried a few edits to my Bitbake file as well but not sure what to do as I don't fully understand Bitbake yet... putting "-I path" in the do_compile section was suggested to me, but hasn't worked. Do I need to edit this file? I've opened up some of the gpio.h files and some of them contain references to including other instances of gpio.h from elsewhere... this just seems to complicate things!

I know I could simply write C code to write and read directly from the files in /sys/class/gpio but that won't fix the bigger problem - I should be able to include a header file! I assume that would also give me problems with using interrupts on these pins later on in development.

Thanks in advance for your help.

Re: Problems compiling with BitBake - Can't find header file gpio.h

by Dave Hylands :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Thu, Oct 29, 2009 at 1:04 PM, kindredvendetta <jam306@...> wrote:

>
> Hello,
>
> I'm completely new to the Gumstix so sorry if this has been answered
> elsewhere, but I haven't found anything to help fix my problem! It's
> probably something obvious...
>
> I'm trying to write an application in C which interfaces with the Gumstix
> Overo's GPIO pins, exposed on the pin header on an attached Summit board.
> I've successfully managed to manipulate the GPIO pins from the terminal by
> echoing the appropriate data to the files in sys/class/gpio, but from the C
> program I'd like to access the pins by calling functions such as
> gpio_request and gpio_set_value, which I guess necessitates a "#include
> <path/gpio.h>" at the beginning of the file.

Those functions, gpio_request and gpio_set_value and the gpio.h header
file will only work from kernel space. If you're compiling a driver or
module then you can use these functions, but from user space, these
are not available.

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: Problems compiling with BitBake - Can't find header file gpio.h

by kindredvendetta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks very much for the quick reply!

How do you suggest I interface with the GPIO pins from my code? Is writing from and reading to the /sys/class/gpio files the best way if not running in kernel space?

Is there any way to access interrupts from user space, or would I need to write a driver/module?

Cheers



>Those functions, gpio_request and gpio_set_value and the gpio.h header
>file will only work from kernel space. If you're compiling a driver or
>module then you can use these functions, but from user space, these
>are not available.

Re: Problems compiling with BitBake - Can't find header file gpio.h

by Dave Hylands :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Thu, Oct 29, 2009 at 2:03 PM, kindredvendetta <jam306@...> wrote:
> Thanks very much for the quick reply!
>
> How do you suggest I interface with the GPIO pins from my code? Is writing
> from and reading to the /sys/class/gpio files the best way if not running in
> kernel space?
>
> Is there any way to access interrupts from user space, or would I need to
> write a driver/module?

Yeah - you basically have 3 options:

1 - Use the /sys/class/gpio interface

2 - Use mmap and directly access the registers. This requires root
access and has some implications if you're trying to access the same
registers as the kernel driver is at the same time.

3 - Write a driver/user-lib

It turns out that I've actually done item 3 for work and the code is
under GPL. I've put the files onto
http://www.davehylands.com/gumstix-wiki/gpio

There are 4 files:

user-gpio-drv.c is the kernel side driver
user-gpio.c is the user side library which talks to the kernel driver
user-gpio.h is the interface for user-mode programs to use user-gpio.c
gpio.c is a small command line program which I use to test out the gpio library.

Feel free to use these. I haven't done anything to integrate these
with anything other than our internal build environment, so a few
changes will be required to get things to work under OE.

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: Problems compiling with BitBake - Can't find header file gpio.h

by kindredvendetta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks again. I think i'm going to go with 1) as it seems simplest to me with my limited skills on this platform!

Do you know what the best way of setting up these pins as interrupts would be?

Thanks


Dave Hylands wrote:
Hi,

On Thu, Oct 29, 2009 at 2:03 PM, kindredvendetta <jam306@ecs.soton.ac.uk> wrote:
> Thanks very much for the quick reply!
>
> How do you suggest I interface with the GPIO pins from my code? Is writing
> from and reading to the /sys/class/gpio files the best way if not running in
> kernel space?
>
> Is there any way to access interrupts from user space, or would I need to
> write a driver/module?

Yeah - you basically have 3 options:

1 - Use the /sys/class/gpio interface

2 - Use mmap and directly access the registers. This requires root
access and has some implications if you're trying to access the same
registers as the kernel driver is at the same time.

3 - Write a driver/user-lib

Re: Problems compiling with BitBake - Can't find header file gpio.h

by Dave Hylands :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Fri, Oct 30, 2009 at 4:39 AM, kindredvendetta <jam306@...> wrote:
>
> Thanks again. I think i'm going to go with 1) as it seems simplest to me with
> my limited skills on this platform!
>
> Do you know what the best way of setting up these pins as interrupts would
> be?

That also requires being in kernel space. I wrote a driver called
gpio-event which allows access to pin change interruupts from user
space. It worked on the verdex, and I believe that a couple of people
have ported it to the overo.
<http://docwiki.gumstix.com/index.php/GPIO_event>

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users