Wednesday, May 27, 2009

android notes - the process of development

0 installation and setup
1 create a project

$ android create project --target 1 --path ./demo --activity demo --package com.example.demo

2 edit source code ~/myspace/demo/src/example/demo/demo.java
3 compile with ant

$ ant -debug -verbose

4 run emulator with a script

#! /bin/sh
out/host/linux-x86/bin/emulator -verbose \
-kernel prebuild/android-arm/kernel/kernel-qemu \
-ramdisk out/target/product/generic/ramdisk.img \
-system out/target/product/generic/system.img \
-init-data out/target/product/generic/userdata.img \
-avd myavd -sdcard ./sdcard.img -no-skin -no-boot-anim

5 install the application we have build

$ cd ~/myspace/demo
$ adb install bin/demo-debug.apk
$ adb install -r bin/demo-debug.apk (for reinstall)
$ adb shell
# logcat
# ps a (to get process id to kill)
# kill -9



That's on java side, on the android side,
1 setup

$ cd ~/myspace/mydroid
$ source ./build/envsetup.sh
$ lunch 1

2 build the project in android

$ cd ./frames/base/media/libmediaplayerservice
$ mm (it builds libmediaplayerservice library as an example)
$ cd ~/myspace/mydroid (go back to the root)
$ make snod (build the system image

then you can go back to run emulator with parameters specified in the script.

Wednesday, May 20, 2009

Calculate cpu usage in MCycles/sec

Here is the script to calculate cpu usage in MCycles per second.
The cpu speed is 222MHz as an example, processing data rate is 44100, each block has 8192 samples, and the total calls to foo is 532.

#!/bin/bash

rate=44100
blksize=8192
cpu=222
call=532

# the following val is got from gprof as percentage cpu time, 30.11%.
pcpu_foo=30.11

duration=`echo "scale=4; $blksize * $call / $rate" | bc`
echo "duration: " $duration

secs_foo=`echo "scale=4; $duration * $pcpu_foo /100" | bc`
echo "secs_foo " $secs_foo

blksecs_foo=`echo "scale=4; $secs_foo/$call"|bc`
echo "blocksecs_foo" $blksecs_foo

cpu_foo=`echo "scale=4; $cpu * $rate / $blksize * $blksecs_foo"|bc`
echo "cpu_foo " $cpu_foo " MCycle/sec"

Wednesday, May 13, 2009

u8.04 - build procmeter3

At last, I left Fedora Core 5 which I have used for these 2 years and move to Ubuntu. I am now running Ubuntu 8.04 which is not a very latest version, but at least it is newer than FC5.

But by default to build procmeter3, it prompts "X11/Intristic.h is missing". I have to install the following packages:

$ sudo apt-get install libxt-dev libxaw-headers libxaw7-dev
$ make
$ sudo make install

Thursday, May 7, 2009

android notes - build and test shared library

1. download system.tar.gz from benno and extract it to ~/myspace/tmp.
2. make a link.

cd ~/myspace/tmp/system/lib
ln -s libc.so libc.so.6

Is it necessary? but it fixed the problem to looking for libc.so.6.
3. Here is the Makefile.

CC=arm-none-linux-gnueabi-gcc
LD=arm-none-linux-gnueabi-ld
AR=arm-none-linux-gnueabi-ar
LD_OPTS= --entry=_start \
--dynamic-linker /system/bin/linker -nostdlib \
-rpath /system/lib -rpath ~/myspace/tmp/system/lib \
-L ~/myspace/tmp/system/lib -L .
foo2.a : foo2.c
$(CC) -g -fpic -c foo2.c
$(CC) -g -shared -nostdlib -o libfoo2.so foo2.o
$(AR) -rcs $@ foo2.o
foo2: main.c start.c foo2.a
$(CC) -g -c main.c
$(CC) -g -c start.c
$(LD) $(LD_OPTS) -lc -lfoo2 -o foo2 main.o start.o



when build the library, should set "-nostdlib"

4. run the commands

$ make foo2
$ adb push libfoo2.so /data
$ adb push foo2 /data
$ adb shell
# cd data
# ./trace ./foo2

Thursday, April 30, 2009

ubuntu notes - connect to nfs share folder

I have installed ubuntu 8.04, here is the command to connect to nfs share folder of my FC5.
sudo apt-get install portmap nfs-common
sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-common restart
sudo mount -t nfs 192.168.0.9:/tftpboot /mnt -o nolock

Wednesday, April 29, 2009

android notes

To develop on android, I need open four consoles at least:
1. one console to show the log -- ``$ adb logcat''.
2. one console to run the emulator -- ``$ emulator -sdcard sd.img -avd qslavd''.
3. A third console to build the source code, and install the package:

$ ant debug
$ adb install -r .\bin\foo-debug.apk
$ adb push your\file /sdcard

4. A vim gui/console to edit source code

Monday, April 27, 2009

chown and chgrp

When use ``ls -l'' command it shows the owner and group of the directory.

markc@ubuntu-vm:/opt $ls -la
total 16
drwxr-xr-x 4 root root 4096 2009-04-27 11:04 .
drwxr-xr-x 25 root root 4096 2009-02-18 11:04 ..
drwxr-xr-x 7 root root 4096 2008-08-08 11:04 alp-dev
drwxr-xr-x 2 markc markc 4096 2009-04-27 11:04 work
^ ^
| |
chown chgrp


Here is the command (so I don't have to google it again) to change the directory "work"'s owner and group.


$ sudo chown markc work
$ sudo chgrp markc work