Sunday, November 15, 2009

android boot issue with yaffs file system

Hi,
Last week i was faceing android boot problem.Basically android was not coming up on the LCD.I posted the query on the android-porting mailing list for some kind of solutions. Now i got it resolved, below if copy of the mails from android-porting list, this might be halpful to people who are facing similar problem.

Below are all the posting for Android-porting mailing list:

first posting: description of problem
I am trying to port android on custom board ARM CORTEX-A8 based with
128MB of onenand device.
I can see "android" text coming up on the LCD screen but after that
nothing is coming. I am using YAFFS2 filesystem. Below is log last few
lines:

***************** log start ***********************


Freeing init memory: 152K
init: cannot open '/initlogo.rle'
yaffs: dev is 32505860 name is "mtdblock4"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.4, "mtdblock4"
block 363 is bad
yaffs: dev is 32505862 name is "mtdblock6"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.6, "mtdblock6"
yaffs_read_super: isCheckpointed 0
yaffs: dev is 32505861 name is "mtdblock5"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.5, "mtdblock5"
yaffs_read_super: isCheckpointed 0
android_usb gadget: high speed config #1: UMS Only (Not debugging
mode)
init: cannot find '/system/bin/sh', disabling 'console'
init: cannot find '/system/bin/servicemanager', disabling
'servicemanager'
init: cannot find '/system/bin/vold', disabling 'vold'
init: cannot find '/system/bin/debuggerd', disabling 'debuggerd'
init: cannot find '/system/bin/rild', disabling 'ril-daemon'
init: cannot find '/system/bin/app_process', disabling 'zygote'
init: cannot find '/system/bin/mediaserver', disabling 'media'
init: cannot find '/system/bin/playmp3', disabling 'bootsound'
init: cannot find '/system/bin/dbus-daemon', disabling 'dbus'
init: cannot find '/system/bin/installd', disabling 'installd'
init: cannot find '/system/bin/flash_image', disabling
'flash_recovery'
init: cannot find '/system/bin/keystore', disabling 'keystore'
enabling adb
android_usb gadget: high speed config #1: UMS + ADB (Debugging mode)
************************* End of log ******************************
please advise what could be the reason for this.
any help will be appreciated.

second posting: First problem resolved
Ok I got it. My onenand device is if 2Kb page side and in the mkyaffs2 utils
4KB page support was enabled.
Now the board boots till prompt but still i cann't see the Android coming up
on the LCD and text is there.
Any idea whats still wrong with it?

Third posting: New problem
Hi all,
more info in the below problem...
here i am sending the logcat massages..its seems these massages are
getting repeated..
Any help will be appreciated..

************ logcat massage start ****************


I/DEBUG ( 1701): debuggerd: Nov 3 2009 18:39:21
I/vold ( 1700): Android Volume Daemon version 2.0
D/vold ( 1700): Bootstrapping complete
E/flash_image( 1709): error opening /system/recovery.img: No such file
or directory
D/DHCP ( 1724): failed to set ip addr for eth0 to 0.0.0.0: No such
device
D/AndroidRuntime( 1703):
D/AndroidRuntime( 1703): >>>>>>>>>>>>>> AndroidRuntime START
<<<<<<<<<<<<<<
D/AndroidRuntime( 1703): CheckJNI is ON
D/dalvikvm( 1703): DexOpt: incorrect opt magic number (0xff ff ff ff)
D/dalvikvm( 1703): Stale deps in cache file; removing and retrying
I/ ( 1704): ServiceManager: 0xad18
D/AudioHardwareALSA( 1704): Mixer: element name: 'DAC1'
D/AudioHardwareALSA( 1704): Mixer: element name: 'DAC2'
D/AudioHardwareALSA( 1704): Mixer: element name: 'DAC3'
D/AudioHardwareALSA( 1704): Mixer: master 'PCM' not found.
D/AudioHardwareALSA( 1704): Mixer: route 'Earpiece' not found.
D/AudioHardwareALSA( 1704): Mixer: route 'Speaker' not found.
D/AudioHardwareALSA( 1704): Mixer: route 'Bluetooth' not found.
D/AudioHardwareALSA( 1704): Mixer: route 'Headphone' not found.
D/AudioHardwareALSA( 1704): Mixer: route 'Bluetooth A2DP' not found.
D/AudioHardwareALSA( 1704): Mixer: master 'Capture' not found.
D/AudioHardwareALSA( 1704): Mixer: route 'Capture' not found.
D/AudioHardwareALSA( 1704): Mixer: route '' not found.
D/AudioHardwareALSA( 1704): Mixer: route 'Bluetooth Capture' not
found.
D/AudioHardwareALSA( 1704): Mixer: route 'Capture' not found.
D/AudioHardwareALSA( 1704): Mixer: route 'Bluetooth A2DP Capture' not
found.
D/AudioHardwareALSA( 1704): mixer initialized.
D/AudioHardwareInterface( 1704): setMode(NORMAL)
I/CameraService( 1704): CameraService started: pid=1704
V/AudioHardwareALSA( 1704): virtual android::AudioStreamOut*
android::AudioHardwareALSA::openOutputStream(uint32_t, int*,
uint32_t*, uint32_t*, android::status_t*) - format = 0, channels = 0,
sampleRate = 0
V/AudioHardwareALSA( 1704): ALSAStreamOps - input - format = 0,
channels = 0, rate = 0
V/AudioHardwareALSA( 1704): ALSAStreamOps - default - format = 2,
channels = 2, rate = 44100
E/ALSALib ( 1704): external/alsa-lib/src/control/setup.c:555:
(add_elem) Cannot obtain info for CTL elem (MIXER,'Playback Path',
0,0,0): No such file or directory
E/ALSALib ( 1704): external/alsa-lib/src/control/setup.c:555:
(add_elem) Cannot obtain info for CTL elem (MIXER,'Playback Path',
0,0,0): No such file or directory
I/AudioHardwareALSA( 1704): Initialized ALSA PLAYBACK device
AndroidPlayback
D/AudioHardwareALSA( 1704): Set PLAYBACK PCM format to S16_LE (Signed
16 bit Little Endian)
I/AudioHardwareALSA( 1704):
I/AudioHardwareALSA( 1704): android::status_t
android::ALSAStreamOps::channelCount(int)::671
D/AudioHardwareALSA( 1704): Using 2 channels for PLAYBACK.
D/AudioHardwareALSA( 1704): Set PLAYBACK sample rate to 44100 HZ
D/AudioHardwareALSA( 1704): Buffer size: 4096
D/AudioHardwareALSA( 1704): Latency: 92879
I/AudioFlinger( 1704): openOutput() created mixer output: ID 1 thread
0x26178
I/AudioFlinger( 1704): AudioFlinger's thread 0x26178 ready to run
W/dalvikvm( 1703): partial write in inflate (20440 vs 32768)
E/dalvikvm( 1703): Unable to extract+optimize DEX from '/system/
framework/framework.jar'
D/dalvikvm( 1703): Unable to process classpath element '/system/
framework/framework.jar'
E/dalvikvm( 1703): opt header write failed: No space left on device
I/dalvikvm( 1703): Unable to open or create cache for /system/
framework/android.policy.jar (/data/dalvik-cache/
system@framew...@android.policy.jar@classes.dex)
D/dalvikvm( 1703): Unable to process classpath element '/system/
framework/android.policy.jar'
E/dalvikvm( 1703): opt header write failed: No space left on device
I/dalvikvm( 1703): Unable to open or create cache for /system/
framework/services.jar (/data/dalvik-cache/
system@framew...@services.jar@classes.dex)
D/dalvikvm( 1703): Unable to process classpath element '/system/
framework/services.jar'
E/dalvikvm( 1703): Unable to find createAnnotation() in android
AnnotationFactory
D/dalvikvm( 1703): VM cleaning up
D/dalvikvm( 1703): LinearAlloc 0x0 used 44308 of 5242880 (0%)
W/dalvikvm( 1703): JNI_CreateJavaVM failed
E/AndroidRuntime( 1703): JNI_CreateJavaVM failed
D/AndroidRuntime( 1733):
D/AndroidRuntime( 1733): >>>>>>>>>>>>>> AndroidRuntime START
<<<<<<<<<<<<<<
D/AndroidRuntime( 1733): CheckJNI is ON
D/dalvikvm( 1733): DexOpt: incorrect opt magic number (0xff ff ff ff)
D/dalvikvm( 1733): Stale deps in cache file; removing and retrying
W/dalvikvm( 1733): partial write in inflate (20440 vs 32768)
E/dalvikvm( 1733): Unable to extract+optimize DEX from '/system/
framework/framework.jar'
D/dalvikvm( 1733): Unable to process classpath element '/system/
framework/framework.jar'
E/dalvikvm( 1733): opt header write failed: No space left on device
I/dalvikvm( 1733): Unable to open or create cache for /system/
framework/android.policy.jar (/data/dalvik-cache/
system@framew...@android.policy.jar@classes.dex)
D/dalvikvm( 1733): Unable to process classpath element '/system/
framework/android.policy.jar'
E/dalvikvm( 1733): opt header write failed: No space left on device
I/dalvikvm( 1733): Unable to open or create cache for /system/
framework/services.jar (/data/dalvik-cache/
system@framew...@services.jar@classes.dex)
D/dalvikvm( 1733): Unable to process classpath element '/system/
framework/services.jar'
E/dalvikvm( 1733): Unable to find createAnnotation() in android
AnnotationFactory
D/dalvikvm( 1733): VM cleaning up
D/dalvikvm( 1733): LinearAlloc 0x0 used 44308 of 5242880 (0%)
W/dalvikvm( 1733): JNI_CreateJavaVM failed
E/AndroidRuntime( 1733): JNI_CreateJavaVM failed
D/AndroidRuntime( 1734):
D/AndroidRuntime( 1734): >>>>>>>>>>>>>> AndroidRuntime START
<<<<<<<<<<<<<<
D/AndroidRuntime( 1734): CheckJNI is ON
D/dalvikvm( 1734): DexOpt: incorrect opt magic number (0xff ff ff ff)
D/dalvikvm( 1734): Stale deps in cache file; removing and retrying
W/dalvikvm( 1734): partial write in inflate (20440 vs 32768)
E/dalvikvm( 1734): Unable to extract+optimize DEX from '/system/
framework/framework.jar'
D/dalvikvm( 1734): Unable to process classpath element '/system/
framework/framework.jar'
E/dalvikvm( 1734): opt header write failed: No space left on device
I/dalvikvm( 1734): Unable to open or create cache for /system/
framework/android.policy.jar (/data/dalvik-cache/
system@framew...@android.policy.jar@classes.dex)
D/dalvikvm( 1734): Unable to process classpath element '/system/
framework/android.policy.jar'
E/dalvikvm( 1734): opt header write failed: No space left on device
I/dalvikvm( 1734): Unable to open or create cache for /system/
framework/services.jar (/data/dalvik-cache/
system@framew...@services.jar@classes.dex)
D/dalvikvm( 1734): Unable to process classpath element '/system/
framework/services.jar'
E/dalvikvm( 1734): Unable to find createAnnotation() in android
AnnotationFactory
D/dalvikvm( 1734): VM cleaning up
D/dalvikvm( 1734): LinearAlloc 0x0 used 44308 of 5242880 (0%)
W/dalvikvm( 1734): JNI_CreateJavaVM failed
E/AndroidRuntime( 1734): JNI_CreateJavaVM failed
D/AndroidRuntime( 1735):
D/AndroidRuntime( 1735): >>>>>>>>>>>>>> AndroidRuntime START
<<<<<<<<<<<<<<
************************ logcat end***************
These massages keep coming...


please help.

Fourth posting: Got reply from mvniekerk

Have you've checked for read only partitions?

What Android does upon initial bootup it will extract the apk files
into the /data/ folder. If it doesn't have write access it will fail.
Also, if there is no space on the device to extract these it also
won't work.

Fifth Posting: got another problem
Hello again,
i changed my data partition from 11MB to 31MB. Now the logcat massages
has changed as below, please give some pointer if any one have face
similar problem:

************* logcat start *******************
D/AndroidRuntime( 1766): CheckJNI is ON
D/dalvikvm( 1766): DexOpt: incorrect opt magic number (0xff ff ff ff)
D/dalvikvm( 1766): Stale deps in cache file; removing and retrying
D/dalvikvm( 1766): DexOpt: --- BEGIN 'framework.jar' (bootstrap=1) ---
I/DEBUG ( 1701): *** *** *** *** *** *** *** *** *** *** *** *** ***
*** *** ***
I/DEBUG ( 1701): pid: 1767, tid: 1767 >>> /system/bin/dexopt <<<
I/DEBUG ( 1701): signal 11 (SIGSEGV), fault addr 456d1abc
I/DEBUG ( 1701): r0 4223a008 r1 000162b0 r2 04000a24 r3 00000001
I/DEBUG ( 1701): r4 400aa4c8 r5 41a290f2 r6 416d1098 r7 4174584c
I/DEBUG ( 1701): r8 00000000 r9 00000000 10 00000000 fp 00000000
I/DEBUG ( 1701): ip becc5580 sp becc5620 lr afe0eca8 pc
ad057486 cpsr 00000030
I/DEBUG ( 1701): #00 pc 00057486 /system/lib/libdvm.so
I/DEBUG ( 1701): #01 pc 00057afe /system/lib/libdvm.so
I/DEBUG ( 1701): #02 pc 0005828a /system/lib/libdvm.so
I/DEBUG ( 1701): #03 pc 0005849a /system/lib/libdvm.so
I/DEBUG ( 1701): #04 pc 00057d84 /system/lib/libdvm.so
I/DEBUG ( 1701): #05 pc 00059602 /system/lib/libdvm.so
I/DEBUG ( 1701): #06 pc 00058530 /system/lib/libdvm.so
I/DEBUG ( 1701): #07 pc 000582e2 /system/lib/libdvm.so
I/DEBUG ( 1701): #08 pc 0005849a /system/lib/libdvm.so
I/DEBUG ( 1701): #09 pc 00057d84 /system/lib/libdvm.so
I/DEBUG ( 1701): #10 pc 00059602 /system/lib/libdvm.so
I/DEBUG ( 1701): #11 pc 00058530 /system/lib/libdvm.so
I/DEBUG ( 1701): #12 pc 000582e2 /system/lib/libdvm.so
I/DEBUG ( 1701): #13 pc 0005849a /system/lib/libdvm.so
I/DEBUG ( 1701): #14 pc 00057d84 /system/lib/libdvm.so
I/DEBUG ( 1701): #15 pc 000492f4 /system/lib/libdvm.so
I/DEBUG ( 1701): #16 pc 00045a88 /system/lib/libdvm.so
I/DEBUG ( 1701): #17 pc 0004683e /system/lib/libdvm.so
I/DEBUG ( 1701): #18 pc 00048ffc /system/lib/libdvm.so
I/DEBUG ( 1701): #19 pc 0004923a /system/lib/libdvm.so
I/DEBUG ( 1701): #20 pc 0004b678 /system/lib/libdvm.so
I/DEBUG ( 1701): #21 pc 0004b6fa /system/lib/libdvm.so
I/DEBUG ( 1701): #22 pc 0004b7a0 /system/lib/libdvm.so
I/DEBUG ( 1701): #23 pc 0004a74c /system/lib/libdvm.so
I/DEBUG ( 1701): #24 pc 0004a8fe /system/lib/libdvm.so
I/DEBUG ( 1701): #25 pc 00008e1c /system/bin/dexopt
I/DEBUG ( 1701): #26 pc 00008ed2 /system/bin/dexopt
I/DEBUG ( 1701): #27 pc 0000bf66 /system/lib/libc.so
I/DEBUG ( 1701): #28 pc b00016d0 /system/bin/linker
I/DEBUG ( 1701): stack:
I/DEBUG ( 1701): becc55e0 400aa4c8 /dev/ashmem/mspace/dalvik-
heap/0 (deleted)
I/DEBUG ( 1701): becc55e4 ad0428f1 /system/lib/libdvm.so
I/DEBUG ( 1701): becc55e8 00000000
I/DEBUG ( 1701): becc55ec ad080be8 /system/lib/libdvm.so
I/DEBUG ( 1701): becc55f0 00000000
I/DEBUG ( 1701): becc55f4 ad080be8 /system/lib/libdvm.so
I/DEBUG ( 1701): becc55f8 0000034c
I/DEBUG ( 1701): becc55fc 00010008 [heap]
I/DEBUG ( 1701): becc5600 001800c0
I/DEBUG ( 1701): becc5604 000162b0 [heap]
I/DEBUG ( 1701): becc5608 4174584c /data/dalvik-cache/
system@framew...@core.jar@classes.dex
I/DEBUG ( 1701): becc560c afe0b985 /system/lib/libc.so
I/DEBUG ( 1701): becc5610 400aa4c8 /dev/ashmem/mspace/dalvik-
heap/0 (deleted)
I/DEBUG ( 1701): becc5614 41a290ee /data/dalvik-cache/
system@framew...@core.jar@classes.dex
I/DEBUG ( 1701): becc5618 df002777
I/DEBUG ( 1701): becc561c e3a070ad
I/DEBUG ( 1701): #00 becc5620 400833d8 /dev/ashmem/mspace/dalvik-
heap/0 (deleted)
I/DEBUG ( 1701): becc5624 ad055f8b /system/lib/libdvm.so
I/DEBUG ( 1701): becc5628 40028938 /dev/ashmem/mspace/dalvik-
heap/0 (deleted)
I/DEBUG ( 1701): becc562c ad055f8b /system/lib/libdvm.so
I/DEBUG ( 1701): becc5630 00010f90 [heap]
I/DEBUG ( 1701): becc5634 4222dda0
I/DEBUG ( 1701): becc5638 00a6eba0
I/DEBUG ( 1701): becc563c 00010008 [heap]
I/DEBUG ( 1701): becc5640 ad07ff44 /system/lib/libdvm.so
I/DEBUG ( 1701): becc5644 00000000
I/DEBUG ( 1701): becc5648 becc56a0 [stack]
I/DEBUG ( 1701): becc564c 00000000
I/DEBUG ( 1701): becc5650 000162b0 [heap]
I/DEBUG ( 1701): becc5654 0014dd74
I/DEBUG ( 1701): becc5658 4216af2c /data/dalvik-cache/
system@framew...@framework.jar@classes.dex
I/DEBUG ( 1701): becc565c 400aa558 /dev/ashmem/mspace/dalvik-
heap/0 (deleted)
I/DEBUG ( 1701): becc5660 00000000
I/DEBUG ( 1701): becc5664 afe0eca8 /system/lib/libc.so
I/DEBUG ( 1701): becc5668 000117bc [heap]
I/DEBUG ( 1701): becc566c afe0ed98 /system/lib/libc.so
I/DEBUG ( 1701): becc5670 41a56b3c /data/dalvik-cache/
system@framew...@core.jar@classes.dex
I/DEBUG ( 1701): becc5674 ad05f0b7 /system/lib/libdvm.so
I/DEBUG ( 1701): becc5678 00001647
I/DEBUG ( 1701): becc567c ad07ff44 /system/lib/libdvm.so
I/DEBUG ( 1701): becc5680 00016318 [heap]
I/DEBUG ( 1701): becc5684 4174584c /data/dalvik-cache/
system@framew...@core.jar@classes.dex
I/DEBUG ( 1701): becc5688 00000000
I/DEBUG ( 1701): becc568c ad057b03 /system/lib/libdvm.so
I/DEBUG ( 1701): #01 becc5690 00000000
I/DEBUG ( 1701): becc5694 00016318 [heap]
I/DEBUG ( 1701): becc5698 00000001
I/DEBUG ( 1701): becc569c 00000004
I/DEBUG ( 1701): becc56a0 00010008 [heap]
I/DEBUG ( 1701): becc56a4 0014dd2c
I/DEBUG ( 1701): becc56a8 00000001
I/DEBUG ( 1701): becc56ac 00010001 [heap]
I/DEBUG ( 1701): becc56b0 41a2a35d /data/dalvik-cache/
system@framew...@core.jar@classes.dex
I/DEBUG ( 1701): becc56b4 00000000
I/DEBUG ( 1701): becc56b8 0000c248 [heap]
I/DEBUG ( 1701): becc56bc ad07ff44 /system/lib/libdvm.so
I/DEBUG ( 1701): becc56c0 00016318 [heap]
I/DEBUG ( 1701): becc56c4 ad05828f /system/lib/libdvm.so
W/dalvikvm( 1766): DexOpt: --- END 'framework.jar' --- status=0x000b,
process failed
E/dalvikvm( 1766): Unable to extract+optimize DEX from '/system/
framework/framework.jar'
D/dalvikvm( 1766): Unable to process classpath element '/system/
framework/framework.jar'
W/dalvikvm( 1766): Exception Ljava/lang/NoSuchMethodError; thrown
during Lorg/apache/harmony/xnet/provider/jsse/
OpenSSLSocketImpl;.
E/OpenSSLSocketImpl( 1766): Can't find OpenSSLSocketImpl.ssl_ctx
W/dalvikvm( 1766): jniRegisterSystemMethods failed
D/dalvikvm( 1766): VM cleaning up
D/dalvikvm( 1766): LinearAlloc 0x0 used 138836 of 5242880 (2%)
W/dalvikvm( 1766): JNI_CreateJavaVM failed
E/AndroidRuntime( 1766): JNI_CreateJavaVM failed
D/AndroidRuntime( 1768):
D/AndroidRuntime( 1768): >>>>>>>>>>>>>> AndroidRuntime START
<<<<<<<<<<<<<<
D/AndroidRuntime( 1768): CheckJNI is ON
D/dalvikvm( 1768): DexOpt: incorrect opt magic number (0xff ff ff ff)
D/dalvikvm( 1768): Stale deps in cache file; removing and retrying
D/dalvikvm( 1768): DexOpt: --- BEGIN 'framework.jar' (bootstrap=1) ---
I/DEBUG ( 1701): *** *** *** *** *** *** *** *** *** *** *** *** ***
*** *** ***
I/DEBUG ( 1701): pid: 1769, tid: 1769 >>> /system/bin/dexopt <<<
I/DEBUG ( 1701): signal 11 (SIGSEGV), fault addr 456d1abc
I/DEBUG ( 1701): r0 4223a008 r1 000162b0 r2 04000a24 r3 00000001
I/DEBUG ( 1701): r4 400aa4c8 r5 41a290f2 r6 416d1098 r7 4174584c
I/DEBUG ( 1701): r8 00000000 r9 00000000 10 00000000 fp 00000000
I/DEBUG ( 1701): ip bedf8580 sp bedf8620 lr afe0eca8 pc
ad057486 cpsr 00000030


******************** logcat end here ********************************
these mesg are repeating......
Any help will be appreciated.

sixth posting: Finally got it working
Hello again,
at last i got it working..android home page is coming up..
after increasing the size of data partition to 31MB and deleting the /data
folder contains, i rebooted the system and android booted.

Hope this will help to other people who are facing (might face)
similar problem.


you can find the original discussion here.

Friday, November 06, 2009

Oprofile on ARM Linux

Introduction

This article applies to OProfile version 0.9.5. OProfile is a profiling system for Linux 2.2/2.4/2.6 systems on a number of architectures. It is capable of profiling all parts of a running system, from the kernel (including modules and interrupt handlers) to shared libraries to binaries. It runs transparently in the background collecting information at a low overhead. These features make it ideal for profiling entire systems to determine bottle necks in real-world systems. Many CPUs provide "performance counters", hardware registers that can count "events"; for example, cache misses, or CPU cycles. OProfile provides profiles of code based on the number of these occurring events: repeatedly, every time a certain (configurable) number of events have occurred, the PC value is recorded. This information is aggregated into profiles for each binary image.

Some hardware setups do not allow OProfile to use performance counters: in these cases, no events are available, and OProfile operates in timer/RTC mode as described below(RTC mode only applicable till linux kernel 2.4).


Cross-Compiling oprofile for ARM arch

Unpack the oprofile-0.9.5.tar.bz2 and go the oprofile directory

[test@localhost]# cd oprofile-0.9.5


Run the below command to configure the oprofile for cross compilation

[test@localhost oprofile-0.9.5]# ./configure –host=arm-linux –-with-kernel-support


Recommendation: Please use any cross compilation environment like CLFS or Scratchbox for cross compilation. My environment is scratchbox. This is important to resolve lots of library dependence and to save lots of time.


Once the configuration is successful, run make to compile the oprofile.

[test@localhost oprofile-0.9.5]# make


Now install the oprofile, during installation you can specify the rootfs as install path, which will directly install or copy the oprofile binaries and libraries to your root file system.


Run the below command to install the oprofile daemon.

[test@localhost oprofile-0.9.5]# make DESTDIR=<INSTALL PATH> install


Running and using oprofile tools

Oprofile can run into two modes, one is by using the hardware performance monitor controller (PMNC for Cortex-A8) and Timer interrupt mode.

Tool summary

This section gives a brief description of the available OProfile utilities and their purpose.

ophelp

This utility lists the available events and short descriptions.

Opcontrol

Used for controlling the OProfile data collection, discussed below in section 4.4

Opreport

This is the main tool for retrieving useful profile data, described below

Opannotate

his utility can be used to produce annotated source, assembly or mixed source/assembly. Source level annotation is available only if the application was compiled with debugging symbols.

Opgprof

This utility can output gprof-style data files for a binary, for use with gprof –p.

Oparchive

This utility can be used to collect executables, debuginfo, and sample files and copy the files into an archive. The archive is self-contained and can be moved to another machine for further analysis.

Opimport

This utility converts sample database files from a foreign binary format (abi) to the native format. This is useful only when moving sample files between hosts, for analysis on platforms other than the one used for collection.

agent libraries

Used by virtual machines (like the Java VM) to record information about JITed code being profiled.


Oprofile in Timer Interrupt Mode

This section applies to 2.6 kernels and above only. In 2.6 kernels on CPUs without OProfile support for the hardware performance counters, the driver falls back to using the timer interrupt for profiling.

You can force use of the timer interrupt by using the timer=1 module parameter (or oprofile.timer=1 on the boot command line if OProfile is built-in).


Oprofile in Hardware Performance monitor counter(PMNC) mode

In the case you have to add the PMNC IRQ number to the oprofile driver for the armv7 driver in side file arch/arm/oprofilr/op_mode_v7.c

Add the below line:

Static int irqs[ ] ={

#ifdef CONFIG_ARCH_OMAP3

INT_34XX_BENCH_MPU_EMUL,

#endif

+ #ifdef CONFIG_ARCH_

+ , //Irq number for the PMNC controller for CORTEX-A8 in your SoC.

+ #endif

};


Using Opcontrol

In this section we describe the configuration and control of the profiling system with opcontrol.

Download the zImage to the target board using rootfs which contains oprofiling tools. And run as below;

First, we need to be the root user to use OProfile. So, either login as the root user, or use the su command and switch to the root user. Next, we need to setup OProfile. We have two options. We can either profile our application with, or without the Linux kernel. If we want to profile with the Linux kernel, we need to reference the uncompressed kernel image file in the /root directory.

#Init Oprofile:

[root@localhost ~] opcontrol –-reset

[root@localhost ~] opcontrol –-init

[root@localhost ~] opcontrol –-vmlinux=/root/vmlinux

#Setup events

[root@localhost ~] opcontrol –e CPU_CYCLES:100000:0:1:1

#Start

[root@localhost ~] opcontrol –-start-daemon

[root@localhost ~] opcontrol –start

# verify PMNC IRQs

[root@localhost ~] cat /proc/interrupt

Note: one entry should be there in /proc corresponding to PMNC irq only in case you are using PMNC mode.

Run any application at this point of time.

# stoping profiling

[root@localhost ~] opcontrol –-dump

[root@localhost ~] opcontrol –-stop

# Deinit

[root@localhost ~] opcontrol –-shutdown

[root@localhost ~] opcoontrol –-deinit

# Get the report

[root@localhost ~] opreport

Overflow stats not available

CPU: ARM V7 PMNC, speed 0 MHz (estimated)

Counted CPU_CYCLES events (Number of CPU cycles) with a unit mask of 0x00 (No

unit mask) count 100000

CPU_CYCLES:100000|

samples| %|

------------------

337 91.3279 hello

21 5.6911 no-vmlinux

6 1.6260 libc-2.5.so

4 1.0840 ld-2.5.so

1 0.2710 busybox


[root@localhost ~]# opreport --callgraph
CPU: ARM V7 PMNC, speed 0 MHz (estimated)
Counted CPU_CYCLES events (Number of CPU cycles) with a unit mask of 0x00 (No
unit mask) count 100000
samples % app name symbol name
-------------------------------------------------------------------------------
477 86.1011 hello1 main
477 100.000 hello1 main [self]
-------------------------------------------------------------------------------
15 2.7076 vmlinux _spin_unlock_irqrestore
15 100.000 vmlinux _spin_unlock_irqrestore [self]
-------------------------------------------------------------------------------
7 1.2635 vmlinux check_poison_obj
7 100.000 vmlinux check_poison_obj [self]
-------------------------------------------------------------------------------
4 0.7220 busybox /bin/busybox
4 100.000 busybox /bin/busybox [self]
-------------------------------------------------------------------------------
4 0.7220 vmlinux __do_softirq
4 100.000 vmlinux __do_softirq [self]

Conclusion
It should be noted that Oprofile does not provide 100% instruction-accurate profiles and cannot accept any disturbance to the system at all.
Oprofile is easy to install and run.
Oprofile can give a full profile, kernel + all processes
Very detailed CPU info available with advanced usage.
useful links:

http://oprofile.sourceforge.net/
http://oprofile.sourceforge.net/doc/index.html
http://oprofile.sourceforge.net/doc/internals/index.html
and google for your questions.



My learning continues...............Alim




Monday, November 02, 2009

ARM Processor Modes
The processor mode determines which registers are active and the access rights to CPSR register itself. Each processor mode is either privileged or nonprivileged. A privileged mode allows full read-write access to cpsr. Conversely, a nonprivileged mode only allow read access to the control field in the CPSR but still allow read-write access to the condition flags.
There are seven processor mode in total, six privileged modes and one user mode.

Privileged Modes:
Abort: The processor enters the abort mode when there is a failed attempt to aaccess memory.
Fast Interrupt & Interrupt request: two interrupt level available on the ARM processor.
Supervisor: mode that the processor is in after reset and is generally the mode that an operating system kernel operates in.
System Mode: special version of user mode that allow the full read write access to the CPSR.
Undefined mode: is used when processor encounters an instruction that is undefined or not supported by the implementation.
User mode: is used for programs and applications.

Table: ARM Processor Mode