GPIO and buttons array

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

tobetter wrote:
Wed Aug 31, 2022 6:56 pm
New update with GPIO keypad is not uploaded yet, but would be good to study what device tree will be used.
https://www.kernel.org/doc/Documentatio ... keypad.txt
You made a great work, thanks for this.
Waiting for the update ;)

Luke.go
Posts: 721
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 113 times
Been thanked: 115 times
Contact:

Re: GPIO and buttons array

Post by Luke.go »

These users thanked the author Luke.go for the post:
zyssai (Fri Sep 02, 2022 2:44 am)

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

You made an amazing work, I didn't thought it could be possible!

I didn't exactly understand how to do, but I will work on it!

Thanks!!!

User avatar
mctom
Posts: 1938
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1
Location: Gdansk, Poland
Has thanked: 222 times
Been thanked: 270 times
Contact:

Re: GPIO and buttons array

Post by mctom »

And good luck!
These users thanked the author mctom for the post:
zyssai (Fri Sep 02, 2022 12:33 pm)
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

Luke.go
Posts: 721
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 113 times
Been thanked: 115 times
Contact:

Re: GPIO and buttons array

Post by Luke.go »

You should configure the device tree overlay file.

Change the gpio key code for your settings and set the event key code.

But I think you must optimize the delay properties. it will be hard time to fit your h/w. :)

Good luck!
These users thanked the author Luke.go for the post:
zyssai (Fri Sep 02, 2022 12:34 pm)

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

HI!

I have flashed new HK Android update.
And... it seems to work!

https://youtube.com/shorts/q7o8AME5UhI

I just need to change gpio key mapping and check key event because some of them are not working.
It's pretty easy, just need to create keymatrix.dtbo inside /odm folder, and change gpio pins and key event.
Don't forget to add keymatrix to env.ini in user_overlay and in Odroid_Settings app.

But I just don't understand what is this:

Image

Luke.go
Posts: 721
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 113 times
Been thanked: 115 times
Contact:

Re: GPIO and buttons array

Post by Luke.go »

Oh, please check here. https://github.com/hardkernel/linux/blo ... map.txt#L9

So, First byte for row, second byte for col and last 2byte for key event code. :)

ex)
00010052 means, 00 -> row 0, 01 -> cal 1, 0052 -> KEY_KP0 (decimal 82)
These users thanked the author Luke.go for the post:
zyssai (Mon Sep 05, 2022 12:41 pm)

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

Luke.go wrote:
Mon Sep 05, 2022 9:23 am
Oh, please check here. https://github.com/hardkernel/linux/blo ... map.txt#L9

So, First byte for row, second byte for col and last 2byte for key event code. :)

ex)
00010052 means, 00 -> row 0, 01 -> cal 1, 0052 -> KEY_KP0 (decimal 82)
Perfect, thanks, I haven't changed key events because of this.
You have made an amazing job, thanks to all of you!! :P

Is there just a simple way now to interprete those key events in android?
ie. Key event KEY_LEFTALT will make next track action

Edit: it seems that KeyMapper APK do the job perfectly.
I need to work with it but it seems good :P

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

So after modification of keymatrix.dtbo it seems that changes are not updated, even with deletion of the file, rebooting, and copying new dtbo.

https://youtu.be/nWh2CHJL0CY

User avatar
tobetter
Posts: 10564
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 689 times
Been thanked: 1802 times
Contact:

Re: GPIO and buttons array

Post by tobetter »

zyssai wrote:
Tue Sep 06, 2022 1:32 am
So after modification of keymatrix.dtbo it seems that changes are not updated, even with deletion of the file, rebooting, and copying new dtbo.

https://youtu.be/nWh2CHJL0CY
Have you tried the original .dtb and work?
Where did you put your down .dtb?
By any chance, do you have a serial log from U-Boot?

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

tobetter wrote:
Tue Sep 06, 2022 2:37 am
Have you tried the original .dtb and work?
Where did you put your down .dtb?
By any chance, do you have a serial log from U-Boot?
I have tested the original dtbo file with just corrected gpio pins, and it works.
But modified key events seems to not be applied.

Here is my dtbo file, I copy it to /odm folder.
Don't know how to have serial log, will check it.
Thanks for the help!

User avatar
tobetter
Posts: 10564
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 689 times
Been thanked: 1802 times
Contact:

Re: GPIO and buttons array

Post by tobetter »

zyssai wrote:
Tue Sep 06, 2022 4:22 am
tobetter wrote:
Tue Sep 06, 2022 2:37 am
Have you tried the original .dtb and work?
Where did you put your down .dtb?
By any chance, do you have a serial log from U-Boot?
I have tested the original dtbo file with just corrected gpio pins, and it works.
But modified key events seems to not be applied.

Here is my dtbo file, I copy it to /odm folder.
Don't know how to have serial log, will check it.
Thanks for the help!
If the GPIO pins detect the keys and triggers key event as given in the original dtbo, but not the key event modified by you, it's worth to check if the key event is filter in Android or not. I think they are not filtered but, would be good to double check.

What do you have ls -l /dev/input/by-id and do you have od command? Please check in the terminal of Android.

Luke.go
Posts: 721
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 113 times
Been thanked: 115 times
Contact:

Re: GPIO and buttons array

Post by Luke.go »

zyssai wrote:
Tue Sep 06, 2022 4:22 am
tobetter wrote:
Tue Sep 06, 2022 2:37 am
Have you tried the original .dtb and work?
Where did you put your down .dtb?
By any chance, do you have a serial log from U-Boot?
I have tested the original dtbo file with just corrected gpio pins, and it works.
But modified key events seems to not be applied.

Here is my dtbo file, I copy it to /odm folder.
Don't know how to have serial log, will check it.
Thanks for the help!
Please check gpio number from here -> https://wiki.odroid.com/odroid-n2/hardw ... connectors

I think you set the wrong gpio pins. there are no gpio a11, gpio x21 and gpio x22.

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

tobetter wrote:
Tue Sep 06, 2022 4:35 am
If the GPIO pins detect the keys and triggers key event as given in the original dtbo, but not the key event modified by you, it's worth to check if the key event is filter in Android or not. I think they are not filtered but, would be good to double check.

What do you have ls -l /dev/input/by-id and do you have od command? Please check in the terminal of Android.
Thanks I will check when back to home
Luke.go wrote:
Tue Sep 06, 2022 2:33 pm
Please check gpio number from here -> https://wiki.odroid.com/odroid-n2/hardw ... connectors

I think you set the wrong gpio pins. there are no gpio a11, gpio x21 and gpio x22.
Thanks, I thought it was physical pin number, I will change this

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

tobetter wrote:
Tue Sep 06, 2022 4:35 am
If the GPIO pins detect the keys and triggers key event as given in the original dtbo, but not the key event modified by you, it's worth to check if the key event is filter in Android or not. I think they are not filtered but, would be good to double check.

What do you have ls -l /dev/input/by-id and do you have od command? Please check in the terminal of Android.
Image

od command seems to exist, but I have no idea about how to use it.
Luke.go wrote:
Tue Sep 06, 2022 2:33 pm
Please check gpio number from here -> https://wiki.odroid.com/odroid-n2/hardw ... connectors

I think you set the wrong gpio pins. there are no gpio a11, gpio x21 and gpio x22.
After change this is better, but I always have the problem of key events not updated from original dtbo file.


Something strange is that it doesn't work AT ALL if I change the name of the dtbo file (and user_overlay in env.ini, and overlay in Odroid Settings app).
If I come back to the name of the original file, it works again, but always with original key events.

Luke.go
Posts: 721
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 113 times
Been thanked: 115 times
Contact:

Re: GPIO and buttons array

Post by Luke.go »

please share your compiled dtbo file. I will check it.

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

Luke.go wrote:
Wed Sep 07, 2022 8:43 am
please share your compiled dtbo file. I will check it.
Here it is.
https://github.com/zyssai/Lag-And-Droid ... atrix.dtbo

But I think I'm doing something wrong, I place this file to /odm folder.

Have a nice day

Luke.go
Posts: 721
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 113 times
Been thanked: 115 times
Contact:

Re: GPIO and buttons array

Post by Luke.go »

Oh, did you compile to dtbo file or just copy it to odm?

You should make dtbo file from dts.

Please check here https://wiki.odroid.com/common/applicat ... g_dtc_tool

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

Luke.go wrote:
Wed Sep 07, 2022 3:51 pm
Oh, did you compile to dtbo file or just copy it to odm?

You should make dtbo file from dts.

Please check here https://wiki.odroid.com/common/applicat ... g_dtc_tool
Thanks, I thought this step was not needed. But it will be hard to compile with Android, I hope there is apt command.
And, this folder seems to not exist, or I don't know how to mount it:

Odroid-N2: ./amlogic/overlays/odroidn2/*.dtbo

Really sorry, I have some basics with Linux, but i'm not an advanced user :oops:
Will try when back to home, thanks again for all your help

User avatar
odroid
Site Admin
Posts: 39538
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2675 times
Been thanked: 1480 times
Contact:

Re: GPIO and buttons array

Post by odroid »

I think you can use the WSL2 to compile the device-tree files if your major OS is Windows on your host PC instead of Linux.

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

odroid wrote:
Wed Sep 07, 2022 5:03 pm
I think you can use the WSL2 to compile the device-tree files if your major OS is Windows on your host PC instead of Linux.
Thanks for the tip.
I have a debian distrib, I will try with it, and if it's a no go then will install wsl2.

Luke.go
Posts: 721
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 113 times
Been thanked: 115 times
Contact:

Re: GPIO and buttons array

Post by Luke.go »

You don't need compile all of android. You can compile just dtbo file.

But now, I share it. please test with it. :)

To use this dtbo file, unzip keymatrix.zip and copy it to /odm.

and, you should remove "spi0" from overlays, then add keymatrix to user_overlays in /odm/env.ini.
Attachments
keymatrix.zip
(576 Bytes) Downloaded 6 times

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

Luke.go wrote:
Wed Sep 07, 2022 5:39 pm
You don't need compile all of android. You can compile just dtbo file.

But now, I share it. please test with it. :)

To use this dtbo file, unzip keymatrix.zip and copy it to /odm.

and, you should remove "spi0" from overlays, then add keymatrix to user_overlays in /odm/env.ini.
Thanks for the help.
I tried to compile but I think it will be harder than I thought :lol:

Image

Perhaps because I do it by ssh, I'm not at home, will try your compiled file later, really appreciate!

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

Good news, it works perfectly with your file 8-)

Every button works except one, I think it's because Android does not respond to LEFT_ALT key event.

But I need to do some changes to the file, because some buttons are inverted, don't know why, it doesn't seems to be an inverted row or col, and not a wiring problem.
I just need to invert key events.

So, I have updated the DTS file here
https://github.com/zyssai/Lag-And-Droid ... matrix.dts

But I don't want to abuse of your generosity Luke.go
I will find a way to get compile working
These users thanked the author zyssai for the post:
tobetter (Thu Sep 08, 2022 1:40 am)

Luke.go
Posts: 721
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 113 times
Been thanked: 115 times
Contact:

Re: GPIO and buttons array

Post by Luke.go »

Here you are. :)

You don't need to build all of android.

you can build dtbo from the kernel.

Please download kernel source from GitHub repo. and set environment variable. And apply your configuration to keymatrix.dts.

and make dtbo from the command.

Code: Select all

$ make odroidn2_android_defconfig
$ make dtbs
check this page. https://wiki.odroid.com/odroid-n2/softw ... ing_kernel
Attachments
keymatrix.zip
(576 Bytes) Downloaded 5 times

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

I will test it, and let you know.

Thanks again Luke.go, and also tobetter, odroid, mctom and paulcrawford for the help with this project :P

I love this community :twisted:
These users thanked the author zyssai for the post (total 2):
tobetter (Thu Sep 08, 2022 2:31 pm) • paulcrawford (Thu Sep 08, 2022 8:41 pm)

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

@Luke.go thanks for the dtbo file, everything is working except one touch, don't know why. But it doesn't matter, I have the most important, volume and control.

Again, thanks ;)
These users thanked the author zyssai for the post:
tobetter (Fri Sep 09, 2022 7:51 am)

User avatar
mctom
Posts: 1938
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1
Location: Gdansk, Poland
Has thanked: 222 times
Been thanked: 270 times
Contact:

Re: GPIO and buttons array

Post by mctom »

I'm glad to see you guys are making progress on this one. :)
These users thanked the author mctom for the post:
zyssai (Thu Sep 15, 2022 1:28 pm)
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

mctom wrote:
Thu Sep 15, 2022 4:46 am
I'm glad to see you guys are making progress on this one. :)
They have made an amazing work!
I'm just waiting now for voodik to integrate this update to LOS :D

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

Hi :!:

I'm trying to compile myself.
I modified keymatrix.dts but I'm facing this:

Code: Select all

root@NAS:/home/zyssai/Downloads/linux# make dtbs
  CHK     include/config/kernel.release
  CHK     include/config/kernel.release_full
  UPD     include/config/kernel.release_full
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  HOSTLD  scripts/dtc/dtc
/usr/bin/ld : scripts/dtc/dtc-parser.tab.o:(.bss+0x10) : définitions multiples de « yylloc »; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0) : défini pour la première fois ici
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:110 : scripts/dtc/dtc] Erreur 1
make[1]: *** [scripts/Makefile.build:648 : scripts/dtc] Erreur 2
make: *** [Makefile:565 : scripts] Erreur 2
root@NAS:/home/zyssai/Downloads/linux#
I don't know what I'm doing wrong, if you have some ideas.. :oops:
Thanks!

User avatar
mctom
Posts: 1938
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1
Location: Gdansk, Poland
Has thanked: 222 times
Been thanked: 270 times
Contact:

Re: GPIO and buttons array

Post by mctom »

Compile errors are worth googling in general. See if this helps:
https://github.com/BPI-SINOVOIP/BPI-M4-bsp/issues/4

They say the trouble is gcc 10 or older. If you could install gcc-9 instead this should help. Or modifying one of the files as described over there.
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

User avatar
zyssai
Posts: 408
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 4Gb
Vu7a+
Has thanked: 148 times
Been thanked: 47 times
Contact:

Re: GPIO and buttons array

Post by zyssai »

mctom wrote:
Mon Sep 26, 2022 4:13 am
Compile errors are worth googling in general. See if this helps:
https://github.com/BPI-SINOVOIP/BPI-M4-bsp/issues/4

They say the trouble is gcc 10 or older. If you could install gcc-9 instead this should help. Or modifying one of the files as described over there.
Thanks mctom ;)
I didn't found this, I will try this week and let you know :!:

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 3 guests