NetBSD Wiki/tutorials/
using the nand emulator and chfs
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
and substitute the values you want.
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
Note: because this is using kernel memory and not real flash, nothing will be persistent across reboots!
Add a comment