https://support.bluetechnix.at/wiki/NAND_flash_(SBC-i.MX51)
NAND flash (SBC-i.MX51)
From BlueWiki
The SBC provides 2 GiB of NAND flash.
Contents[hide ] |
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 |
There are 2 ways to customize this layout:
- Edit the Linux source code
- Open the file btmxc-linux/arch/arm/mach-mx51
- 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,
},
};
- Supply a boot argument to the kernel
- TODO
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
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)
TODO link to page