TS-7670 NAND Backup

From embeddedTS Manuals
Revision as of 18:07, 5 February 2014 by Kris (talk | contribs)

The NAND on this SBC 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 much smaller than mtd2, 16MB. 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.

The two sections below explain how to create/set up kernel and filesystem images for NAND as well as how to flash these images to the NAND device. Note that even though each process has a different setup, care must be taken to ensure that the modules on the filesystem image are compatible with the kernel image, they must be from the same build. The NAND filesystem image is made from the shipping image of the same date and are in sync. Likewise, the kernel on the SD card image, and the kernel image meant for NAND on the SD card image are the same build and are in sync. Technologic Systems strongly recommends doing all development from an SD card, and then creating NAND images using that SD card.

Kernel

All of Technologic Systems' SD card images contain the file necessary to image the kernel/initramfs to NAND.

When the kernel is built and installed to the SD card from a host PC (see Compile the Kernel), it copies the current bootstream to the SD card at /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 to the initramfs, 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

The stock NAND filesystem image is available from Technologic Systems. This is the same image that is shipped with the SBC itself. When restoring this image to NAND, please use an SD card image of the same date to boot and flash the kernel and filesystem image to NAND. Click to download the latest NAND filesystem image.


It is possible to create a filesystem image from an existing filesystem to create 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

#A folder tree needs to be passed to mkfs.ubifs -r, this tree needs to be a valid filesystem for the TS-7670
#It can be mounted from any source, but here we use an SD card we have been developing on
mount /dev/mmcblk0p2 /mnt/source_fs_root
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.