Application launching with GPIO trigger on Android

You must install the Android release 20190425(N2) or higher to launch app via GPIO.


1. Enable the GPIO key driver as a built-in.

...
CONFIG_KEYBOARD_GPIO_POLLED=y
...

2. Add gpio key mapping to device tree blob.

ODROID-N2
(path: arch/arm64/boot/dts/amlogic/meson64_odroidn2_android.dts)
GPIO Pin description
https://github.com/hardkernel/linux/commit/dd1560c73719c0e46c9a7faba45da253afb25044

gpio_keys_polled {
		status = "okay";
		compatible =
			"gpio-keys-polled";
			#address-cells = <1>;
			#size-cells = <0>;
			poll-interval = <100>;
			autorepeat;
			button@1 {
				label = "GPIO Key F7";
				linux,code = <65>;
				gpios = <&gpio GPIOX_3 1>;
			};
			button@2 {
				label = "GPIO Key F8";
				linux,code = <66>;
				gpios = <&gpio GPIOX_4 1>;
			};
			button@3 {
				label = "GPIO Key F9";
				linux,code = <67>;
				gpios = <&gpio GPIOX_7 1>;
			};
			button@4 {
				label = "GPIO Key F10";
				linux,code = <68>;
				gpios = <&gpio GPIOX_8 1>;
			};
	};

3. Enable GPIO Key map.

gpio_keys_polled {
   status = "okay";
   .
   .
};

4. Build the kernel source. and flash the kernel image to the board.(N2)
Android

$ cd out/target/product/odroidn2
$ fastboot flash dtbs obj/KERNEL_OBJ/arch/arm64/boot/dts/amlogic/meson64_odroidn2_android.dtb
$ fastboot reboot

5. Connect a few buttons to the GPIOs with 10KOhm pull-up resistors. Click images to enlarge it.

ODROID-N2

6. Set the launch app by using ODROID Utility app.