File:  [NetBSD Developer Wiki] / wikisrc / tutorials / using_the_nand_emulator_and_chfs.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Sat Oct 13 23:46:00 2012 UTC (18 months ago) by riz
Branches: MAIN
CVS tags: HEAD
Basics of how to use the NAND emulator and create a CHFS on it.

Emulating a NAND flash device
-----------------------------

A quick rundown on how to get started using the NAND flash emulator
in the NetBSD kernel:

First, build a kernel with:

	pseudo-device nandemulator
	flash* at flashbus?
	nand* at nandbus?

I created a new kernel config called "NAND" (on amd64):

	include "arch/amd64/conf/GENERIC"
	pseudo-device nandemulator
	flash* at flashbus?
	nand* at nandbus?

Note that at the present time, all the parameters of the NAND emulator are
hardcoded, so to change anything you'll need to edit
sys/dev/nand/nandemulator.c .

Build and install the kernel, and boot from it.  You'll notice the following
items appear:

	nandemulator0: NAND emulator
	nand0 at nandemulator0: ONFI NAND Flash
	nand0: vendor: NETBSD, model: NANDEMULATOR
	nand0: page size: 2048 bytes, spare size: 64 bytes, block size: 131072 bytes
	nand0: LUN size: 256 blocks, LUNs: 1, total storage size: 32 MB
	flash0 at nand0: NAND flash partition size 32 MB, offset 0
	flash0: erase size 128 KB, page size 2048 bytes, write size 2048 bytes

You can then mount a chfs file system on the emulated flash device.  The
file system is created on the first mount:

	# mount_chfs /dev/flash0 /mnt
	# ls -l /mnt
	# cp /netbsd /mnt
	# ls -l /mnt
	total 29216
	-rwxr-xr-x  1 root  wheel  14958233 Oct 13 16:29 netbsd
	# umount /mnt
	# mount_chfs /dev/flash0 /mnt
	# ls -l /mnt   
	total 29216
	-rwxr-xr-x  1 root  wheel  14958233 Oct 13 16:29 netbsd
	# ls -l /mnt
	total 29216
	-rwxr-xr-x  1 root  wheel  14958233 Oct 13 16:29 netbsd
	# md5 /mnt/netbsd /netbsd
	MD5 (/mnt/netbsd) = 79184fe311657261e1744d77206716c8
	MD5 (/netbsd) = 79184fe311657261e1744d77206716c8
	# umount /mnt


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb