Tải bản đầy đủ

4412 Android Deveopment



Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 1 - 页

4412 Android Deveopment




REVISION
ORIGINATOR
SCR
REV DATE
0.1.0
Guangzhou FriendlyARM Co., Ltd

April 24, 2014





Guangzhou FriendlyARM Computer Tech Co., Ltd Confidential:
This document and information contained in it shall not be reproduced
by, used by, or disclosed to others except as expressly authorized in
writing by Guangzhou FriendlyARM Co., Ltd.
Guangzhou FriendlyARM
Computer Tech Co., Ltd
Guangzhou, China
Copyright@2013







Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 2 - 页

COPYRIGHT STATEMENT
The content (content being images, text, programs and scripts) of this English
manual is copyright © Guangzhou FriendlyARM Computer Tech Co., Ltd. All
rights expressly reserved.
Any content of the manual printed or downloaded may not be sold, licensed,
transferred, copied or reproduced in whole or in part in any manner or in or on
any media to any person without the prior written consent of Guangzhou
FriendlyARM Computer Tech Co., Ltd including but not limited to:
 transmission by any method
 storage in any medium, system or program
 display in any form
 performance
 hire, lease, rental or loan
Requests for permission to reproduce material from this manual should be
addressed to Guangzhou FriendlyARM Computer Tech Co., Ltd.






Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 3 - 页

Index
1 INTRODUCTION - 5 -
2 SET UP ANDROID DEVELOPMENT ENVIRONMENT - 5 -
2.1 INSTALL JDK (JAVA SE DEVELOPMENT KIT) - 5 -
2.2. INSTALL ADT AND ANDROID SDK - 8 -
2.2.1 Download Android SDK - 9 -
2.2.2 Start ADT Development Environment (Android Developer Tools) - 10 -
2.3 SET UP ANDROID SIMULATOR - 12 -
2.4 CREATE ANDROID APPLICATION - 14 -
2.4.1 Create “HelloWorld” - 14 -
2.4.2 Run Android Application in Simulator - 16 -
2.5 SET UP TINY4412 DEBUG ENVIRONMENT - 18 -
2.5.1 Install USB ADB Driver - 18 -
2.5.2 ADB Testing - 19 -
2.5.2.1 Add ADB to PATH - 19 -
2.5.2.2 Testing ADB Functions - 21 -
2.5.3 Run Applications on Tiny4412 in ADB - 21 -
2.5.4 Debug Android Applications on Tiny4412 - 24 -
3 ACCESS AND CONTROL HARDWARE COMPONENTS - 24 -
3.1 HOW TO USE LIBRARY(LIBFRIENDLYARM-HARDWARE.SO) - 25 -
3.2 LIBRARY (LIBFRIENDLYARM-HARDWARE.SO) API - 27 -
3.2.1 General File Operation APIs - 27 -
3.2.2 Serial Port APIs - 29 -
3.2.3 LED APIs - 31 -
3.2.4 PWM APIs - 31 -
3.2.5 ADC APIs - 32 -
3.2.6 I2C APIs - 33 -
3.2.7 SPI APIs - 35 -
3.2.8 GPIO APIs - 39 -
3.3 CODE SAMPLES - 43 -
3.3.1 LED - 43 -
3.3.2 GPIO - 43 -
3.3.2.1 Run Adroids Application as System - 43 -
3.3.2.2 Disable Kernel LED Driver - 45 -
3.3.2.3 Get GPIO LED Pin - 45 -
3.3.2.4 Control LED via GPIO - 46 -
3.3.3 Serial Port Communication - 48 -


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 4 - 页

3.3.4 PWM - 49 -
3.3.5 A/D Conversion - 50 -
3.3.6 I2C & EEPROM - 51 -
3.4 IMPORT PROJECT IN ADT - 52 -





























Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 5 - 页

1 Introduction
This document is created based on the Tiny4412 board and gives basic ideas on how
to develop applications on Android. Although it was created for the Tiny4412 it is a
good reference for all our boards including 4412, NanoPC, 210 and 6410 that can run
Android.

2 Set up Android Development Environment
In this chapter we will introduce how to set up the Android development environment
on Windows 7 (both 32bit and 64 bit work).

2.1 Install JDK (Java SE Development Kit)
Please go to http://www.oracle.com/technetwork/java/javase/downloads/index.html
and click on JDK


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 6 - 页


On the pop-up window please check the “Accept License Agreement” box


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 7 - 页


Please select the corresponding JDK. Windows 7 64bit corresponds to
“jdk-7u51-windows-x64.exe”. After download it double click to install.
After installation is done please add the JDK commands to the “Path” environment
variable.
After add the JDK commands to “PATH” you can verify it by commanding
“java-version” in the DOS commandline utility:




Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 8 - 页

2.2. Install ADT and Android SDK
Please go to http://developer.android.com/sdk/ to get the latest SDK.




Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 9 - 页


You can select either 32 bit or 64 bit suitable to your system.
After download the package please uncompress it and you will find the following
files:


2.2.1 Download Android SDK
Our Android is 4.2.2 therefore users need to download Android4.2.2 SDK. Please
double click on “SDK Manager” and select Android 4.2.2(API 17) SDK Platform and


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 10 - 页

ARM EABI v7a System Image.

On the window please click on “Install 4 packages…” and check the “Accept License”
option on the “Choose Packages to Install” dialog and click on “Install”.

2.2.2 Start ADT Development Environment (Android Developer Tools)
Please go to the “adt-bundle-windows-x86_64” directory and then the “eclipse”
directory, double click on “eclipse.exe” to start ADT.


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 11 - 页


When you start it you will be asked to set the workspace path where you will save
your projects’ source code. After “finish” you will see the following window

Actually ADT is built with Eclipse and is Eclipse + Android + SDK + ADT Plugin. In
the following sections we will use “ADT”


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 12 - 页

2.3 Set up Android Simulator
In ADT, click on “WIndows” and then “Android Virtual Device Manager” to start the
simulator. Click on “New…” and the “Create new Android Virtual Device(AVD)”
window will pop up.
On this window you can make your own configurations:



Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 13 - 页

Click on “OK” to complete it and you will find the simulator

Select a simulator and click on “Start” and “Launch” on the “Launch Option” dialog



Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 14 - 页

2.4 Create Android Application
2.4.1 Create “HelloWorld”
We will create a “HelloWorld” to verify whether the ADT is set up correctly or not.
Please go to “File” -> “New” -> “Android Application Project”

After the “New Android Project” dialog pops up please type the following info
1) Application name: HelloWorld
2) Project name: HelloWorld
3) Package name: com.example.helloworld
4) Build target: API 17: Android 4.2(Jelly Bean)
5) Target SDK: API 17: Android 4.2(Jelly Bean)


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 15 - 页


Click on “Next” all the way till “Finish” to complete the project.


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 16 - 页



2.4.2 Run Android Application in Simulator
To compile and run the “HelloWorld” please select the project in “Package Explorer”
and run it via “Run” -> “Run As” -> “Android Application” then ADT will start the
Android Simulator automatically and will run the “HelloWorld”.


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 17 - 页






Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 18 - 页

2.5 Set up Tiny4412 Debug Environment
2.5.1 Install USB ADB Driver
On the ADB window please click on “Window” -> “Android SDK Manager” to start
“SDK Manager”. You can check the “Google USB Driver” status from “Extras”. If it is
not “Installed” then please check “Google USB Driver” and click “Install 1 package…”

After the installation is done please turn on the Tiny4412. After Android is fully
loaded please connect the board to a PC via a USB cable and follow the Windows 7
prompt to install the USB driver.


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 19 - 页


If the installation fails please go to “Device Manager” and right click on “Tiny4412”
to update its driver.

2.5.2 ADB Testing
2.5.2.1 Add ADB to PATH
Please add the ADB directory to the “PATH” variable.
1) Right click on “My Computer” -> “Properties” and select “Advanced”
2) Click on “Environmental Variables”
3) Double click on the PATH variable from “System Variables” and add the directory of
“adt-bundle” to it.




Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 20 - 页


To test ADB commands please lauch the Windows command line utility, type “adb”
and enter. If you observe the following messages you will be able to work with ADB
successfully.



Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 21 - 页

2.5.2.2 Testing ADB Functions
1) Check Device Status
To check a device status please type “#adb devices”. If you observe the following
messages it means the Tiny4412 is connected successfully.


2) Enter ADB Shell
To enter the ADB shell please type “#adb shell”. You can type “exit” to return to
DOS.

3) Install Software in ADB
For instance we have a software utility in “D:\sinaweibo_2.0.4.apk” we can type “adb
install D:\sinaweibo_2.0.4.apk” to install it.

2.5.3 Run Applications on Tiny4412 in ADB
Double click on “eclipse/eclipse.exe” to start ADT and the “HelloWorld” will be


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 22 - 页

automatically opened.
Please go to Package Explore, right click on “HelloWorld” and select “Propertities”,
click on “Run/Debug Settings”, select “HelloWorld” and click on “Edit…”

On the “Edit Configuration” window click on “Target” and check “Always prompt to
pick device” on the “Deployment Target Selection Mode” tab



Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 23 - 页

Click on “OK” to save and exit.
Now you can run the HelloWorld on your Tiny4412. Please select the HelloWorld
project and click on the “Run” button on the tools bar. On the “Android Device Chooser”
dialog select “Coose a running Android device” and select the 4.2.2 device (Tiny4412)
from “Target”

A moment later “HelloWorld” will run on your Tiny4412



Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 24 - 页

When ADT asks whether you want to trace logcat messages you can choose “Yes”
and select “debug”


2.5.4 Debug Android Applications on Tiny4412
To debug an application on the Tiny4412 you need to stop it if it is running. Please go
to “Open Perspective”, click on “Debug”, add a break point and hit “Run” -> “Debug”.

3 Access and Control Hardware Components
In this chapter we provide some code samples on how to develop applications
accessing hardware components.
We developed a libfriendlyarm-hardware.so which is the basis for all our hardware
control applications.


Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640 Website: http://www.arm9.net
Sales: +86-20-85201025 Tech Support: +86-13719442657 Fax: +86-20-85261505
Email for Business and Cooperation: capbily@163.com Email for Tech Support: dev_friendlyarm@163.com

第 - 25 - 页

3.1 How to Use Library(libfriendlyarm-hardware.so)
We have two DVDs that come with the Tiny4412 package. In the second DVD ’s
“tools\libfriendlyarm-hardware” there are all necessary “.so” files and JAVA JNIs

In our Android souce code package the libfriendlyarm-hardware.so file is located at
“vendor/friendly-arm/exynos4412/rootdir/system/lib/libfriendlyarm-hardware.so”. In
the Android system it is under “/system/lib/libfriendlyarm-hardware.so”.
You can use the libfriendlyarm-hardware.so in the following ways:
1) Go to your application’s directory and create a “libs” directory. Enter this libs
directory, create an “armeabi” directory and copy the libfriendlyarm-hardware.so file
to this directory.
2) Go back to your application’s directory, enter the “src” directory and create
“com\friendlyarm\AndroidSDK”

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×