Android system binaries disappearing when running from NAND and YAFFS2

234 views
Skip to first unread message

Elvis Dowson

unread,
Mar 24, 2010, 11:02:25 PM3/24/10
to android-porting
Hi,
I'm facing a problem, trying to run android-2.6.29 kernel and
android-1.5r3 off NAND on the gumstix Overo, where somehow, the
android binaries in the /system/bin folder are getting deleted, like
vold, etc, upon boot from NAND, with the following error messages.
These messages appear, and after I inspect the NAND filesystem, its
actually gone missing.

init: Unable to open persistent property directory /data/property
errno: 2
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/app_process', disabling 'zygote'
init: cannot find '/system/bin/mediaserver', disabling 'media'
init: cannot find '/system/bin/installd', disabling 'installd'
/system/bin/sh: can't access tty; job control turned off

Before I launched android, I inspected the /system/bin folder in NAND,
after flashing it, and the above binaries were present. After running
it from NAND, these binaries disappear.

My NAND partitions are as follows

reating 7 MTD partitions on "omap2-nand":
0x000000000000-0x000000080000 : "xloader"
0x000000080000-0x000000240000 : "uboot"
0x000000240000-0x000000280000 : "uboot environment"
0x000000280000-0x000000680000 : "linux"
0x000000680000-0x00000a680000 : "system"
0x00000a680000-0x00000c680000 : "userdata"
0x00000c680000-0x00000e680000 : "cache"

root@overo:/# cat /proc/mtd
dev: size erasesize name
mtd0: 00080000 00020000 "xloader"
mtd1: 001c0000 00020000 "uboot"
mtd2: 00040000 00020000 "uboot environment"
mtd3: 00400000 00020000 "linux"
mtd4: 0a000000 00020000 "system"
mtd5: 02000000 00020000 "userdata"
mtd6: 02000000 00020000 "cache"


Best regards,

Elvis Dowson

Deva R

unread,
Mar 25, 2010, 7:54:04 AM3/25/10
to elvis....@gmail.com, android-porting
pls check http://groups.google.com/group/android-porting/msg/d303260bc1dbb08a

can u cross check ur init.rc for proper MTD partition mounting sequence??

mount yaffs2 mtd@system /system
mount yaffs2 mtd@system /system ro remount
mount yaffs2 mtd@userdata /data nosuid nodev
mount yaffs2 mtd@cache /cache nosuid nodev

> --
> unsubscribe: android-porti...@googlegroups.com
> website: http://groups.google.com/group/android-porting
>
> To unsubscribe from this group, send email to android-porting+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
>

Ashwin Bihari

unread,
Mar 25, 2010, 8:15:53 AM3/25/10
to r.de...@gmail.com, elvis....@gmail.com, android-porting
Guys,

A slightly related question, since you're playing with NAND and
YAFFS2. Do you guys have a procedure handy on how to generate a YAFFS2
RFS image and flash it to the NAND using U-boot? Also on how you flash
and load the Kernel from NAND would be great. Appreciate the
pointers..

Regards
-- Ashwin

supermaximus79

unread,
Mar 25, 2010, 8:49:47 AM3/25/10
to android-porting
I made a patch for u-boot 2009.3 which enable nand write.yaffs2
command.

On Mar 25, 2:15 pm, Ashwin Bihari <abih...@gmail.com> wrote:
> Guys,
>
> A slightly related question, since you're playing with NAND and
> YAFFS2. Do you guys have a procedure handy on how to generate a YAFFS2
> RFS image and flash it to the NAND using U-boot? Also on how you flash
> and load the Kernel from NAND would be great. Appreciate the
> pointers..
>
> Regards
> -- Ashwin
>

> On Thu, Mar 25, 2010 at 7:54 AM, Deva R <r.deva...@gmail.com> wrote:
> > pls checkhttp://groups.google.com/group/android-porting/msg/d303260bc1dbb08a


>
> > can u cross check ur init.rc for proper MTD partition mounting sequence??
>
> > mount yaffs2 mtd@system /system
> > mount yaffs2 mtd@system /system ro remount
> > mount yaffs2 mtd@userdata /data nosuid nodev
> > mount yaffs2 mtd@cache /cache nosuid nodev
>

Elvis Dowson

unread,
Mar 25, 2010, 8:52:30 AM3/25/10
to Ashwin Bihari, r.de...@gmail.com, android-porting

A slightly related question, since you're playing with NAND and
YAFFS2. Do you guys have a procedure handy on how to generate a YAFFS2
RFS image and flash it to the NAND using U-boot? Also on how you flash
and load the Kernel from NAND would be great. Appreciate the
pointers..


Procedure


Step 01.00: Build a basic kernel and a non-gui root file system image.


Type in the following commands:


$ bitbake omap3-console-image

$ bitbake x-load

$ bitbake u-boot-omap3


Step 02.00: Create a bootable microSD card using gparted.


Step 02.01: Download and install gparted


$ su

# yum install gparted


Step 02.02: Launch gparted.


# gparted


Step 02.03: Delete all existing partitions on the microSD card.


Select all existing partition on the microSD card and right click and select the Delete option.


Step 02.04: Create a 32MB FAT32 partition.


Right click on the unallocated partition and select the New option and enter the following values:


New Size (MiB): 32

Filesystem: fat32

Label: disk


Step 02.05: Create an ext3 partition.


Right click on the unallocated partition and select the New option and enter the following values:


New Size (MiB): 1800

Filesystem: ext3

Label: disk-1


Step 02.06:  Copy the boot files to the FAT32 partition on the microSD card


$ su

# cd /media/disk

# cp /tool/overo-oe/tmp/deploy/glibc/images/overo/MLO-overo /media/disk/MLO

# cp /tool/overo-oe/tmp/deploy/glibc/images/overo/u-boot-overo.bin /media/disk/u-boot.bin

# cp /tool/overo-oe/tmp/deploy/glibc/images/overo/uImage-overo.bin /media/disk/uImage


Step 02.07: Copy the rootfs to the ext3 partition on the microSD card


$ su

# cd /media/disk-1

# tar xvjf /path/to/omap3-console-image-overo.tar.bz2


Step 03.00: Prepare the NAND images and NAND writing script on the microSD card.


Step 03.01: Copy the boot and rootfs images to a folder on the microSD card 


$ su

# cd /media/disk-1

# mkdir images

# cp '/tool/overo-oe/tmp/deploy/glibc/images/overo/MLO-overo' MLO

# cp '/tool/overo-oe/tmp/deploy/glibc/images/overo/u-boot-overo.bin' u-boot.bin

# cp '/tool/overo-oe/tmp/deploy/glibc/images/overo/uImage-overo.bin' uImage

# cp '/tool/overo-oe/tmp/deploy/glibc/images/overo/omap3-console-image-overo.tar.bz2' .


Step 03.02: Create a script to write the images to on-board NAND.


Create a script called overo-flash-onboard-nand-yaffs2.sh and place it in the /images folder on the microSD card.


#!/bin/sh

#

# Flash on-board NAND using YAFFS2 filesystem

#


dir=$PWD

uboot=u-boot.bin

uimage=uImage

rootfs=omap3-console-image-overo.tar.bz2

#rootfs=omap3-android-image-overo.tar.bz2

#rootfs=android-2.6.29-image-r15.tar.bz2


if [ -e $uboot ]; then

  echo "Erasing u-boot partition ..."

  flash_eraseall /dev/mtd1

  echo "Erasing u-boot environment partition ..."

  flash_eraseall /dev/mtd2

  echo "Writing u-boot to NAND ..."

  nandwrite -p /dev/mtd1 $uboot

else

  echo "ERROR:  couldn't find u-boot binary"

fi


if [ -e $uimage ]; then                 

  echo "Erasing kernel partition ..."            

  flash_eraseall /dev/mtd3                       

  echo "Writing kernel to NAND ..."         

  nandwrite -p /dev/mtd3 $uimage

else                                             

  echo "ERROR:  couldn't find kernel binary"     

fi                                               

    

if [ -e $rootfs ]; then

  umount /dev/mtdblock4

  echo "Erasing and formatting rootfs partition ..."

  flash_eraseall /dev/mtd4

  echo "Mounting rootfs partition ..."

  mkdir -p /media/mtdblock4

  mount -t yaffs2 /dev/mtdblock4 /media/mtdblock4

  cd /media/mtdblock4

  echo "Setting the date to avoid warnings about time differences ..."

  date 032010002010

  tar xjf $dir/$rootfs

  sync

  cd /

  umount /media/mtdblock4

else

  echo "ERROR:  couldn't find rootfs tarball"

fi



Step 04.00: Connect to the Overo console using Kermit


$ su

# kermit -l /dev/ttyUSB0

C-Kermit>set flow-control none

C-Kermit>set carrier-watch off

C-Kermit>set speed 115200

/dev/ttyUSB0, 115200 bps

C-Kermit>connect

Connecting to /dev/ttyUSB0, speed 115200

Escape character: Ctrl-\ (ASCII 28, FS): enabled

Type the escape character followed by C to get back,

or followed by ? to see other options.

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


Step 04.01: Reset and update the u-boot environment variables


Power up the Overo and interrupt the boot process by pressing a key in the console window.


Step 04.02:    Erase the old u-boot environment variables from NAND memory.


# nand erase 240000 20000


Step 04.03:    Modify the the boot parameters.


# printenv

# setenv defaultdisplay lcd43

# setenv dvimode 480x272MR-16@60

# setenv console ttyS2,115200n8

# setenv vram 32M


# setenv mmcargs setenv bootargs console=${console} vram=${vram} omapfb.vram=0:8M omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait


# setenv nandargs setenv bootargs console=${console} vram=${vram} omapfb.vram=0:8M omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} root=/dev/mtdblock4 rw rootfstype=yaffs2 rootwait


# saveenv

# boot


Step 05.00: Write images to on-board NAND using the YAFFS2 filesystem


Login to the Overo as root.


Step 05.01: Determine the MTD device for the file system partition of you Flash device


# cat /proc/mtd

dev:    size   erasesize  name

mtd0: 00080000 00020000 "xloader"

mtd1: 001c0000 00020000 "uboot"

mtd2: 00040000 00020000 "uboot environment"

mtd3: 00400000 00020000 "linux"

mtd4: 0f980000 00020000 "rootfs"


Creating 7 MTD partitions on "omap2-nand":

0x000000000000-0x000000080000 : "xloader"

0x000000080000-0x000000240000 : "uboot"

0x000000240000-0x000000280000 : "uboot environment"

0x000000280000-0x000000680000 : "linux"

0x000000680000-0x00000a680000 : "system"

0x00000a680000-0x00000c680000 : "userdata"

0x00000c680000-0x00000e680000 : "cache"


root@overo:/# cat /proc/mtd

dev:    size   erasesize  name

mtd0: 00080000 00020000 "xloader"

mtd1: 001c0000 00020000 "uboot"

mtd2: 00040000 00020000 "uboot environment"

mtd3: 00400000 00020000 "linux"

mtd4: 0a000000 00020000 "system"

mtd5: 02000000 00020000 "userdata"

mtd6: 02000000 00020000 "cache"



Step 05.02: Change to the NAND image folder and execute the NAND script


# cd /images

# ./overo-flash-onboard-nand-yaffs2.sh


Step 05.03: Remove the microSD card reboot the Overo


Best regards,

Elvis  

Deva R

unread,
Mar 25, 2010, 8:55:33 AM3/25/10
to Ashwin Bihari, elvis....@gmail.com, android-porting

Ashwin Bihari

unread,
Mar 25, 2010, 8:55:55 AM3/25/10
to andrusc...@mail.ru, android-porting
Could you post that patch to U-boot please.

Thanks
-- Ashwin

Ashwin Bihari

unread,
Mar 25, 2010, 8:57:06 AM3/25/10
to Deva R, elvis....@gmail.com, android-porting
Elvis,

Appreciate the detailed writeup..

Deva,

The links you provided are very helpful..

Thanks
-- Ashwin

Elvis Dowson

unread,
Mar 25, 2010, 8:57:14 AM3/25/10
to Deva R, android-porting
Hi Deva,


On Thu, Mar 25, 2010 at 3:54 PM, Deva R <r.de...@gmail.com> wrote:
pls check http://groups.google.com/group/android-porting/msg/d303260bc1dbb08a

can u cross check ur init.rc for proper MTD partition mounting sequence??

mount yaffs2 mtd@system /system
mount yaffs2 mtd@system /system ro remount
mount yaffs2 mtd@userdata /data nosuid nodev
mount yaffs2 mtd@cache /cache nosuid nodev


Yes, my init.rc is using that same mount sequence.. here is an excerpt from my init.rc file for NAND. From the bootargs, the filesystem is mounted as rw anyway.

# mount mtd partitions
    # Mount /system rw first to give the filesystem a chance to save a checkpoint
    mount yaffs2 mtd@system /system 
    #mount yaffs2 mtd@system /system ro remount

    # We chown/chmod /data again so because mount is run as root + defaults
    mount yaffs2 mtd@userdata /data nosuid nodev
    chown system system /data
    chmod 0771 /data

    # Same reason as /data above
    mount yaffs2 mtd@cache /cache nosuid nodev
    chown system cache /cache
    chmod 0770 /cache

    # This may have been created by the recovery system with odd permissions
    chown system system /cache/recovery
    chmod 0770 /cache/recovery

 best regards,

Elvis

supermaximus79

unread,
Mar 25, 2010, 9:01:41 AM3/25/10
to android-porting
I can post patch for u-boot to support yaffs2 write, but i don't know
how to attach files to messages here. Is it possible?

On Mar 25, 2:57 pm, Elvis Dowson <elvis.dow...@gmail.com> wrote:
> Hi Deva,
>

Максим Андрущенко

unread,
Mar 25, 2010, 9:05:05 AM3/25/10
to Ashwin Bihari, android-porting
Patch for u-boot 2009.03 in attachment.

Good luck!

Thu, 25 Mar 2010 08:55:55 -0400 О©╫О©╫О©╫О©╫О©╫О©╫ О©╫О©╫ Ashwin Bihari <abi...@gmail.com>:

1.diff

Elvis Dowson

unread,
Mar 25, 2010, 11:04:51 AM3/25/10
to Deva R, android-porting
Hi,
      I tried making the changes to make the /system rw and changed the permissions. 

Here are the modifications that I made to init.rc

# mount mtd partitions
    # Mount /system rw first to give the filesystem a chance to save a checkpoint
    mount yaffs2 mtd@system /system 
    mount yaffs2 mtd@system /system rw remount
    chmod 0771 /system

    # We chown/chmod /data again so because mount is run as root + defaults
    mount yaffs2 mtd@userdata /data nosuid nodev
    chown system system /data
    chmod 0771 /data

    # Same reason as /data above
    mount yaffs2 mtd@cache /cache nosuid nodev
    chown system cache /cache
    chmod 0770 /cache

    # This may have been created by the recovery system with odd permissions
    chown system system /cache/recovery
    chmod 0770 /cache/recovery

Here are the error messages.

yaffs: dev is 32505860 name is "mtdblock4"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.4, "mtdblock4"
yaffs: restored from checkpoint
yaffs_read_super: isCheckpointed 1
VFS: Mounted root (yaffs2 filesystem) on device 31:4.
Freeing init memory: 944K
mmc1: mmc_rescan - card ocr from io_op=0x00000000, err = -110
init: cannot open '/initlogo.rle'
save exit: isCheckpointed 1
yaffs: dev is 32505861 name is "mtdblock5"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.5, "mtdblock5"
yaffs_read_super: isCheckpointed 0
yaffs: dev is 32505862 name is "mtdblock6"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.6, "mtdblock6"
block 94 is bad
block 206 is bad
yaffs_read_super: isCheckpointed 0
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/app_process', disabling 'zygote'
init: cannot find '/system/bin/mediaserver', disabling 'media'
init: cannot find '/system/bin/installd', disabling 'installd'
/system/bin/sh: can't access tty; job control turned off


Best regards,

Elvis

Elvis Dowson

unread,
Mar 25, 2010, 11:29:07 AM3/25/10
to Deva R, android-porting
Hi,
       
If I do a ls -l  on the root / folder, I get the following permissions

drwxrwx--x  1 1000 1000   2048 Jan  1 00:00 data
drwxrwx--x  1 1000 1000   2048 Jan  1 00:00 system

I can't see the group system defined, I just get a 1000 group id as above. What should I do ?

My init.rc file looks like this at the moment

    # Mount /system rw first to give the filesystem a chance to save a checkpoint
    mount yaffs2 mtd@system /system 
    mount yaffs2 mtd@system /system ro remount
    chown system system /system
    chmod 0771 /system

    # We chown/chmod /data again so because mount is run as root + defaults
    mount yaffs2 mtd@userdata /data nosuid nodev
    chown system system /data
    chmod 0771 /data

    # Same reason as /data above
    mount yaffs2 mtd@cache /cache nosuid nodev
    chown system cache /cache
    chmod 0770 /cache

    # This may have been created by the recovery system with odd permissions
    chown system system /cache/recovery
    chmod 0770 /cache/recovery

best regards,

Elvis

Elvis Dowson

unread,
Mar 25, 2010, 12:06:21 PM3/25/10
to Deva R, android-porting
Hi,
          I've found something. When I prepare my rootfs image, initially in /bin I have a few files like zcat.zip for example. 

Now, in that same rootfs, I have a /system/bin folder which contains the android servicemanager, vold executables, etc. 

Upon booting from NAND, the /system/bin folder is pointing to the /bin folder, rather than the /system/bin folder, which is why /init cannot find the android binaries.

How can I fix this? 

My u-boot command args are as follows: 

setenv nandargs setenv bootargs console=${console} vram=${vram} omapfb.vram=0:8M omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} root=/dev/mtdblock4 rw rootfstype=yaffs2 rootwait init=/init

the init file is under / root. 

best regards,

Elvis

Elvis Dowson

unread,
Mar 25, 2010, 12:45:53 PM3/25/10
to Deva R, android-porting
Hi,

On Mar 25, 2010, at 8:26 PM, Elvis Dowson wrote:

I was wondering if I perhaps change the init.rc file to 

    mount yaffs2 mtd@system / 
    mount yaffs2 mtd@system / ro remount
    chown system system /system
    chmod 0771 /system

Making those changes allowed me to boot, but Im'm getting the 

D/dalvikvm(  882): DexOpt: incorrect opt magic number (0xff ff ff ff) 

error again. 

Best regards,

Elvis

# init: untracked pid 870 exited
init: untracked pid 869 exited
init: untracked pid 874 exited
init: untracked pid 879 exited
logcat
I/vold    (  867): Android Volume Daemon version 2.0
I/DEBUG   (  868): debuggerd: Feb 26 2010 13:00:28
E/vold    (  867): Unable to chdir to /sys/class/mmc_host/mmc0/slot_name (m)
E/vold    (  867): Error bootstrapping card '/sys/class/mmc_host/mmc0/slot_name' (m)
E/vold    (  867): Unable to chdir to /sys/class/mmc_host/mmc1/slot_name (m)
E/vold    (  867): Error bootstrapping card '/sys/class/mmc_host/mmc1/slot_name' (m)
D/vold    (  867): Bootstrapping complete
D/AndroidRuntime(  874): 
D/AndroidRuntime(  874): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime(  874): CheckJNI is ON
D/dalvikvm(  874): DexOpt: --- BEGIN 'core.jar' (bootstrap=1) ---
D/dalvikvm(  879): Ignoring duplicate verify attempt on Ljava/lang/Object;
D/dalvikvm(  879): Ignoring duplicate verify attempt on Ljava/lang/Class;
D/AndroidRuntime(  882): 
D/AndroidRuntime(  882): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime(  882): CheckJNI is ON
D/dalvikvm(  882): DexOpt: incorrect opt magic number (0xff ff ff ff)
D/dalvikvm(  882): Stale deps in cache file; removing and retrying
D/dalvikvm(  882): DexOpt: --- BEGIN 'core.jar' (bootstrap=1) ---
D/dalvikvm(  888): Ignoring duplicate verify attempt on Ljava/lang/Object;
D/dalvikvm(  888): Ignoring duplicate verify attempt on Ljava/lang/Class;
D/dalvikvm(  888): DexOpt: load 253ms, verify 2565ms, opt 139ms
init: untracked pid 891 exited
init: untracked pid 882 exited
D/AndroidRuntime(  893): 
D/AndroidRuntime(  893): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime(  893): CheckJNI is ON
D/dalvikvm(  893): DexOpt: sleeping on flock(/data/dalvik-cache/system@framework@core...@classes.dex)
D/dalvikvm(  893): DexOpt: incorrect opt magic number (0xff ff ff ff)
D/dalvikvm(  893): Stale deps in cache file; removing and retrying
init: untracked pid 888 exited
D/dalvikvm(  893): DexOpt: --- BEGIN 'core.jar' (bootstrap=1) ---
D/dalvikvm(  897): Ignoring duplicate verify attempt on Ljava/lang/Object;
D/dalvikvm(  897): Ignoring duplicate verify attempt on Ljava/lang/Class;
D/dalvikvm(  897): DexOpt: load 229ms, verify 2492ms, opt 119ms
init: untracked pid 893 exited
init: untracked pid 900 exited
D/AndroidRuntime(  901): 
D/AndroidRuntime(  901): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime(  901): CheckJNI is ON
D/dalvikvm(  901): DexOpt: sleeping on flock(/data/dalvik-cache/system@framework@core...@classes.dex)
D/dalvikvm(  901): DexOpt: incorrect opt magic number (0xff ff ff ff)
D/dalvikvm(  901): Stale deps in cache file; removing and retrying
init: untracked pid 897 exited
D/dalvikvm(  901): DexOpt: --- BEGIN 'core.jar' (bootstrap=1) ---
D/dalvikvm(  906): Ignoring duplicate verify attempt on Ljava/lang/Object;
D/dalvikvm(  906): Ignoring duplicate verify attempt on Ljava/lang/Class;
init: critical process 'servicemanager' exited 4 times in 4 minutes; rebooting into recovery mode
save exit: isCheckpointed 1
save exit: isCheckpointed 1
D/dalvikvm(  906): DexOpt: load 230ms, verify 2956ms, opt 291ms
Restarting system with command 'recovery'.


Reply all
Reply to author
Forward
0 new messages