This how-to describes the process to build a RAM disk or init.rd image.
This is a part of the Xilinx design flow described in Getting Started.

Task Dependencies (Pre-requisites)

Tools Required

  • None

Input Files Required

  • ramdisk.image.gz (required for Zynq AP SoC)
  • initramfs.cpio.gz (required for MicroBlaze and PowerPC)

Output Files Produced

  • uramdisk.image.gz

Task Description

There are two types of formats being used for root filesystems. Before Vivado/SDK version 2013.1, Linux for Zynq AP SoC used an initial ramdisk/initrd (ramdisk.image.gz); Since then, the Zynq uses initramfs. MicroBlaze and PowerPC are using initramfs (initramfs.cpio.gz).

Prebuilt images

Prebuilt images can be found here:
for Zynq AP SoC (ARM) systems. (initrd)
for AXI (Little Endian) MicroBlaze systems. (initramfs)
for PLB (Big Endian) MicroBlaze systems. (initramfs)
for PLB (Big Endian) MicroBlaze systems. (initramfs)

Modifying the root filesystem


To modify an initial ramdisk:
1. Extract the initrd image from the gzip archive.
gunzip ramdisk.image.gz
2. Mount the initrd image.
chmod u+rwx ramdisk.image
mkdir tmp_mnt/
sudo mount -o loop ramdisk.image tmp_mnt/
cd tmp_mnt/
3. Make changes in the mounted filesystem.
4. Unmount the initrd image and compress the image.
sudo umount tmp_mnt/
gzip ramdisk.image

To create an initrd from scratch, tools such as Buildroot or Yocto may be used to populate the filesystem (with BusyBox, tools, etc.).
Alternatively, an empty initrd may be created and then populated with the desired filesystem contents as specified above. To create an empty (8MB) initrd:
dd if=/dev/zero of=ramdisk.image bs=1024 count=8192
mke2fs -F ramdisk.image -L "ramdisk" -b 1024 -m 0
tune2fs ramdisk.image -i 0
chmod a+rwx ramdisk.image


To modify an initramfs:
1. Extract the contents of the cpio.gz archive.
mkdir tmp_mnt/
gunzip -c initramfs.cpio.gz | sudo sh -c 'cd tmp_mnt/ && cpio -i'
cd tmp_mnt/
2. Make changes to the filesystem.
3. Repack the filesystem into a cpio.gz archive.
sh -c 'cd tmp_mnt/ && sudo find . | sudo cpio -H newc -o' | gzip -9 > new_initramfs.cpio.gz

To create an initramfs from scratch, tools such as Buildroot or Yocto may be used to populate the filesystem (with BusyBox, tools, etc.).
Alternatively, initramfs image may be created by populating a directory with the desired filesystem contents and packing these contents into a cpio.gz archive as mentioned above.

Wrapping the image with a U-Boot header

For Zynq AP SoC only, the ramdisk.image.gz needs to be wrapped with a U-Boot header in order for U-Boot to boot with it:
mkimage -A arm -T ramdisk -C gzip -d ramdisk.image.gz uramdisk.image.gz

For MicroBlaze and PowerPC, the initramfs.cpio.gz presently needs to be embedded into the kernel (see Build Linux Kernel).

Unwrap the image with the u-boot header

dd if=uRamdisk bs=64 skip=1 of=ramdisk.gz

Check File Type

file uramdisk.image.gz
uramdisk.image.gz: u-boot legacy uImage, , Linux/ARM, RAMDisk Image (gzip), 4815459 bytes, Fri May 30 01:52:10 2014,
Load Address: 0x00000000, Entry Point: 0x00000000, Header CRC: 0x265787C1, Data CRC: 0x2CA30F4B
file ramdisk.image.gz
ramdisk.image.gz: gzip compressed data, was "rootfs.cpio", from Unix, last modified: Fri May 30 01:52:08 2014

Next Step

Related Links