Atmel ARM-based Microcontrollers

crookpatedhatMobile - Wireless

Dec 10, 2013 (3 years and 6 months ago)

84 views



Atmel

ARM
-
based
Microcontrollers

04
-

Installing

A
n A
pplication on Android

ANDROID
TRAINING MANUAL

Prerequisites



Hardware Prerequisites



Atmel
®

SAM9M10
-
G45
-
EK

or SAM9X5
-
EK



USB
-
to
-
serial converter if your laptop does not have a serial interface




Software P
rerequisites



Need install Ubuntu 11.04 in Windows





Estimated Completion Time
:
30

min
utes

Introduction

T
h
e goal

of this
H
ands
-
O
n
is to
:



I
nstall and configure
an

Android develop
ment

environment



Learn to u
se Android
D
ebug
B
ridge (ADB)



I
nstall

an application
under the
Android OS on
the
SAM9

target board



09/2
2
/2011





Atmel

ARM
-
based
:
09/2
2
/2011

Page
2

of
13

Table of Contents

Prerequisites

................................
................................
.....................
1

Introduction

................................
................................
.......................
1

Icon Key Identifiers

................................
................................
...........
3

1.

Assignments

................................
................................
..............
4

1.1

Connect target board to PC via USB cable

................................
.........

4

1.2

Using Android Debug Bridge (adb)

................................
......................

5

1.3

Install an application on
Android OS

................................
....................

7

1.4

Going further with
adb

................................
................................
.........

9

Conclusion

................................
................................
......................

12

Resource
s
................................
................................
.......................

12

Atmel Technical Support Center

................................
.....................

12







Atmel

ARM
-
based
:
09/2
2
/2011

Page
3

of
13

Icon Key Identifiers

Icons are used to identify different assignment sections and reduce complexity.
These icons are:


Information

Delivers contextual information about a specific topic


Tips

Highlights useful tips and techniques


To Do List

Highlights objectives to be completed


Result

Highlights the expected result of an assignment step


Warning

Indicates important informati
on


Execute

Highlights actions to be executed out of the target when
necessary






Atmel

ARM
-
based
:
09/2
2
/2011

Page
4

of
13

1.

Assignments

In previous hands
-
on we know how to using NFS as Android rootfs. That is useful for developing Android root
file system.

In following training we still use Android

file system in NAND flash, so let switch back to NAND flash file
system now.


Unplug the Ethernet cable and reset your board to make sure you are running Android
in NAND flash file system.

1.1

Connect
target
board to PC via USB cable


Connect the
USB cable
to

the target board
which is running Android

properly
.



Check whether we can find the USB connection in Ubuntu



Press “CTRL+ALT+T” to open a terminal window.

lsusb | grep
Atmel


Here we can find the Atmel USB devices

as result shows:

at91
sam@ubuntu:~
$ lsusb

| grep
Atmel

Bus 001 Device 011: ID 03eb:6155
Atmel

Corp.



What
does

0x03EB

mean
?



0x03EB is the Atmel vendor ID which is
register
ed to
the
USB
organization

by
Atmel






USB connects here





Atmel

ARM
-
based
:
09/2
2
/2011

Page
5

of
13

1.2

Using Android
Debug Bridge (
adb
)

Android Debug Bridge (adb) is a versatile command li
ne tool that lets you communicate
with an emulator
instance or connected Android
-
powered device.


It is a client
-
server program that includes three components:




A client, which runs on your development machine. You can invoke a client from a shell by issui
ng
an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.




A server, which runs as a background process on your development machine. The server manages
communication b
etween the client and the adb da
emon running on an
emulator or device.




A daemon, which runs as a background process on each emulator or device instance.


You can find the

adb

tool in

~/work/android
-
sdk
-
linux
/platform
-
tools


Android SDK tools

need

JAVA SDK environment. We already set it up
in

Android
install

script.


Now you will u
se
Android Debug Bridge (a
db
)
:



Go to Android SDK tools folder:

cd
~/work/
android
-
sdk
-
linux/
tools



Generate
a new
adb_usb.ini

file

by typing
:

./
android

update adb



If meet any error of “
Java: not found
” please restart the

terminal and
do above
again.


Java SDK is installed and we add the Java to
$PATH

in
~/.bashrc
, that need restart
terminal to take effect.


Check the
adb_usb.ini

is generated

ls ~/.android/


We can see
the adb_usb.ini file is created under the folder

~/.android
:


adb_usb.i
ni


A
dd 0x03EB

value to
adb_usb.ini

file

using following command:

echo 0x03EB >> ~/.android/adb_usb.ini





Atmel

ARM
-
based
:
09/2
2
/2011

Page
6

of
13


What
does

0x03EB

mean
?



0x03EB

is the Atmel vendor ID which is
register
ed to
the
USB
organization

by
Atmel


Check the 0x03EB is added in the file

cat ~/.an
droid/adb_usb.ini


Here is the result:

at91sam@ubuntu:~/work/android
-
sdk
-
linux/tools$ cat ~/.android/adb_usb.ini

# ANDROID 3RD PARTY USB VENDOR ID LIST
--

DO NOT EDIT.

# USE 'android update adb' TO GENERATE.

# 1 USB VENDOR ID PER LINE.

0x03EB


Start the ad
b server:




Go to

<
android_sdk_path/platform
-
tools
>,

cd ~/work/android
-
sdk
-
linux/platform
-
tools/



E
x
e
cute
adb kill
-
server

to kill the adb server

sudo ./adb kill
-
server



T
hen restart the adb server with
adb start
-
server


sudo ./
adb start
-
server


Check whether

we can find the Android device now

./a
db devices


Here we can see the Android device is found



If Android
has
entered
stan
d
by

mode, you
w
o
n’
t

detect
your Android device

by using

./a
db devices

. Please wake up
Android

first,

then

execute


./a
db devices






Atmel

ARM
-
based
:
09/2
2
/2011

Page
7

of
13

1.3

Install

an application
on

Android

OS

We will add the new application “
Jewels
.apk
” into the existing Android demo.


While still

under

<
android_sdk_path/platform
-
tools
>, e
xecute the command:

./
adb install
/media/KINGSTON/03_Android_Training/
Tools/
Jewels
.apk


H
ere shows the result




Now y
ou can see

Jewels
” application installed

in Android
application

UI.











Atmel

ARM
-
based
:
09/2
2
/2011

Page
8

of
13


C
lick on this icon to
launch

the
g
ame




When exit
ing

Jewels

(
use BACK
button)
,

press the MENU

button

and then

select
:

Settings
-
>
Display


and unch
eck the ‘
Auto
-
rotate screen
’ option

to
come back to the
landscape mode
automatically.




Atmel

ARM
-
based
:
09/2
2
/2011

Page
9

of
13


1.4

Going
f
urther with
adb

Let’s look at useful adb commands:


adb (Android debug bridge) commands:

adb devices
-

list attached Android devices

adb install


install an Andr
oid application on target

adb uninstall


uninstall an Android application on target

adb push/pull


upload/download multimedia files on target

adb logcat


view and follow the contents of the system's log buffers

adb shell


execute a shell on devices


In

a
terminal window
, you can
execute


./a
db shell


under
:


~/work/
android
-
sdk
-
linux
/
platform
-
tools
/


to

get into
the
Android shell.


R
un

command:
“ls /data/data”

to check which applications have already been
installed

ls /data/data






Atmel

ARM
-
based
:
09/2
2
/2011

Page
10

of
13


You will find the most
-
r
ecently installed one listed

as

org.
mhgames.jewels

.



Now use the
command

exit


to exit
the
Android shell.


An

alternative
way to
find out

a
package name is
to
run
the
following command

(but
NOT

in the shell

view
)
:

./
aapt dump badging

/media/KINGSTON/0
3_Android_Training/Tools/
Jewels
.apk





Atmel

ARM
-
based
:
09/2
2
/2011

Page
11

of
13


a
ap
t(Android Asset Packaging Tool)

allows you to view, create, and update Zip
-
compatible archives (zip, jar, apk). It can also compile resources into binary assets.


Now e
xecute


./a
db uninstall
org.mhgames.jewels


to rem
ove
the

Jewels


application from
your

Android

OS
.

./a
db uninstall
org.mhgames.jewels


You can check
if
this application has been removed on the
user interface
.



For more information about adb, SDK, Android demo, Android
application
, and how to
build Andro
id, please visit
www.at91.com/android4sam
,
http://developer.android.com
,
and
http://code.google.com
.






















Atmel

ARM
-
based
:
09/2
2
/2011

Page
12

of
13

Conclusion

You
now
know how to
install

an application
on an
Android
OS
running on
the
SAM9X5
-
EK

or SAM9M10
-
G45
-
EK
.

Resources

http://www.atmel.com/

http://www.linux4sam.org/

http://www.at91.com/android4sam/

http://www.android.com

Atmel Technical Support Center

Atmel has several support channels available.

We encourage you to register and use o
ur web portal for several reasons:



All your requests are managed in one place. It is easy to submit a new
request and get the status of pending requests.



FAQ Access. We provide a large FAQ database through our website.



You can subscribe to free newsletters

about Atmel ARM
-
based
microcontrollers.


Support channels:



Go to
http://support.atmel.no/

for
support

for a
ll Atmel microcontrollers
.



Contact
at91@atmel.com

for
support

for all A
tmel ARM
-
based
microcontrollers.
































Atmel Corporation

2325 Orchard Parkway

San Jose, CA 95131

USA

Tel:

(+1)(408) 441
-
0311

Fax:

(+1)(408) 487
-
2600

www.atmel.com



Atmel Asia Limited

Unit 01
-
5
& 16, 19F

BEA Tower, Millennium City 5

418 Kwun Tong Road

Kwun Tong, Kowloon

HONG KONG

Tel:

(+852) 2245
-
6100

Fax:

(+852) 2722
-
1369

Atmel Munich GmbH

Business Campus

Parkring 4

D
-
85748 Garching b. Munich

GERMANY

Tel:

(+49) 89
-
31970
-
0

Fax:

(+49) 89
-
3194621

A
tmel Japan

9F, Tonetsu Shinkawa Bldg.

1
-
24
-
8 Shinkawa

Chuo
-
ku, Tokyo 104
-
0033

JAPAN

Tel:


(+81)(3) 3523
-
3551

Fax:


(+81)(3) 3523
-
7581





© 2011 Atmel Corporation. All rights reserved. / Rev.:



Atmel

ARM
-
based
:
09/2
2
/2011

Atmel
®
, logo and combinations thereof, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries.

Other terms and product
names may be trademar
ks of others.

Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, b
y estoppel or otherwise, to any intellectual property right is granted by
this document or in connection with the sa
le of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL
ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING,
BUT NOT LI
MITED TO, THE
IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON
-
INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAM
AGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF
INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF S
UCH DAMAGES. Atmel makes no
representations or warranties with respect

to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and

products descriptions at
any time without notice. Atmel does not make any commitment to update the information contained herein.
Unless specifically provided otherwise, Atmel products are not suitable for, and shall not
be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in appli
cations intended to support or sustain l
ife.