NAND Flash

From ThinCan

Jump to: navigation, search

This page describes the GeodeLX CS5536 NAND Flash storage media and how to use it, as found in ThinCan DBE61 and DBE62

Contents

Booting from NAND Flash

The NAND Flash in a ThinCan DBE61 and DBE62 can contain either embedded Linux or WinCE as an operating system. The primary way of booting them is via the FILO bootloader, as it contains a GeodeLX CS5536 chipset flash driver contributed by Artec. The suggested boot method is through the ArtecBoot loader found in FILO, because it enables multiboot through a custom header at the start of the NAND Flash, therefore changing of default kernel parameters, kernel and/or initrd size, and other similar options does not require re-flashing the BIOS NOR chip, but only the NAND Flash. Alternative methods include using a Linux loader or Windows CE loader directly. These are all found in FILO's configuration Loader menu.

Booting with SeaBIOS is currently not possible, because there is currently no CS5536 NAND Flash OptionROM that could be used with SeaBIOS for flash storage access and booting.

Using the NAND Flash

The CS5536 NAND Flash can be used as a small storage media through raw NAND Flash access operating system drivers. Because it is a flash device with limited block erase cycles, it is highly suggested to primarily use it as a read-only media.

Linux

NAND support for CS5536 exists in Linux kernel since version 2.6.18. The necessary kernel configuration options for enabling it are CONFIG_MTD, CONFIG_MTD_NAND and CONFIG_MTD_NAND_CS553X.

Partitioning

To better support updating only parts of the system on NAND Flash, such as only updating the kernel without overwriting the root filesystem, or having only small portions of the system mounted read-write, the Linux kernel Memory Technology Device (MTD) subsystem supports partitioning. Separate MTD partitions will show up as separate MTD devices and thus can be used to address only predetermined sized ranges of the whole NAND Flash. MTD partitioning for CS5536 NAND Flash is available since kernel version 2.6.25 in the form of kernel command line partitioning. The necessary kernel configuration options are CONFIG_MTD_PARTITIONS and CONFIG_MTD_CMDLINE_PARTS. To set up partitions, a special kernel command line parameter mtdparts is used, as described in the kernel help for CONFIG_MTD_CMDLINE_PARTS. The mtd-id for the NAND Flash on a ThinCan DBE61 and DBE62 is cs553x_nand_cs1. So a kernel command line parameter for partitioning a 2MB kernel space, 60MB read-only rootfs area and a 2MB configuration partition as an example could be:

mtdparts=cs553x_nand_cs1:2m@0m(kernel),60m@2m(rootfs),2m@62m(conf)

This last command can be inserted through lilo, but this would result updating bios everytime you want to change partition size. Other possibility could be compiling the command into kernel with CONFIG_CMDLINE="mtdparts=...".

After you have set up your partititions you have to clean them with mtd-utils. In addition if you want to access any of the partitions via mtdblock device you have to create a filesystem (for example jffs2) on that mtd. This could be achieved so:

flash_eraseall /dev/mtdX -j

Booting from nand with filo via linux loader

In order to boot from NAND, Artec has developed ABoot extension to FILO (now in FILO mainline). This extension reads the kernel image location and command line from first block of NAND flash and starts it. This way, the user does not need to re-build FILO and re-flash BIOS to change kernel command line or other parameters. The user can just erase the NAND flash and program the new kernel and root FS to flash. The following example shows how to program such configuration to NAND flash:

echo ">>> Installing BIOS"
flashrom -m dbe61 -w bios.bin
echo ">>> Installing ArtecBoot header and kernel"
imagewrite -l -c cmdline.txt /dev/mtd0 kernel.bin
echo ">>> Installing JFFS2 root file system"
## Skip to the beginning of rootfs partition (kernel partition size)
nandwrite -s 2097152 /dev/mtd0 rootfs.bin

Note: As the NAND partitioning must be set up from the kernel command line and it is not very flexible to be changed, create mtd0 partition as the whole flash and then mtd1+ partitions to required areas. This way, different root FS images can be written, just by skipping a known amount of bytes at the beginning of /dev/mtd0.

See Also