Need help activating GPIO

Moderators: mdrjr, odroid

Need help activating GPIO

Unread postby Skylineodroid » Sun Mar 11, 2018 10:57 am

Hi all.
Ive had my Odroid C2 for about 6 months and Ive been trying to activate "app launch for GPIO" so I can install the Odroid in my car as a Navigation system.
All I want to do is use some existing buttons on my dashboard to bring up apps like Google maps and operate the back, home, and menu keys so I can remove them from the screen.

My problem is that I am not familiar with Android and have limited Unix knowledge.
I have followed the Wiki but it has very little information on what the steps are so I am guessing how to set up my PC.
I have installed Ubuntu 14.04 and I think I have all the adb and fastboot tools installed correctly. I have an SD card with Marshmallow V3.9 working on my odroid.
I know the file "meson64-odroidc2.dts" that needs to be modified to enable the app launch function, but I can't make or build the file and when I try to reboot using fastboot through my uart connection, my odroid freezes on the hardkernel screen. I keep getting errors when following the Wiki and I'm pretty sure this is whats preventing me from getting any further.
I am almost at the point of throwing my odroid in the bin. I know what I want to achieve and it seems simple but the information I have is not helpful and I have no more patience in trying to work this out.

Please help me. I know someone out there will be able to give me a simplified answer to this problem.

Thankyou.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby tobetter » Sun Mar 11, 2018 12:04 pm

I think you do not need to compile the device tree file and flash it *if* you have flashed already Marshmallow V3.9, and it boots up well. If your C2 is stuck at Hardkernel logo, it would be at U-boot yet or in Kernel for some reason. So I recommend you to flash Marshmallow again. Right after Marshmallow is up, just make sure that if you have these. You can check it on Android shell through adb shell or UART. If you have these, your Android is ready to get switch events. You can wire switches carefully.
Code: Select all
root@odroidc2:/ # ls /proc/device-tree/gpio_keys_polled
#address-cells
#size-cells
autorepeat
button@1
button@2
button@3
button@4
compatible
name
poll-interval
status
tobetter
 
Posts: 2368
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Need help activating GPIO

Unread postby Skylineodroid » Sun Mar 11, 2018 12:34 pm

Thanks I'll give that a try.
I was trying to assign extra GPIO inputs to use as "back", "home" and "menu" buttons as well as "zoom in" and "zoom out". I have a file ready to go but I just dont know how to load it into my odroid marshmallow system.
When it doesnt boot up is when I try and use the instruction "adb reboot fastboot". It could be marshmallow version.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby tobetter » Sun Mar 11, 2018 12:44 pm

Skylineodroid wrote:Thanks I'll give that a try.
I was trying to assign extra GPIO inputs to use as "back", "home" and "menu" buttons as well as "zoom in" and "zoom out". I have a file ready to go but I just dont know how to load it into my odroid marshmallow system.
When it doesnt boot up is when I try and use the instruction "adb reboot fastboot". It could be marshmallow version.

Oh, I see...if you have done build the .dts with you change and you did adb reboot fastboot while USB cable is connected, just do these two commands.
Code: Select all
fastboot flash dtb arch/arm/boot/dts/meson8b_odroidc.dtb
fastboot reboot

If everything succeeds, your Android will show up more GPIOs you added at /proc/device-tree/gpio_keys_polled.
tobetter
 
Posts: 2368
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Need help activating GPIO

Unread postby Skylineodroid » Sun Mar 11, 2018 2:22 pm

Thats great.
I just hope that I have all the tools set up to flash and use fastboot.
I will try and see how I go.
Thanks so much.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby Skylineodroid » Sun Mar 11, 2018 2:59 pm

I'm concerned that I dont have Uboot installed properly. I keep getting errors event though I follow the Wiki properly.

It looks like this:
In file included from ../../tools/../lib/crc32.c:29:0,
from tools/lib/crc32.c:1:
../include/linux/crc32.h:11:1: error: unknown type name ‘u32’
extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len);
^
../include/linux/crc32.h:11:22: error: unknown type name ‘u32’
extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len);
^
In file included from tools/lib/crc32.c:1:0:
../../tools/../lib/crc32.c:30:26: fatal error: linux/module.h: No such file or directory
#include <linux/module.h>
^
compilation terminated.
make[2]: *** [tools/lib/crc32.o] Error 1
make[1]: *** [tools] Error 2
make: *** [sub-make] Error 2

I cant work out why Uboot wont install properly. Ive tried on both Ubuntu 14.04 and 16.04.

Will this affect my ability to make .dts file changes with adb fastboot?
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby Skylineodroid » Sun Mar 11, 2018 4:22 pm

Well I cant even get fastboot to reboot. All I get is Hardkernel flash screen even on the latest V3.9 Marshmallow.
This shouldnt be so hard but it is not intuitive and the Wiki obviously has many errors and no help or explanation at all.
Is anyone out there willing to program the changes I need for me. I would be willing to pay for your time?

I have had enough of trying to work this out. I know Windows. This is deliberately made difficult it would seem. I dont know why I should need to flash this and compile that. Why cant I modify a text file directly and see results instantly, rather than have to download 70Gb odd of source code to make 10 lines of code change.

As I said, I'm willing to pay someone the make the changes.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby joerg » Sun Mar 11, 2018 6:35 pm

How much gpio functions you need? I would consider to extend my GpioShutdownService App https://forum.odroid.com/viewtopic.php?f=137&t=21386 to have some more extra gpio functions. In this app there are already functions: shutdown, reboot, extra1 and extra2. The functions extra1 and extra2 are free configurable.
There can be eg. the command for an intent am startservice -a com.maxmpz.audioplayer.API_COMMAND --ei cmd 3 (Command to control PowerAmp)
or a command for a key event: input keyevent KEYCODE_VOLUME_UP.
I would extent some more extra functions. As my app is free, there is no need to pay for.
joerg
 
Posts: 800
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2

Re: Need help activating GPIO

Unread postby Skylineodroid » Tue Mar 13, 2018 6:35 pm

That would be great. I didn't know your app existed.
I wanted to do the following:
Start Google Maps
Start Messenger
Zoom In
Zoom Out
Home Key
Back Key
Menu Key
Voice/Speech Button.

This is to put in my car as a navigation replacement. I have installed a touch screen but I want to use existing buttons to make it easier to use when driving. I want to use speech to input locations but the "OK Google" voice command is not ideal in a car, hence the speech button.

I'm so frustrated as I thought I understood how to do these changes but I keep hitting errors that stop me.
I would appreciate if you could assist in making the changes I require. Would I need GPIO set to ok in the meson64-odroidc2.dts file?
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby joerg » Wed Mar 14, 2018 2:37 am

Yesterday I have uploaded a new version with 6 extra functions. I call it extra, because initially the app was designed to shutdown or to reboot with gpio pin. Then I needed functions like 'start music player after reboot' or pause during shutdown timeout and someone asked for some extra functions.
To set it up:
If you don't need the shutdown or reboot functionality you can delete the gpio numbers in settings Shutdown Pin and Restart Pin in settings.
To use an extra function, put a valid WiringPi gpio e.g. 22 (pin 31) in Extra1 Pin and a command like am start -a android.intent.action.VIEW -n com.google.android.apps.maps/com.google.android.maps.MapsActivity in Extra1 Action.
I have not tested if this command works. You can test it at the adb shell command line. Every command that is working there, you can use as ExtraX Action.
Some commands are predefined as auto completion in settings.
E.g.
Home: input keyevent KEYCODE_HOME
Back: input keyevent KEYCODE_BACK

Some more.
Menu: input keyevent KEYCODE_MENU

I have no idea, if KEYCODE_ZOOM_IN and KEYCODE_ZOOM_OUT is working for you.
joerg
 
Posts: 800
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2

Re: Need help activating GPIO

Unread postby Skylineodroid » Wed Mar 14, 2018 11:00 am

Great.
Where it says keycode, am I writing that or do I need the actual code number for that key?
Also when you say adb shell command line is that on the odroid in the terminal app or on ubuntu through a sub connection.
I haven't been able to get adb working on my ubuntu pc. That's why I started looking for easier options.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby Skylineodroid » Wed Mar 14, 2018 7:50 pm

Just wondering also where you have put the extra file to be downloaded?

Ive just tried V1.5 of your app and it works. I can get maps to open and use home and back key function as well as volume and brightness. I will need to work out other button functions. :D

Could you give a little more info into how to use the opening of an app function. I'm not sure about that one.

Also does anyone know what the third button on the bottom of an android screen is called? I thought it was "menu" but that is the 3 verticle dot button. Some say it is "Overview" or "Task" but they dont work.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby joerg » Thu Mar 15, 2018 4:01 am

The version 1.6.0 is there in my thread: https://forum.odroid.com/download/file.php?id=7139.

If you can't get adb working on your linux pc, have you installed all needed packages?
sudo apt-get install android-tools-adb
Please show here the output of lsusb and adb devices when the C2 is connected via its otg port. Also helpful a dmesg at the moment after you connected, should look like this:
Code: Select all
[  414.590502] usb 1-12.3: new full-speed USB device number 4 using xhci_hcd
[  414.766842] usb 1-12.3: new high-speed USB device number 5 using xhci_hcd
[  414.896188] usb 1-12.3: New USB device found, idVendor=18d1, idProduct=4e12
[  414.896192] usb 1-12.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  414.896194] usb 1-12.3: Product: ODROIDC2
[  414.896195] usb 1-12.3: Manufacturer: HardKernel Co., Ltd.
[  414.896197] usb 1-12.3: SerialNumber: HKC213254DFE8F50

Sometimes there are missing the right udev rules in /etc/udev/rules.d on your linux host pc.
51-android.rules.zip
(4.22 KiB) Downloaded 4 times

If nothing helps and if you own a windows pc, here is a link to a universal adb windows driver: https://adb.clockworkmod.com/

Back to your question:
You can send intents to start a activity or a service with the command line tool am. You can find in the internet a lot of useful sites that explain the usage.
E.g to start the HereWeGo app:
am start -a android.intent.action.MAIN -n com.here.app.maps/com.here.app.MainActivity
This is the action: android.intent.action.MAIN
This is the package: com.here.app.maps
This is the activity to start: com.here.app.MainActivity
Sometimes the action is different: android.intent.action.VIEW.
Sometimes the path to the activity or a service is the same as the package, then you can shorten it:
am startservice com.jw.shutdownservice/.GpioShutdownService
To start the vlc player in video mode you give some extra data with --e:
am start -a android.intent.action.VIEW -n org.videolan.vlc/.StartActivity --eu uri video/*
joerg
 
Posts: 800
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2

Re: Need help activating GPIO

Unread postby Skylineodroid » Thu Mar 15, 2018 5:32 am

I will try the windows adb option.
I did try to download v1.6 but it would not install. I will try again later but there might be done thing wrong. V1.5 installed fine and is working.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby Skylineodroid » Thu Mar 15, 2018 6:00 pm

I've tried to download again and I cannot install the app. Perhaps you could upload without being zipped??
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby rooted » Thu Mar 15, 2018 9:11 pm

Skylineodroid wrote:I've tried to download again and I cannot install the app. Perhaps you could upload without being zipped??
https://www.dropbox.com/s/77l3d5tpsq34i2m/GpioShutdownService-1.6.0.apk?dl=0
User avatar
rooted
 
Posts: 5466
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: Need help activating GPIO

Unread postby joerg » Thu Mar 15, 2018 10:47 pm

How do you install? By adb sideload (adb install ...) or do you copy to sdcard and open it with a file manager? Next, normaly need to uninstall the app before install, go to settings - apps, select the app and uninstall. I will check when I am back home.
joerg
 
Posts: 800
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2

Re: Need help activating GPIO

Unread postby rooted » Thu Mar 15, 2018 11:52 pm

I think he just couldn't unzip the file on the device itself.
User avatar
rooted
 
Posts: 5466
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: Need help activating GPIO

Unread postby joerg » Fri Mar 16, 2018 12:36 am

Oops, there was something wrong in AndroidStudio. From AndroidStudio I was able to install, but sideload not worked. I compiled new version with android.injected.testOnly = false in gradle.settings.
joerg
 
Posts: 800
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2

Re: Need help activating GPIO

Unread postby Skylineodroid » Fri Mar 16, 2018 6:47 am

So it wasnt me?
Ive been installing with file manager to open the zip and install.
I just wondered if being zipped was the problem. I guess not.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby joerg » Fri Mar 16, 2018 10:14 pm

No, it was a setting in AndroidStudio. The version 1.6.1 is there in my thread.
joerg
 
Posts: 800
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2

Re: Need help activating GPIO

Unread postby Skylineodroid » Sat Mar 17, 2018 8:23 am

Thanks so much Joerg.
This has really helped me with what I'm trying to achieve.
I have discovered the following:
"input keyevent KEYCODE_F7" will make use of the inbuilt Odroid programmable "F" keys that can be assigned to open apps.
"input keyevent KEYCODE_VOICE_ASSIST" will activate the microphone for voice input.
"input keyevent KEYCODE_APP_SWITCH" will activate double square app menu.

I'm still looking for a few other commands but this working really well.

I did have one more request. Could you please add 4 more extra actions. I have 10 buttons I'd like to utilise.
Again, thankyou so much fo your help.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby joerg » Sun Mar 18, 2018 1:25 am

Fine that you made progress. Yes I can add 4 more. But it will take some time, because I have to go on a business trip. I will return next Friday, after that I will do.
joerg
 
Posts: 800
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2

Re: Need help activating GPIO

Unread postby Skylineodroid » Sun Mar 18, 2018 8:35 am

Thankyou. I really appreciate it.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby joerg » Sun Mar 25, 2018 3:47 pm

Hi Skylineodroid, in my thread there is a new experimental version with 10 actions. https://forum.odroid.com/viewtopic.php?f=137&t=21386&start=50#p219367
joerg
 
Posts: 800
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2

Re: Need help activating GPIO

Unread postby Skylineodroid » Tue Mar 27, 2018 6:00 am

Thanks so much joerg.
I will try it out and let you know if it's successful.
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby Skylineodroid » Wed Mar 28, 2018 5:51 pm

Hi Joerg.
I have uninstalled 1.6.0 and installed 1.7.0 and there are only 6 extra functions instead of 10.
Could you have a look and see if something went wrong?
Skylineodroid
 
Posts: 19
Joined: Sun Mar 11, 2018 10:14 am
Location: Australia
languages_spoken: english
ODROIDs: Odroid c2

Re: Need help activating GPIO

Unread postby joerg » Thu Mar 29, 2018 5:32 am

Yes, I missed to edit the preferences xml. I have uploaded a new version.
joerg
 
Posts: 800
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2


Return to Android

Who is online

Users browsing this forum: No registered users and 5 guests