Optional Root filesystem build and use instructions =================================================== A Introduction This note describes ways to build Linux user-land filesystems of varying complexity for use with the virtualizer. Note that there are several ways to create filesystems and this note doesn't cover all possibilities. The default virtualizer release contains an empty filesystem stub located at "bootwrapper/payload/fsimg" A build using this stub doesn't contain a functional filesytem that the Linux kernel image can use. fsimg can be replaced with a suitable initramfs root filesystem image but with the following constraints: 1. Compressed or uncompressed cpio archives are supported. 2. The image size is limited to ~200 MB. In the default virtualizer build setup, the filesystem image size is limited to 32 MB. In section B. we illustrate a method to create a compressed cpio archive filesystem image that can be used by replacing "bootwrapper/payload/fsimg" file. We will also illustrate what parts of the Virtualizer software need modification to use a cpio archive of size > 32 MB as the root filesystem. The size restriction mentioned in A.2 implies that only very 'lean' filesystems such as busybox may be used. While busybox presents a minimal but robust command line environment, quite often a more conventional desktop like environment with window management on top of an X server is required in order to run web browsers etc. In section C. we illustrate a method to use a larger (~2GB) filesystem image that can be used with the ARM FastModels MMC emulation. Note that the MMC emulations only supports images that are just under 2GB in size. Note that if the MMC route is used, the "bootwrapper/payload/fsimg" filesystem image needs to be replaced by an empty file. This is to prevent Linux from using the cpio archive based initramfs as the root filesystem before it can detect the MMC based root filesystem. B Building and using a cpio archive as a initramfs root filesystem The following steps assume that a pre-built root filesystem is already available in a compressed form in the file rootfs.tar.gz. 1. Uncompress the filesystem: sudo tar -zxf rootfs.tar.gz 2. Ensure that the filesystem contains '/init'. It is used by Linux as the default init process when an initramfs filesystem is used. It can be the actual file or a symlink to another 'init' binary. Alternatively, use the 'rdinit=' e.g. 'rdinit=/sbin/init' to specify which init binary should be used by Linux in the absence of '/init'. The kernel command line can be edited in 'bootwrapper/Makefile'. The BOOTARGS variable points to the kernel command line string. 3. Create a compressed cpio archive from the uncompressed filesystem: pushd binary/boot/filesystem.dir sudo sh -c 'find . | cpio --quiet -H newc -o | gzip -3 -n > ../../../rootfs.cpio.gz' popd 4. Copy the compressed cpio archive to "bootwrapper/payload/fsimg" 5. If the size of the resulting cpio archive is > 32 MB then follow the steps mentioned below. The following diagram illustrates how the payload software (Linux in this case), initramfs filesystem & Virtualizer images are placed relative to each other in physical memory. Base of memory @ $(LOBASE)00000 -> ---------------------- | | | | Linux Kernel start @ 0x80008000 -> |--------------------| | | | | | | | | | | | | Filesystem start @ 0x8df00000 -> |--------------------| | | | | | | Virtualizer start @ $(HIBASE)00000 -> |--------------------| | | | | |--------------------| a. Increase the size of the FILESYSTEM region in the scatter file template bootwrapper/boot.map.template to be not less than the size of the cpio archive created in step 3. It is set to 32MB (0x2000000) by default. b. The variable HIBASE contains the value of the MB where the Virtualizer software (bootwrapper/img.axf) is loaded. Increase its value to prevent any overlap between the memory spaces used by the filesystem and the Virtualizer. An overlap will be flagged as a linker error while building the Virtualizer software. HIBASE can be changed as an environment variable at the time of building the Virtualizer software or in each of the following makefiles: a. "bootwrapper/Makefile" b. "bootwrapper/big-little/Makefile" If following the latter approach please ensure that both the makefiles contain the same value of HIBASE. The default value of $(HIBASE) is 0x8ff. The start address of the root filesystem is contained in the variable FSADDR. The default value of $(FSADDR) = 0x8df00000. The following equation illustrates the relationship between FSADDR and HIBASE mentioned earlier $(FSADDR) + size of FILESYSTEM = $(HIBASE)00000 0x8df00000 + 0x2000000 = 0x8ff00000 c. Increase the kernel parameter value mem=nn[KMG] of the Linux kernel in bootwrapper/Makefile so that Linux is aware that the size of physical memory is enough to include the root filesystem image. The default value is 255M. BOOTARGS=mem=255M ... The following equation should be used as a reference for determining the amount of physical memory made visible to Linux. $(LOBASE)00000 + "size of memory" > $(FSADDR) + size of FILESYSTEM where $(LOBASE) is start of physical memory in the platform in MB. Its default value is 0x800 which corresponds to the start of physical on the FastModels platform at 0x80000000. 7. Build a Linux kernel image for use with the virtualizer by following the steps in "docs/03-Linux-kernel-build.txt". 8. Build the Virtualizer by following the steps in "docs/01-Usage.txt". 9. Launch the ARM FastModel by following the steps in "docs/01-Usage.txt". C Building and using a root filesystem with ARM FastModels MMC emulation 1. Build a Linux kernel image for use with the virtualizer by following the steps in "docs/03-Linux-kernel-build.txt". Please ensure that the kernel is built with MMC support. 2. A suitable root filesystem can be built using the pre-built root filesystem as mentioned under B. a. Create the mmc.dat file. $ dd if=/dev/zero of=mmc.dat bs=1M count=512 b. Add /dev/loop as ./mmc.dat and verify which /dev/loop you got. $ sudo losetup -f ./mmc.dat $ sudo losetup -a c. Create an ext<2,3,4> filesystem on mmc.dat $ mke2fs -F ./mmc.dat d. Create a mountpoint to mount the image on. $ sudo mkdir /mnt/devel $ sudo mount /dev/loop /mnt/devel e. Extract the contents of 'rootfs.tar.gz' into the image $ sudo tar zxvf rootfs.tar.gz --preserve \ --strip-components=3 -C /mnt/devel g. Unmount the image and detach mmc.dat with the loop device $ sudo umount /mnt/devel $ sudo losetup -d /dev/loop 3. Modify the kernel command line to support the MMC image. This is done by indicating the filesystem location to the kernel via the kernel command-line arguments. Append 'root=/dev/mmcblk0' (for a single partition MMC image) to the argument list. To make this modification, edit the file bootwrapper/Makefile and change the BOOTARGS specification from: BOOTARGS=mem=255M console=ttyAMA0,115200 migration_cost=500 cachepolicy=writealloc to BOOTARGS=root=/dev/mmcblk0 mem=255M console=ttyAMA0,115200 migration_cost=500 cachepolicy=writealloc 4. Build the Virtualizer by following the steps in "docs/01-Usage.txt". Please ensure that the 'bootwrapper/payload/fsimg' filesystem image is replaced by an empty file. 5. The ARM FastModel mxscript needs modification to get the FastModel to use the mmc.img file created in step C above with the MMC emulation. To make this change uncomment the 'string mmcimage=' line and provide the complete path to the mmc.img file generated in step 2 above. 6. Launch the ARM FastModel by following the steps in "docs/01-Usage.txt". D Known limitations None.