We recently had a need for a quick RAM-disk image and went to the tool we've been using for years: Buildroot and took some notes along the way.
With less than 10 minutes of effort, I had a newly built RAM disk image that will work on either i.MX5x or i.MX6x boards, complete with login, and the filesystem utilities I was after. I was about to build
Try doing that, Yocto!
Getting right to the point, the steps I took were these:
Grab the latest snapshot
~/$ wget https://buildroot.org/downloads/buildroot-2012.08.tar.gz
~/$ tar zxvf buildroot-2012.08.tar.gz
Configure for i.MX
~/$ cd buildroot-2012.08
~/buildroot-2012.08$ make menuconfig
Using the kconfig
interface, I chose:
- Target ARM (Little-Endian)
- Target Cortex A-8
- Under toolchain: enable large file support and WCHAR
- Under System Configuration, chose
ttymxc1
as the "Port to run a getty (login prompt) on", - Under Package Selection:Hardware, enabled
dosfstools
ande2fsprogs
- Under Filesystem Images, selected
Output cpio - gzipped
Please read for a nice (and short) guide to usage. In particular, pay attention to this one:
After making those selections, a simple~/buildroot-2012.08$ make busybox-menuconfig
make
resulted in a gzip
ped cpio
archive. Build the image
~/buildroot-2012.08$ make
~/buildroot-2012.08$ ls -l ./output/images/rootfs.cpio.gz
-rw-r--r-- 1 user group 1380949 2012-09-11 13:09 ./output/images/rootfs.cpio.gz
Less than 1.4MB for a working filesystem image with the tools I needed. Very nice!
Wrap it for U-Boot
In order to boot this using the 2-parameter U-Boot bootm
command, all that was left is to wrap it up:
~/buildroot-2012.08$ mkimage -A arm -O linux -T ramdisk -n "Initial Ram Disk"
-d output/images/rootfs.cpio.gz uramdisk.img
Image Name: Initial Ram Disk
Created: Tue Sep 11 15:26:51 2012
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 1380949 Bytes = 1348.58 kB = 1.32 MB
Load Address: 0x00000000
Entry Point: 0x00000000
And boot it
I booted this on an i.MX6 by hand by placing it and a kernel on an SD card like so:
MX6Q SABRELITE U-Boot > mmc dev 0
MX6Q SABRELITE U-Boot > fatload mmc 0 12000000 uImage
reading uImage
3837484 bytes read
MX6Q SABRELITE U-Boot > fatload mmc 0 12500000 uramdisk.img
reading uramdisk.img
1381013 bytes read
MX6Q SABRELITE U-Boot > bootm 12000000 12500000
## Booting kernel from Legacy Image at 12000000 ...
Image Name: Linux-3.0.35-1968-gd3f7f36-02004
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3837420 Bytes = 3.7 MB
Load Address: 10008000
Entry Point: 10008000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 12500000 ...
Image Name: Initial Ram Disk
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 1380949 Bytes = 1.3 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
...
Welcome to Buildroot
buildroot login: root
#
For more information about hacking RAM disks, check out this post.