[Yaffs] nandsim and device target system image mounting?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: TJ
Date:  
To: yaffs
Subject: [Yaffs] nandsim and device target system image mounting?
I've recently found the need to mount, on a Linux workstation, an
Android device's back-up 237MB 'system.img' which is a YAFFS image. For
obscure reasons 'unyaffs' won't achieve my objective here.

The problem I'm having is one described in other emails to this list -
namely that after writing the device image the only thing visible is the
"lost+found" directory. I've tried creating both YAFFS 1 and 2 images
from a directory and mounting them the same way but get the same result,
so I'm suspecting I'm missing something fundamental and probably
obvious.

>From various yaffs trace output in the kernel log (echo all | sudo tee

/proc/yaffs) I believe the image is YAFFS 1 although once mounted YAFFS
reports it as version 2 due to the nandsim device page size:

[37421.406721] yaffs: dev is 32505856 name is "mtdblock0" rw
[37421.406727] yaffs: passed flags ""

[37421.406732] yaffs: yaffs_read_super: Using yaffs1

[37421.406736] yaffs: yaffs_read_super: block size 4096
[37421.406742] yaffs: yaffs: Attempting MTD mount of 31.0,"mtdblock0"
[37421.406747] yaffs: erase f8804440
[37421.406751] yaffs: read f8804c70
[37421.406754] yaffs: write f8804140
[37421.406758] yaffs: readoob f8804ad0
[37421.406761] yaffs: writeoob f88042c0
[37421.406765] yaffs: block_isbad f8804750
[37421.406768] yaffs: block_markbad f88047a0
[37421.406772] yaffs: writesize 2048
[37421.406776] yaffs: oobsize 64
[37421.406779] yaffs: erasesize 131072
[37421.406783] yaffs: size 536870912

[37421.406787] yaffs: auto selecting yaffs2

[37421.406793] yaffs: yaffs locking d3eb71a0
[37421.406797] yaffs: yaffs locked d3eb71a0
[37421.406800] yaffs: yaffs: yaffs_guts_initialise()
[37421.406851] yaffs: restore entry: is_checkpointed 0
[37421.406857] yaffs: read checkpoint validity
[37421.406862] yaffs: find next checkpt block: start: blocks 0 next 1
...

"yaffs" is selected due to:

if (yaffs_auto_select && yaffs_version == 1 && WRITE_SIZE(mtd) >= 2048)
{
yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting yaffs2");
yaffs_version = 2;
}

I'm using an Ubuntu Lucid host with kernel v2.3.68 and building
yaffs2multi from git.

cat /proc/version
Linux version 2.6.38-8-generic (buildd@muntries) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #42~lucid1-Ubuntu SMP Mon Apr 11 13:47:25 UTC 2011

git log -1 --pretty=format:"%h %cd %s"
912be3d Thu May 19 13:24:32 2011 +1200 yaffs: Add utils header file

I'm using nandsim with device ID bytes taken from the device the
'system.img' is targeted for, as well as using a file as the
backing-store.

[32727.595846] NAND device: Manufacturer ID: 0xec, Chip ID: 0xbc (Samsung
NAND 512MiB 1,8V 16-bit)

I originally tried using settings found in 'linux-test/initnandsim' for
a device large enough to accommodate the image (first_id_byte=0x20
second_id_byte=0x71) but switched to the real device-parameters after
reading an earlier suggestion to match image and device page sizes and
so
on.

[74950.474942] NAND device: Manufacturer ID: 0x20, Chip ID: 0xaa (ST Micro
NAND 256MiB 1,8V 8-bit)

cat /etc/modprobe.d/nandsim.conf
options nandsim first_id_byte=0xec second_id_byte=0xbc third_id_byte=0x00
fourth_id_byte=0x55 cache_file=/tmp/nandsim.bin

cat /proc/mtd
dev:    size   erasesize  name
mtd0: 20000000 00020000 "NAND simulator partition 0"


The method I use is:

sudo modprobe mtdblock
sudo modprobe nandsim
sudo modprobe yaffs2multi

sudo flash_erase /dev/mtd0 0 4096
sudo nandwrite -a /dev/mtd0 system.img
sudo mount -t yaffs /dev/mtdblock0 mnt/system

ls -l /tmp/nandsim.bin
-rw------- 1 root root 553648128 2011-06-11 22:34 /tmp/nandsim.bin

ls mnt/system
lost+found

cat /proc/yaffs
Multi-version YAFFS built:Jun 11 2011 21:47:14

Device 0 "NAND simulator partition 0"
start_block.......... 0
end_block............ 4095
total_bytes_per_chunk 2048
use_nand_ecc......... 1
no_tags_ecc.......... 0
is_yaffs2............ 1
inband_tags.......... 0
empty_lost_n_found... 1
disable_lazy_load.... 0
refresh_period....... 500
n_caches............. 10
n_reserved_blocks.... 5
always_check_erased.. 0

data_bytes_per_chunk. 2048
chunk_grp_bits....... 0
chunk_grp_size....... 1
n_erased_blocks...... 3896
blocks_in_checkpt.... 0

n_tnodes............. 1
n_obj................ 5
n_free_chunks........ 249408

n_page_writes........ 0
n_page_reads......... 1
n_erasures........... 1
n_gc_copies.......... 0
all_gcs.............. 1
passive_gc_count..... 1
oldest_dirty_gc_count 0
n_gc_blocks.......... 0
bg_gcs............... 0
n_retired_writes..... 0
n_retired_blocks..... 0
n_ecc_fixed.......... 0
n_ecc_unfixed........ 0
n_tags_ecc_fixed..... 0
n_tags_ecc_unfixed... 0
cache_hits........... 0
n_deleted_files...... 1
n_unlinked_files..... 1
refresh_count........ 1
n_bg_deletions....... 0
tags_used............ 101056
summary_used......... 0