Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A13 => Topic started by: DarkAngel on December 26, 2012, 01:22:37 AM

Title: [Solved] A13-OLinuXino-WIFI GPIO access?
Post by: DarkAngel on December 26, 2012, 01:22:37 AM
Hello @all,

I'm new here and I bought me a A13-OLinuXino WIFI.

My question is how can I access the GPIOs in Android?

The only thing I was found was this: https://olimex.wordpress.com/2012/10/24/a13-olinuxino-project-control-relays-and-read-adcs-and-ios-with-android/ (https://olimex.wordpress.com/2012/10/24/a13-olinuxino-project-control-relays-and-read-adcs-and-ios-with-android/)

But that does not help me to get access to the GPIOs on the board.

Has anybody a idea?

Thank you for your help.  :)

DarkAngel
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: olimex on December 26, 2012, 08:10:26 PM
the way to have access to the GPIO should be same as in the above example for the I2C access, you have to enable GPIOs in Linux kernel, then with the NDK to write C code which to access the GPIOs and to export them to Java so you can use them in Android.
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: DarkAngel on January 09, 2013, 11:41:49 PM
Thanks for your answer  :D

I will see if I can make it.

DarkAngel
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: DarkAngel on January 19, 2013, 02:16:53 AM
So, I'm back and I have it not succeeded  :(

In the A13-SDK source there is no included driver for GPIO which I can activate.

Unlike as in the source for "Building bootable SD-card with Debian Linux".

There are all the files to compile the "sun4i-gpio.ko"

But this help me not because the files from source for "Building bootable SD-card with Debian Linux" are not compatible with the A13-SDK source.

I've tried to compile the "sun4i-gpio.ko" with the source for "Building a bootable SD card" and load it with insmod. But there was an error: "failed (Exec format error)".

How can I add the sun4i-gpio to the A13-SDK to enable GPIOs in Linux kernel?


Thanks for your help  ;)

DarkAngel
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: bernard on January 19, 2013, 06:47:22 AM
hello, have you found a way to control the GPIOs?  I would be happy to try to use the NDK, but I do not know where to find a piece of C source code that plays with the GPIO and implements that through NDK. 

I think I found the source for accessing those GPIOs:  https://github.com/linux-sunxi/linux-sunxi/blob/sunxi-3.0/drivers/misc/sun4i-gpio.c   ...which appears to essentially use:

gpio_write_one_pin_value() and
gpio_read_one_pin_value()

..dunno where this is defined nor how it works. But someone posted an interesting post on the subject: https://www.olimex.com/forum/index.php?topic=436.0
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: DarkAngel on January 21, 2013, 08:25:56 AM
So, I have built a new sun4i-gpio.ko and tried insmod but I get these errors:

insmod: ini_module 'sun4i-gpio.ko failed (Interrupted system call)

dmesg: sun4i gpio driver init
       sun4i_gpio_init script_parser_fetch "gpio_para" "gpio_used" error

Any idea how I can fix it?


Thanks for your help  ;)

DarkAngel

Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: DarkAngel on January 27, 2013, 04:56:51 PM
Does nobody has an idea how can fix it?


Thanks for your help  ;)

DarkAngel
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: JohnS on January 27, 2013, 07:23:35 PM
Generally the answer is to build your own kernel and the module for it as well.
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: DarkAngel on January 27, 2013, 11:31:35 PM
I have build my own kernel with enabled GPIO.

But dmesg shows me an error:

dmesg: sun4i gpio driver init
       sun4i_gpio_init script_parser_fetch "gpio_para" "gpio_used" error


And when I try to load the module with insmod I get the same error:

insmod: ini_module 'sun4i-gpio.ko failed (Interrupted system call)

dmesg: sun4i gpio driver init
       sun4i_gpio_init script_parser_fetch "gpio_para" "gpio_used" error


Must I modify the sun4i_gpio.c so it works under Android?


DarkAngel
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: JohnS on January 28, 2013, 01:36:01 AM
I'm not using Android.

Someone posted an app for using it there.
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: Bernd on January 28, 2013, 02:03:03 PM
I have played around with the GPIO configuration for the Linux boot, but that is the same as for Android.

In my boot configuration there is a script.bin which defines the board configuration where is defined which pin is used for what and so on. The human readable version of this file would be script.fex. The sunxi-tools contain programs bin2fex and fex2bin for conversion.

In my fex file there are the following entries:

[gpio_para]
gpio_used = 1
gpio_num = 5
gpio_pin_1 = port:PB02<1><0><default><default>
gpio_pin_2 = port:PB03<1><0><default><default>
gpio_pin_3 = port:PB04<1><0><default><default>
gpio_pin_4 = port:PB05<1><0><default><default>
gpio_pin_5 = port:PG09<1><1><default><default>


The GPIO driver looks for there and if there are no entries for GPIO, it just quits. I think this is what you are seeing.

I don't know what the parameter in the GPIO configuration mean, but I suspect it is for direction, tristate and so on.
Title: Re: A13-OLinuXino-WIFI GPIO access?
Post by: DarkAngel on January 29, 2013, 12:29:27 AM
Hurray ;D
Bernd you are the best. ;D
That was the missing puzzle part.  :D

Thanks for the help  :)
Title: Re: [Solved] A13-OLinuXino-WIFI GPIO access?
Post by: markome on January 29, 2013, 11:46:26 AM
DarkAngel, could you be so kind and compose a short HOWTO how to access GPIO pins on Olinuxino A13 WIFI? Thank you in advance!
Title: Re: [Solved] A13-OLinuXino-WIFI GPIO access?
Post by: andnitro on April 24, 2013, 02:43:57 AM
If a HOWTO for GPIO access on android  :D :D :D :D
Title: Re: [Solved] A13-OLinuXino-WIFI GPIO access?
Post by: BJFreeman on April 24, 2013, 10:18:25 PM
using the ADT (eclipse) you can follow this example https://github.com/hehopmajieh/modio_android