TS-7670 NAND Backup

From embeddedTS Manuals
Revision as of 16:39, 19 December 2013 by Kris (talk | contribs)

On the TS-7670, the NAND is divided in to three devices, mtd0, mtd1, and mtd2. mtd0 contains the raw bootstream (kernel and initramfs in one binary), mtd1 contains what would normally be the /ts folder on the SD card, and mtd2 contains the linux root filesystem (mtd1 and mtd2 use UBI and UBIFS and can be subdivided down further with mechanisms in UBIFS, see UBI and UBIFS for more information). Since UBI/UBIFS does have a fairly linear mount time for device size, mtd1 is made fairly small, 8MB. This allows for increased startup speed when booting from NAND so that configuration, FPGA softload, or other scripts may be run as soon as possible after power is applied.

Kernel

When the kernel is built and installed to the SD card from a host PC, it copies the current bootstream to the SD card as well. It copies it to /lib/modules/imx28_ivt_linux.sb, the bootstream is a Freescale boot mechanism that contains the bootloader and kernel all in one binary. When booted from an SD card, the bootstream at /lib/modules/imx28_ivt_linux.sb can be flashed to mtd0 with

kernel_from_sd

This will take a few moments and then will return with no messages if everything was successful.

As a part of our USB update mechanism, the bootstream file can be copied to the root of a USB device and then the following command can be used to flash the bootstream to mtd0:

kernel_from_usb

See the section on our USB update mechanism for more information about utilizing this process.

Filesystem

Making a UBIFS Debian image from existing filesystem is the best way to make a custom image for production devices. Technologic Systems strongly recommends to do all development on an SD card and later create a UBIFS image from that Debian filesystem. Copying the large amount of small files Debian has to or from the NAND is very time consuming.

Making the UBIFS image from a host PC. Note that mtd-utils will need to be installed, please see your distribution's documentation for instructions on installation

#/mnt/source_fs_root is the mounted Debian filesystem on an SD; /mnt/usb is a USB drive to store the image for later use
mkfs.ubifs -m4096 -e516096 -c3971 -r /mnt/source_fs_root/ nandimg.ubifs

Note that the UBI rootfs partition on NAND is 1954MiB, Make sure that the UBIFS image is smaller than this. UBI does implement compression on-disk, so the total size of a folder tree may not reflect the actual filesystem size when made in to a UBIFS image. For example, our default SD Debian root filesystem is around 1.2GB, however when made in to a UBIFS image with the above command, it is compressed to roughly 550MB and remains this size on disk.


This image can be used in conjunction with tools in our initramfs. Copy nandimg.ubifs to the root of a formatted USB drive, or to the root linux folder of a pre-imaged SD card. The SD card can either be a freshly imaged SD card, or be one that was used for current development, provided that there is enough space to fit the UBIFS image.

From there, boot from the SD card to the initramfs, when presented a command prompt, run one of the following commands:

filesystem_from_sd


As a part of our USB update mechanism, the nandimg.ubifs can be put on the root partition of a USB device, and then the following command can be used to for flash the nandimg.ubifs to mtd1:

filesystem_from_usb

See the section on our USB update mechanism for more information about utilizing this process.


WARNING: The `filesystem_from_*` commands will completely format any existing data that is on the NAND linux root partition


There are a number of different configurations and setups available when using UBI and UBIFS, see UBI and UBIFS for more information about the capabilities of the subsystem.