How to set gpio as input in Android 6.0.1


#1

Hi I am trying to do my own Android app (with Android Studio) that call to GPIOs, now I am able to use GPIO as output but I also need to set some GPIO as input.

In the Android 6.0.1 (any version) don’t exists the GPIO folder, so gpios can’t be exported. The only folder that exists is gpio_sw, with it I am able to set gpio data on/off, but I don’t know how to set a gpio as an input. By default all gpio are outputs.

  • Together with “data” (file used to set a gpio to 1/0), I noticed that exist more files inside sys/class/gpio_sw/"gpio_name/ :

data

cfg

drv

pull

uevent

  • And exists another folder inside each gpio, this folder is “…/gpio/power”. The files inside power folder:

async

autosuspend_delay_ms

control

runtime_active_kids

runtime_active_time

runtime_enabled

runtime_status

runtime_suspended_time

runtime_usage

  • Inside this files, there only appears a binary/boolean value that we write with “echo” command (like a variable identifier).

=> Ok, what is the purpose for all this files? I.E: Pull file is for setting a pull-up or a pull down? “echo > 1 /sys/class/gpio_sw/PB7/pull”

***Can be this files used to set the GPIO port direcction? Any tutorial or info to use them?

=> In anoher hand I noticed that exist a sys_config.fex file that should be modified to get the UART working, and inside this file the GPIO can be defined as an input too. I am in the right way??? How can I modify sys_config.fex???.. I can’t find any info

=> Finally, I have read that exist a JAVA library called Pi4J with support for all BPI products including M64. I tried to use in Android Studio,the library and the imports looks recognized properly but I can’t build. How use Pi4J in Studio???

Thanks in advance :slight_smile:


(ZB) #2

here change to :

directionPath = “echo in > " + " /sys/class/gpio/gpio” + gpio_number + “/direction”;

then gpio will be changed as input.


#3

Hello Jackzeng :slight_smile:

Thanks a lot for your support again, the problem is that the gpio folder doesn’t exist. I am using BPI-M64 +Android 6.0.1 (v3), now I am downloading the 2018-10-24 Android 6.0.1 img, and I will try again.

I have read that the gpio direction also can be changed inside sys_config.fex, to try it I read that I have to build the Android source again and because I have an old 1st gen core I5 4GBRAM pc :cold_sweat:…last time I wasted a lot of hours for getting a working build (If I remember OK, more that 12 hours only for build), and a lot of fails until to get the right way to do this and in to configure Ubuntu to build.

Another way to work with gpios is with Pi4J or wiringpi for sinovoip products, I am interested in using Pi4J with Studio because I read that is the only way to manage gpio interruptions.

  • Can I manage the interruptions from Shell commands too?

EDIT: I Just burned the Android 6.0.1 2018-10-24, again the gpio folder doesn’t exist. Pls, How can I solve this problem???