This is an old revision of the document!
Table of Contents
Having a great fun with GPIO on Android
You must install the C2 Android Marshmallow Ver2.7 image or higher to access the 40pin GPIO properly.
This WiKi explains how to make an Android app which can access GPIO ports.
You need to install Google Android Studio on your host PC.
And add NDK and tools first before starting below steps.
We tested following steps on Android Studio 2.3 and NDK R14.
Ubuntu/Linux
Configure NDK path for Android Studio
Add this line in your ~/.bashrc file after installing Android NDK.
export NDK_PATH=[YOUR ANDROID SDK LOCATION]/ndk-bundle
For example
export NDK_PATH=/home/codewalker/projects/android-sdks/ndk-bundle
You can find the Android SDK location on this menu (File → Settings → Appearance & Behavior → System Settings → Android SDK)
After editing the bashrc file, you have to login again or type “source ~/.bashrc” on the command line.
Download example code
Download C2-WiringPi NDK library and App source code Project from github.
$ sudo apt install git $ git clone https://github.com/codewalkerster/example-wiringPi -b odroidc2_gpiomem
Run Android Studio and open the downloaded project.
Build the project to make an apk package
Select Build → Make Project menu.
You will see a couple of error messages and click following texts to complete the build process.
Install missing platform(s) and sync project
Install Build Tools 25.0.2 and sync project
And you will have an apk file to run it on your ODROID.
Windows
Set environment PATH to point NDK folder path
Reboot Windows.
Install git client program
Clone project
Install NDK
Toos → Android → SDK Manager
ADC and GPIO output
PWM
I2C
UART
1 Wire
Kernel for i2c
Open File Manager app.
Edit /storage/internal/boot.ini like this. (near end of file).
Before edit.
movi read dtb 0 ${dtbaddr} # load kernel from vat or boot partition. movi read boot 0 ${loadaddr} #fatload mmc 0:1 ${loadaddr} Image booti ${loadaddr} - ${dtbaddr}
After edit.
movi read dtb 0 ${dtbaddr} # load kernel from vat or boot partition. #movi read boot 0 ${loadaddr} fatload mmc 0:1 ${loadaddr} Image booti ${loadaddr} - ${dtbaddr}
Load kernel image from vfat partition built i2c.
If you could not find 'fatload' command, remove /storage/internal/boot.ini file and reboot system.