How To Boot from the Hard Drive on the Freescale MPC8572DS
Table of Contents
NFS-based root file systems are very useful in a development environment. However, once you start to move to a production system, it is no longer a viable option. Instead, you will want your device to boot from some sort of persistent memory, such as a Hard Drive. This document explains how to boot a complete system from the Hard Drive on a Freescale MPC8572DS.
Prerequisites
- Some method of writing to a SATA hard drive (USB enclosure, SATA connector on motherboard
- Kernel uImage with the following configuration options enabled:
- CONFIG_SATA_AHCI=y
- CONFIG_EXT3_FS=y
- Factory workorder with the following options enabled:
- CONFIG_TSWO_RFS_FS_tar=y
- CONFIG_TSWO_INSTALL_KERNEL_TO_TARGET=y
Building RFS Images
Run make on your Factory workorder with the above options selected. This will create a tarball containing your root file system. The kernel will be in the RFS, as well, in the directory /boot/. This tarball can be found at build*/images/rfs/rootfs.tar.gz.
You can also download the file rootfs.tar.gz from the Output page of a web Factory build.
Writing the RFS to the hard drive
The recommended way to write the RFS to the hard drive is to mount the drive on a Linux system and extract the tarball into the root of a partition. This can be done by using an external hard drive enclosure, a connection to a free SATA connector on your host machine's motherboard, or even an nfs-mounted RFS on the target platform.
- Connect the hard drive to a machine
- Partition the drive (if it hasn't already been done). For help with partitioning a hard drive in Linux, please see Partitioning with FDISK. You will need a Linux partition on the disk large enough to hold your root filesystem. For the remainder of this document, we are assuming that you are using the first partition, or sd*1.
- Format the disk with the filesystem of your choice. By default, the kernels that Timesys distributes typically have ext2 and ext3 support enabled. For ext3, use the mkfs.ext3 utility (part of e2fsprogs). Assuming that your hard drive partition is /dev/sdb1:
mkfs.ext3 /dev/sdb1
- Make a mount point for the hard drive on your host system.
mkdir /mnt/sdb1
- Mount the hard drive
mount /dev/sdb1 /mnt/sdb1
- Go to the hard drive's mount point
cd /mnt/sdb1
- Extract the rootfs tarball (as root!) into this directory.
sudo tar xzf ~/Desktop/rootfs.tar.gz
- Unmount the hard drive and connect it to the SATA connector on your MPC8572DS.
umount /dev/sdb1
Boot procedure
In order to boot from the hard drive, you must load the kernel and device tree blob from the hard drive into memory, and then tell the kernel where to look for the RFS, and how to load it. This is done using the following U-Boot commands:
- Copy the kernel into RAM using the ext2ls command:
=> ext2load scsi 0:1 1000000 /boot/uImage
This command will the file /boot/uImage from scsi device 0, partition 1 (sda1) and move it to address 0x1000000 in RAM. - Copy the device tree blob into RAM using the ext2ls command:
=> ext2load scsi 0:1 C00000 /boot/mpc8572ds.dtb
This command will the file /boot/mpc8572ds.dtb from scsi device 0, partition 1 (sda1) and move it to address 0xC00000 in RAM. - Set the kernel command line to boot from your hard drive:
=> setenv bootargs root=/dev/sda1 rw
- Boot the kernel using the bootm command.
=> bootm 1000000 - C00000
NOTE: You can set the bootcmd environment variable to perform these steps automatically:
=> setenv bootcmd setenv bootargs root=/dev/sda1 rw\; ext2load scsi 0:1 1000000 /boot/uImage\; ext2load scsi 0:1 C00000 /boot/mpc8572ds.dtb\; bootm 1000000 - C00000