Root filesystems initflash
From GumstixDocsWiki
This page describes configuring the root file system in flash to load a root file system from a MMC card or CF card. The kernel version in flash must match the kernel version on the MMC/CF card. The root file system in flash is essentially used the way an initrd would be used to load modules necessary to mount the final root file system.
Using the MMC Card as the Root Filesystem
If the on-board flash isn't large enough to accomodate your filesystem, it's possible to place the filesystem on the mmc card and mount that as the new root filesystem after boot. The kernel that is loaded off the MMC card must be the same version as the kernel on your filesystem image.
Pre-built gcc and Python with MMC script and kernel: http://www.gumstix.com/~ken/development_systems/devsys_mmc_r1090.zip
unzip this file onto your MMC card.
Your mmc card should have three files: gumstix-factory.script, uImage, and rootfs.img
The mmc card is now ready to go. Skip to Step 4.
If you want to make your own root filesystem image, Start at Step 1
- Step 1: create the buildroot
build your filesystem using Buildroot with all modules you need.
Enable ext2 in this buildroot's kernel:
cd <gumstix-buildroot> cd build_arm_nofpu cd linux-<the version of linux you're using> make ARCH=arm CROSS_COMPILE=`pwd`/../staging_dir/bin/arm-linux- menuconfig
Once in the kernel config menu, under file systems, select 'Second Extended FS. Now make the kernel:
make ARCH=arm CROSS_COMPILE=`pwd`/../staging_dir/bin/arm-linux-
Rebuild the buildroot:
cd <gumstix-builtroot> make
Create the file build_arm_nofpu/root/root/setup_ramfs.sh with this content:
#!/bin/sh # ramfs for proc, sys /bin/mount -t ramfs proc-ramfs /proc /bin/mount -t proc /proc /proc /bin/mount -t ramfs sys-ramfs /sys /bin/mount -t sysfs /sys /sys # ramfs for dev /bin/mount -t ramfs ramfs /mnt/tmp /bin/cp -a /mnt/oldroot/dev/* /mnt/tmp /bin/mount -o bind /mnt/tmp /dev /bin/umount /mnt/tmp # devpts /bin/mount -n -t devpts devpts /dev/pts -ogid=5,mode=620 /bin/umount /mnt/oldroot/dev/pts
make it executable:
chmod +x build_arm_nofpu/root/root/setup_ramfs.sh
lastly, create directories in build_arm_nofpu/root/mnt
mkdir oldroot mkdir tmp
- Step 2: create a filesystem image from the buildroot
make build_arm_nofpu your working directory
cd build_arm_nofpu
create a place to mount the filesystem
mkdir tmp/fsimage
create a blank filesystem image
mkdir images dd if=/dev/zero of=images/rootfs.img bs=1k count=65536
create a filesystem on the image
/sbin/mke2fs -F -v -m0 images/rootfs.img
mount the image
mount -o loop images/rootfs.img tmp/fsimage
copy the root filesystem to the image
cp -av root/* tmp/fsimage
done, unmount the image
umount tmp/fsimage
- Step 3: Download the MMC script
gumstix-factory.script that loads a kernel with ext2 enabled so we can mount the file system image from step 2.
echo "Booting Development System..."
set workedok Failed
if mmcinit; then
if fatload mmc 0 a2000000 uImage; then
set workedok Success
fi
fi
bootm a2000000
[MMC version of gumstix-factory.script]
Copy mmc_kernel_gumstix-factory.script to your MMC card. Rename it gumstix-factory.script.
Copy build_arm_nofpu/root/boot/uImage to your MMC card.
Copy rootfs.img from Step 2 to your MMC card.
The mmc card is now ready to go. We'll now set up the gumstix.
- Step 4: Modify Files on the gumstix
The root filesystem on the gumstix must use the same kernel version that you load from MMC
Make these changes to the root filesystem in flash:
rm /etc/motd
edit /etc/network/interfaces and remove or comment out these lines:
auto usb auto eth0 auto mwlan0
edit /etc/modules to look like this:
loop # MMC support -- uncomment the next two lines to enable MMC if not using CF mmc_block pxamci # Compact Flash support -- comment next line to disable CF if using MMC #pcmcia
Create a file named mount_mmc_filesystem.sh with this content:
#!/bin/sh mount /mnt/mmc mount -t ext2 -o loop -o ro /mnt/mmc/rootfs.img /rfs mount -t ramfs ramfs /rfs/mnt/oldroot wait cd /rfs /sbin/pivot_root . /rfs/mnt/oldroot cd /root /root/setup_ramfs.sh echo "Root filesystem on MMC card has been loaded. System is ready."
execute the following commands:
chmod +x mount_mmc_filesystem.sh mkdir /rfs
to load the MMC card's filesystem and use it as the new filesystem:
. ./mount_mmc_filesystem.sh
Using the CompactFlash Card as the Root Filesystem
This is the same as the MMC Card configuration with a different gumstix-factory.script and a new U-Boot bootcmd. There are configuration changes to support CF instead of MMC.
Loading images from CompactFlash requires the U-Boot pinit command. This was added in U-Boot 1.1.4-r1066.
- Step 0: Change U-Boot's bootcmd
CF requires a different U-Boot bootcmd environment variable.
The bootcmd shown in this step is the default bootcmd in U-Boot 1.1.4-r1161
Change the bootcmd from U-Boot:
GUM> setenv bootcmd 'icache on\; setenv stderr nulldev\; setenv stdout nulldev\; if pinit on && fatload ide 0 a2000000 gumstix-factory.script\; then setenv stdout serial\; setenv stderr serial\; echo Found gumstix-factory.script...\; autoscr\; else if mmcinit && fatload mmc 0 a2000000 gumstix-factory.script\; then setenv stdout serial\; setenv stderr serial\; echo Found gumstix-factory.script...\; autoscr\; else setenv stdout serial\; setenv stderr serial\; fsload && bootm\; fi\; fi'
This bootcmd needs to be entered as one line.
If the root filesystem on your gumstix was compiled with the 1.1.4 version of U-Boot, then you can change U-Boot's bootcmd from Linux. Check the version compatibility first by running fw_printenv.
To change the bootcmd from Linux:
# fw_setenv bootcmd 'icache on; setenv stderr nulldev; setenv stdout nulldev; if pinit on && fatload ide 0 a2000000 gumstix-factory.script; then setenv stdout serial; setenv stderr serial; echo Found gumstix-factory.script...; autoscr; else if mmcinit && fatload mmc 0 a2000000 gumstix-factory.script; then setenv stdout serial; setenv stderr serial; echo Found gumstix-factory.script...; autoscr; else setenv stdout serial; setenv stderr serial; fsload && bootm; fi; fi'
This bootcmd needs to be entered as one line. Note that fw_setenv doesn't require ';' to be escaped with a '\'. update_bootcmd.sh
- Step 1: same as MMC
- Step 2: same as MMC
- Step 3: Download the CF script
gumstix-factory.script that loads a kernel with ext2 enabled so we can mount the file system image from step 2.
echo "Booting CF..."
set workedok Failed
if pinit on; then
if fatload ide 0 a2000000 uImage; then
set workedok Success
fi
fi
bootm a2000000
[CF version of gumstix-factory.script]
Copy cf_kernel_gumstix-factory.script to your CF card. Rename it gumstix-factory.script.
Copy build_arm_nofpu/root/boot/uImage to your CF card.
Copy rootfs.img from Step 2 to your CF card.
The CF card is now ready to go. We'll now set up the gumstix.
- Step 4: Modify Files on the gumstix
The root filesystem on the gumstix must use the same kernel version that you load from CF
Make these changes to the root filesystem in flash:
rm /etc/motd
edit /etc/network/interfaces and remove or comment out these lines:
auto usb auto eth0 auto mwlan0
edit /etc/modules to look like this:
loop ide-disk # MMC support -- uncomment the next two lines to enable MMC if not using CF #mmc_block #pxamci # Compact Flash support -- comment next line to disable CF if using MMC pcmcia
Create a file named mount_cf_filesystem.sh with this content:
#!/bin/sh mount -t vfat /dev/hda1 /mnt/cf mount -t ext2 -o loop -o ro /mnt/cf/rootfs.img /rfs mount -t ramfs ramfs /rfs/mnt/oldroot wait cd /rfs /sbin/pivot_root . /rfs/mnt/oldroot cd /root /root/setup_ramfs.sh echo "Root filesystem on CF card has been loaded. System is ready."
execute the following commands:
chmod +x mount_cf_filesystem.sh mkdir /rfs
to load the CF card's filesystem and use it as the new filesystem:
. ./mount_cf_filesystem.sh

