Android 7, GPIO


With the new Android 7, GPIOs are enabled, we finally have the directory sys/class/gpio !
but we have to export the pin to use them.
I have tried to calculate the GPIO number using the algorithm listed on the following link:

but without success!
So please what is the GPIO number to be exported for Pin 29 to Pin 33?

Thank you.


The GPIO number list:
<1>Pin 29(GPIOH_7) is 178
<2>Pin 30(GPIOH_6) is 177
<3>Pin 31(GPIOH_9) is 180
<4>Pin 32(GPIOH_8) is 179
<5>Pin 33(GPIOAO_6) is 151
<6>Pin 37(GPIOH5) is 176

Notice: If you want to use the Pin 29~32 , you need to modify two file

1. the file 'kvim.dts' : remove the line 'pinctrl-0 = <&audio_pins>;'
2. the file 'mesongxl.dtsi' : change the status from okay to disable
    amlogic-jtag {
       compatible = "amlogic, jtag";
       status = "okay";
       pinctrl-names = "jtag_apao_pins", "jtag_apee_pins";
       pinctrl-0 = <&jtag_apao_pins>;
       pinctrl-1 = <&jtag_apee_pins>;

Edit: modify the file ‘mesongxl.dtsi’


Hi Terry,
Thank you for your reply!
I tried to export the numbers but whithout success as you see from the following results:

Vim:/sys/class/gpio # echo 178 > export
1|Vim:/sys/class/gpio # ls
export gpiochip145 gpiochip155 unexport
Vim:/sys/class/gpio # cd gpio178
/system/bin/sh: cd: /sys/class/gpio/gpio178: No such file or directory

Should we strat by modifing the file ’ Kvim.dts’ ? Where is it located?

thank you.


Yes,you should modify the file (your-project-path)/common/arch/arm64/boot/dts/kvim.dts


I’m sorry.
You also need to modify the file (your-project-path)/common/arch/arm64/boot/dts/amlogic/mesongxl.dtsi


Hi Terry,
Is it possible to do the modifications to ’ Kvim.dts’ and ‘mesongxl.dtsi’ whithout building a new ROM of the new Android 7 ?

Thank you



You can only build the kvim.dtb

$ cd <path-your-project>
$ source build/
$ lunch 12
$ source device/khadas/kvim/

The output file is 'out/target/product/kvim/obj/KERNEL_OBJ/arch/arm64/boot/dts/kvim.dtb’
About how to download the 'kvim.dtb’
you can look this