NAND flash (SBC-i.MX51)

From BlueWiki

Jump to: navigation, search

The SBC-i.MX51 provides 2 GiB of NAND flash.

Contents

1 Linux kernel configuration

System Type  --->
  Freescale MXC Implementations  --->
    MX51 Options  --->
      [*] MXC NFC Hardware Version 3
      [*]   MXC NFC Hardware Version 3.2
Device Drivers  --->
  <*> Memory Technology Device (MTD) support  --->
    [*]   MTD partitioning support
    [*]     Command line partition table parsing
    <*>   Direct char device access to MTD devices
    -*-   Common interface to block layer for MTD 'translation layers'
    <*>   Caching block device access to MTD devices
    <*>   NAND Device Support  --->
      <*>   MXC NAND Version 3 support

2 Setting partitions on NAND flash

The default partitions on the NAND flash are as follows:

Name Size Offset
bootloader 0x300000 (3 MiB) 0x0
nand.kernel 0x500000 (5 MiB) 0x300000
nand.rootfs 0x40000000 (1 GiB) 0x800000
nand.userfs1 0x3E800000 (1000 MiB) 0x40800000

To customize this layout, follow the instructions below.

  • Open the file
btmxc-linux/arch/arm/mach-mx5/mx51_3stack.c

(Linux 2.6.31) or

btmxc-linux/arch/arm/mach-mx51/mx51_i.fly.c

(Linux 2.6.28) respectively.

  • Search for the following struct and edit it according to your wishes.
    NOTE: Leave at least 2 MiB (0x200000) bytes unassigned at the end of the flash. This is the location where the bad block table (BBT) and its copy are usually stored by Linux and Redboot.
static struct mtd_partition nand_flash_partitions[] = {
	{
		.name = "bootloader",
		.offset = 0,
		.size = 3 * 1024 * 1024,
	},
	{
		.name = "nand.kernel",
		.offset = MTDPART_OFS_APPEND,
		.size = 5 * 1024 * 1024,
	},
	{
		.name = "nand.rootfs",
		.offset = MTDPART_OFS_APPEND,
		.size = 1024 * 1024 * 1024,
	},
	{
		.name = "nand.userfs1",
		.offset = MTDPART_OFS_APPEND,
		.size = 1000 * 1024 * 1024,
	},
};

3 Test in Linux

We will copy some test file to the 4th partition (nand.userfs1).

  • Use some test file (e.g. 32 MiB large) and copy it to the SBC. "/randomfile" is assumed from now on.
  • Have a look at the available partitions:
cat /proc/mtd
cat /proc/partitions
  • Create a jffs2 file system by deleting the contents and simply mounting it:
mkdir /mnt/nanduserfs
flash_eraseall /dev/mtd3
mount -t jffs2 /dev/mtdblock3 /mnt/nanduserfs
  • Copy the file to this partition 10 times:
for i in `seq 1 10` ; do cp /randomfile /mnt/nanduserfs/file${i} ; done
  • Check files:
for i in `seq 1 10` ; do diff /randomfile /mnt/nanduserfs/file${i} ; done

Diff must not output anything, which means the files are all identical.

4 Boot from NAND flash (default)

The NAND boot mode and the NAND setup procedure are described on the Boot media page.

Personal tools