technexion-android / cookers

Please select your target branch first, then the detail instruction is inside the README.md
8 stars 9 forks source link

GPIOD_JNI_TEST not working #36

Closed LeoChang88 closed 2 years ago

LeoChang88 commented 3 years ago

Hello,

I was finished the Android 11 image building for EDM-G-IMX8M-PLUS board, and boot successfully, but I can not using the APP "GPIOD_JNI_TEST" to change the gpio status, For example: pin 249 is GPIO4_IO06 so i choose gpio bank 4 and gpio line 6, but not working.

wigcheng commented 2 years ago

If you just issue gpioset command to setting the GPIO value directly, it still failed??

wigcheng commented 2 years ago

@LeoChang88 Any update?

LeoChang88 commented 2 years ago

Hello @wigcheng "gpioset" command is not working, but the "legacy sysfs-based GPIO" way is working.

wigcheng commented 2 years ago

Very strange, so it's command issue, but I tested here before and it works, could you provide your command detail?

Can I test pin 249 (GPIO4_IO06) directly, or your target pin is another one?

Thanks

LeoChang88 commented 2 years ago

I have tested both pin 249 & pin 251 and this is my command history: history.txt

wigcheng commented 2 years ago

Hmm... I think GPIO249 should be use gpioset gpioset gpiochip1 6=1, could you try again?

LeoChang88 commented 2 years ago

It works, but is it inconsistent with the document?

gpioset Set a the value of a GPIO. For example, setting the value of line 9 of gpio bank 3 to 1 below:

root@pico-imx8mm:~# gpioset gpiochip3 9=1

Finding gpio number To use a GPIO its number needs to be known. If we know the bank and io number, the kernel's number can be calculated with

N = (BANK – 1) * 32 + IO

Shell For example GPIO2_IO12 would get the kernel GPIO number

N = (2 – 1) * 32 + 12 = 44
wigcheng commented 2 years ago

Yeah I know your point, that strange why libgpiod initial sequence is difference with generic gpio way. I think root cause could be this libgpiod is tweaked by me because normal libgpiod is not compatible with android, sorry cause your inconvenience!

I'll fix it later when I have time, and thanks a lot about feedback this bug!

LeoChang88 commented 2 years ago

Thank you, should I try Android 10 first? Is it more stable?

wigcheng commented 2 years ago

No, Android 11 is more stable (kernel was be fine tuned), this is libgpiod bug only, I'll take a look.

LeoChang88 commented 2 years ago

OK, I will wait for your new patch.

wigcheng commented 2 years ago

I fixed this bug already, please update libgpiod and kernel_imx repo and recompile again, should be works.

wigcheng commented 2 years ago

Any update?

LeoChang88 commented 2 years ago

I will test it as soon as possible, thanks.

LeoChang88 commented 2 years ago

@wigcheng How can I update libgpiod and kernel_imx repo? I issued the following commands but nothing changed: $ repo init -u https://github.com/technexion-android/manifest -b tn-android-11.0.0_1.2.0_8m-next $ repo sync -j2 $ throw $ source cookers/env.bash.imx8.edm-g-imx8mp.wandboard.hdmi $ merge_restricted_extras $ cook -j2

wigcheng commented 2 years ago

So did you re-download the source code again? It will auto update if you re-downloaded. A quick way is force delete folders and sync again such as: $ rm -rf (source)/vendor/nxp-opensource/kernel_imx $ rm -rf (source)/external/libgpiod

Sync the source again $ repo sync --force-sync (source)/vendor/nxp-opensource/kernel_imx $ repo sync --force-sync (source)/external/libgpiod

Please try it, thanks :)

LeoChang88 commented 2 years ago

@wigcheng I have tried but not working :( Do you need any information?

wigcheng commented 2 years ago

give me your 'uname -r' information in runtime Android

LeoChang88 commented 2 years ago

edm_g_imx8mp:/ # uname -r 5.4.70-gdf5e0707dd2a

wigcheng commented 2 years ago

You already updated your kernel, that's very strange.... So your gpiochip sequence is the same if you issue 'gpiodetect' command on the runtime stage?

LeoChang88 commented 2 years ago

edm_g_imx8mp:/ # gpiodetect gpiochip0 [30200000.gpio] (32 lines) gpiochip1 [30210000.gpio] (32 lines) gpiochip2 [30220000.gpio] (32 lines) gpiochip3 [30230000.gpio] (32 lines) gpiochip4 [30240000.gpio] (32 lines) gpiochip5 [1-0021] (16 lines) gpiochip6 [1-0023] (16 lines)

wigcheng commented 2 years ago

So it seems fix the issue already, right? Original one is gpiochip0 [30200000.gpio] (32 lines) gpiochip1 [30230000.gpio] (32 lines) gpiochip2 [1-0021] (16 lines) gpiochip3 [1-0023] (16 lines) gpiochip4 [30210000.gpio] (32 lines) gpiochip5 [30220000.gpio] (32 lines) gpiochip6 [30240000.gpio] (32 lines)

I don't know you said the issue still exist is means....???

LeoChang88 commented 2 years ago

edm_g_imx8mp:/ # gpioset gpiochip4 6=1 but the status of pin 249 is still low.

wigcheng commented 2 years ago

For pin 249 case, you should issue command as follows: edm_g_imx8mp:/ # gpioset gpiochip3 6=1

you can use 'gpioinfo' to check specific number first, libgpiod assign gpiochip number from 0, so you need (n-1), n is your real bank number.

Please try again and let me know if works Thanks

LeoChang88 commented 2 years ago

gpioset is working now, but the APP GPIOD_JNI_TEST is still not working.

wigcheng commented 2 years ago

Oops, selinux permission issue on app, just fixed and update source code already, please update these two repos: (source)/system/sepolicy (source)/device/nxp/

Should be works

LeoChang88 commented 2 years ago

@wigcheng Is it correct?

sync_log.txt build_log (2).txt

wigcheng commented 2 years ago

It seems you sync failed because you modified the source code, right? a quick way is pull the specific repos manually: cd (source)/system/sepolicy; git pull tn_github tn-android-11.0.0_1.2.0_8m-next cd (source)/device/nxp/; git pull tn_github tn-android-11.0.0_1.2.0_8m-next

Don't forget backup your modified code to avoid disappear.

LeoChang88 commented 2 years ago

@wigcheng It works, thank you.