How to su commands from app

Post Reply
Gus189
Posts: 13
Joined: Fri Feb 12, 2021 4:43 am
languages_spoken: english
ODROIDs: C4
Has thanked: 4 times
Been thanked: 0
Contact:

How to su commands from app

Post by Gus189 »

Hello,
First post and just getting started with the C4 and Android 9...

I'm trying to access GPIO via sysfs, and after some searching here, it seems for the apps to get root access (in order to set perms on files) we need to install Magisk. Is this still the way to go?

TIA,
Gus

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

Re: How to su commands from app

Post by odroid »

Try this Android Things compatible library.
viewtopic.php?f=178&t=37101
These users thanked the author odroid for the post:
Gus189 (Fri Feb 19, 2021 1:26 am)

Luke.go
Posts: 596
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 74 times
Been thanked: 82 times
Contact:

Re: How to su commands from app

Post by Luke.go »

Please check this example. :)
https://wiki.odroid.com/common/android_things/led

The example is compatible with ODROID-C4.
These users thanked the author Luke.go for the post:
Gus189 (Fri Feb 19, 2021 1:26 am)

Gus189
Posts: 13
Joined: Fri Feb 12, 2021 4:43 am
languages_spoken: english
ODROIDs: C4
Has thanked: 4 times
Been thanked: 0
Contact:

Re: How to su commands from app

Post by Gus189 »

Interesting...I'm actually coming from Android Things but was looking for alternatives. Although, this will be useful for my personal stuff. Thanks!

I had actually tried running Android Things libs before, got it to build, but always failed to run. I figured it wouldn't run outside of Android Things OS. Anyways...

I need to find alternatives. I have GPIO working using sysfs on other OSs but seems like ODROID-C4 doesn't allow Android apps 'su' access. Is there a work-around?

I will also be looking into WiringPI/JNI on Android. I've come across some examples on this forum but they are all pretty old and won't build in current Android Studio. Anyway, for another topic.

Thanks,
Gus.

Gus189
Posts: 13
Joined: Fri Feb 12, 2021 4:43 am
languages_spoken: english
ODROIDs: C4
Has thanked: 4 times
Been thanked: 0
Contact:

Re: How to su commands from app

Post by Gus189 »

Just came across this...

https://wiki.odroid.com/odroid-c4/os_im ... 4_20200813

From: viewtopic.php?f=204&t=40854

Maybe I just need to update my image? Will check it tonight.....

Gus189
Posts: 13
Joined: Fri Feb 12, 2021 4:43 am
languages_spoken: english
ODROIDs: C4
Has thanked: 4 times
Been thanked: 0
Contact:

Re: How to su commands from app

Post by Gus189 »

Yep, that worked. Latest image has root option and it works.

For my next weird thing that I haven't seen....When I set the pin for output and set it to "1", it reports that it's still "0". The pin does go hi cause I have an LED on it and it lights up as expected.
Anyone ever see this?


odroidc4:/ # echo 1 > /sys/class/gpio/gpio476/value
odroidc4:/ # cat /sys/class/gpio/gpio476/value
0

Even with gpio...

odroidc4:/ # gpio -g write 476 1
odroidc4:/ # cat /sys/class/gpio/gpio476/value
0

I must be missing something....

Gus189
Posts: 13
Joined: Fri Feb 12, 2021 4:43 am
languages_spoken: english
ODROIDs: C4
Has thanked: 4 times
Been thanked: 0
Contact:

Re: How to su commands from app

Post by Gus189 »

Not all pins are alike....Works fine with 495. Guess I'm still learning ODROID...


Thanks,
Gus

Luke.go
Posts: 596
Joined: Mon May 30, 2016 1:55 pm
languages_spoken: english
Has thanked: 74 times
Been thanked: 82 times
Contact:

Re: How to su commands from app

Post by Luke.go »

Please check the array from code. :)

You should check the pin name string.

https://github.com/codewalkerster/andro ... er.cpp#L57
These users thanked the author Luke.go for the post:
Gus189 (Fri Mar 05, 2021 7:13 am)

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 1 guest