Android eMMC throughput measurement

=  Android eMMC Throughput measurement  =

Introduction
Android native "dd" command seems to be unreliable for measuring bandwidth. we recommend to use instead busybox "dd" command, it seems to provide more repetitive and reliable throughput numbers with busybox. In addition of that the code of test script is provided to run a set of read/write test measuring eMMC throughput.

Installing Busybox
Download busybox-1.19.4.tar.bz2 from www.busybox.net.

You can also refer to this link to obtain more details: Android Installing Busybox

Busybox sources are built using Sourcery G++ Lite 2010q1-202 for ARM GNU/Linux version.

This tool chain can be obtained from

 Configure and build busybox: 

Download busybox code

wget http://busybox.net/downloads/busybox-1.19.4.tar.bz2 tar -xvf busybox-1.19.4.tar.bz2 mv busybox-1.19.4 busybox_src

or

git clone git://busybox.net/busybox.git -b 1_19_stable mv busybox busybox_src

Configure busybox

Note: Your have to add your tool chain path to your PATH environment variable.

cd busybox_src make CROSS_COMPILE=arm-none-linux-gnueabi- defconfig

You can modify busybox configuration with:

''Note: But how to use it, is beyond the scope of this docuemnt. ''

make CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig

Build

make CROSS_COMPILE=arm-none-linux-gnueabi- mkdir ../busybox make CROSS_COMPILE=arm-none-linux-gnueabi- CONFIG_PREFIX=../busybox install

 Android install: 

adb root adb remount adb shell 'mkdir /data/busybox' adb push busybox /data/busybox adb shell 'chmod 0755 /data/busybox/bin/* /data/busybox/sbin/*' adb shell '[ -d /system/vendor/bin -a ! -L /system/vendor/bin ] && mv /system/vendor/bin /system/vendor/bin.orig' adb shell '[ -d /system/vendor/sbin -a ! -L /system/vendor/sbin ] && mv /system/vendor/sbin /system/vendor/sbin.orig' adb shell '[ -d /system/vendor/bin -a -L /system/vendor/bin ] && rm /system/vendor/bin' adb shell '[ -d /system/vendor/sbin -a -L /system/vendor/sbin ] && rm /system/vendor/sbin' adb shell 'ln -s /data/busybox/bin /system/vendor/bin' adb shell 'ln -s /data/busybox/sbin /system/vendor/sbin' adb shell '[ -d /system/vendor/bin.orig ] && cp -f /system/vendor/bin.orig/* /system/vendor/bin' adb shell '[ -d /system/vendor/sbin.orig ] && cp -f /system/vendor/sbin.orig/* /system/vendor/sbin' adb shell sync
 * 1) Adquiring root permissions and remounting
 * 1) Downloading Busybox binaries to Android system.
 * 1) Backup the real directories if they exist
 * 1) Remove the real directories if they are symlinks
 * 1) Create symlinks:
 * 1) Copy the contents of the original directories into the new ones

eMMC Throughput test procedure
First you need to identify the "data" partion device:

adb shell 'ls -l `mount | grep -i "/data" | cut -d " " -f 1` '

The code above will exit a log like this

lrwxrwxrwx   1 0        0               21 Jan  1 00:00 /dev/block/platform/omap/omap_hsmmc.1/by-name/userdata -> /dev/block/mmcblk0p10

This mean we goint to use "/dev/block/mmcblk0p10" as a device (this is normal for 4AI1.x ICS and "/dev/block/mmcblk0p8" for L27 GB).

You should open a text editor and copy all the code in section "Handler Throughput script code" and save as "handler_throughput.sh"

After you do that you could copy the script to you android device

adb push ./handler_throughput.sh /data/ adb shell 'chmod 777 /data/handler_throughput.sh '

Then execute the script

adb shell '/data/handler_throughput.sh /dev/block/mmcblk0p10 /data/external/'

Handler Throughput script code
DEVICE=${1? Error: first parameter "Device" missing} FOLDER=${2? Error: Second parameter "Folder" missing} BLOCKSIZE=1024000 COUNT=200 ITERATIONS=5 #Eg: iterate_bw /dev/zero /mnt/ext_sdcard/zero.bin 1 iterate_bw { TIME=0 for i in $(seq 0 $ITERATIONS); do echo ITERATION=$i if [ "$3" = "1" ]; then echo 1 > /proc/sys/vm/drop_caches && sync fi ALL=$(time dd if=$1 of=$2 bs=$BLOCKSIZE count=$COUNT 2>&1) echo ALL=$ALL REAL=$(echo $ALL | cut -d' ' -f16 | tr -d '[a-z\.]' ) SYS=$(echo $ALL | cut -d' ' -f22 | tr -d '[a-z\.]' ) TIME=$(( TIME + REAL + SYS )) echo REAL=$REAL SYS=$SYS TIME=$(( TIME / 100 )) done BW=$(( (BLOCKSIZE * COUNT * ITERATIONS) / ((TIME / 100) * 1024 * 1024) )) echo BW=$BW } if [ ! -d "${FOLDER}" ];then if [ -e "${FOLDER}" ];then echo "Error: $FOLDER exists but is not a folder" exit 1 else echo "Warning: $FOLDER does not exist, and is been created" mkdir -p $FOLDER fi fi if [ ! -e "${DEVICE}" ];then echo "Error: $DEVICE does not exist" exit 1 fi echo iterate_bw "/dev/zero" "$FOLDER/zero.bin" 1 iterate_bw "/dev/zero" "$FOLDER/zero.bin" 1 FS_WRITE=$BW echo iterate_bw "$FOLDER/zero.bin" "/dev/null" 1 iterate_bw "$FOLDER/zero.bin" "/dev/null" 1 FS_READ=$BW echo iterate_bw "$DEVICE" "/dev/null" 1 iterate_bw "$DEVICE" "/dev/null" 1 RAW_READ=$BW rm $FOLDER/zero.bin echo "---" echo FILE SYSTEM WRITE THROUGHPUT = $FS_WRITE MBytes/sec echo FILE SYSTEM READ THROUGHPUT = $FS_READ MBytes/sec echo RAW READ THROUGHPUT =        $RAW_READ MBytes/sec echo "---"
 * 1) !/data/busybox/bin/sh
 * 2) Name:		hander_throughput.sh
 * 3) Description:	Helper script to measure throughput for
 * 4) 		read and write. Does not mount/unmount
 * 5) 		partitions. Assumed necessary partition
 * 6) 		is already mounted at correct location
 * 7) Usage:	./handler_throughput
 * 8) 		Eg:
 * 9) 		./handler_throughput /dev/block/mmcblk0p10 /data
 * 10) Author:	Viswanath, Puttagunta
 * 11) Date:		30 Mar, 2012
 * 12) /data/handler_throughput.sh /dev/block/mmcblk0p8 /data/external/
 * 13) /data/handler_throughput.sh /dev/block/mmcblk0p10 /data/external/
 * 1) /data/handler_throughput.sh /dev/block/mmcblk0p8 /data/external/
 * 2) /data/handler_throughput.sh /dev/block/mmcblk0p10 /data/external/
 * 1) Usage
 * 2) iterate_bw   
 * 1) function iterate_bw
 * 1) for ((i=0; i < $ITERATIONS; i++)); do
 * 1) ALL=$((time -p dd if=$1 of=$2 bs=$BLOCKSIZE count=$COUNT && sync) 2>&1)
 * 1) TIME=$(echo "$TIME + $REAL + $SYS" | bc)
 * 2) TIME=$( let "$TIME + $REAL + $SYS" )
 * 1) TIME=$(let "$TIME / 100")
 * 1) BW=$(echo "($BLOCKSIZE*$COUNT*$ITERATIONS) / (($TIME)*1024*1024)" | bc)
 * 1) File System Write Throughput
 * 1) File System Read Throughput
 * 1) Device Raw Read Throughput