How to build and flash your own images

Instead of using the prebuilt Ubuntu-based images, it is possible to build your own root file system image and flash it. As mentioned previously, the IFC6410 has fastboot support only, and there is no tool publicly available that can be used to reflash the bootloader sections (SBLx, aboot, rpm) without fastboot. As such it is not recommended to erase or reflash any of the bootloader partitions, and we will assume from now on, that we boot to fastboot prompt.

There are 2 types of images that we can create and flash:

  1. boot image, used for the boot and recovery partition. it contains a kernel and an init ramdisk
  2. rootfs image, used for the main root FS, it can be flashed in any other partition, such as system or userdata.

Create a boot image

The easiest method is to use the tool abootimg, which you can install from your distribution repositories. For example, if you use Ubuntu:

sudo apt-get install abootimg

To print image information, such as file size and kernel bootargs (if any):

abootimage -i <image file>

To extract the content of the image file : zImage, initrd and the configuration file (boot.cfg):

abootimage -x <image file>

To create a new image, using your own zImage and initramdisk, you first need to create a config file, such as

# cat bootimg.cfg
bootsize = 0x1600000
pagesize = 0x800
kerneladdr = 0x80208000
ramdiskaddr = 0x82508000
secondaddr = 0x82100000
tagsaddr = 0x80200100
name = ifc6410
cmdline = earlyprintk=serial,ttyHSL0,115200,n8 console=ttyHSL0,115200,n8 root=/dev/mmcblk0p13 rootwait rw

Assuming you have your own zImage (output of kernel build), and an init ramdisk, you can build the boot image with:

abootimg --create boot.img -f bootimg.cfg -k zImage -r initrd

Create a rootfs image

Fastboot can flash standard image file, or alternatively sparse image file (sparse image files are post-processed image files, optimized to reduce footprint). There are several methods to create a rootfs image that can be flashed with fastboot.

Using make_ext4fs

The tool make_ext4fs is including in the Android SDK, and packaged in some desktop distribution (android-tools-fsutils in Debian/Ubuntu). It is the easiest way to automatically create a sparse image with an ext4 file system.

  1. create the root file system in a local folder on your PC. It can be created with anything: Ubuntu or Fedora, OpenEmbedded, buildroot or even a simple busybox, ...

  2. run the following command:

sudo make_ext4fs -L linaro -l 700M system.img <rootfs folder>

The generated file can directly be flashed with fastboot. The size argument is the size of the generated file system. The file system must be large enough to contain all files from the root file system. If you cannot use sudo, you can install and use fakeroot instead.

For example, if you want to create an image using a Linaro prebuilt Ubuntu root file system, download the latest Ubuntu-based developer image from The name of the file to download is linaro-<ubuntu release>-developer-<timestamp>-<build number>.tar.gz. For example: linaro-trusty-developer-20140721-673.tar.gz. Then you can run the following commands to create a fastboot image that can be flashed:

fakeroot tar xvzf linaro-trusty-developer-20140721-673.tar.gz
fakeroot rm -rf binary/dev
fakeroot mkdir binary/dev
fakeroot make_ext4fs -L linaro -l 700M linaro-developer-ifc6410.img binary/

Using standard tools

fallocate -l 2G system.img
mke2fs -F system.img
mkdir system
sudo mount -o loop system.img system
<fill in the image with the root FS content> 
sudo umount system

Flashing images

On IFC6410, GPT partitioning is used on the eMMC, and GPT support is properly implemented in the bootloader. As such the GPT table is read at boot, and all partition information (size, location and label) is extracted from the GPT table, and not hard coded in the bootloader (unlike with MBR or with NAND systems). It is then possible to update some partition information, and still use fastboot to flash them. However, it is important to note:

  • the partition for SBL1, SBL2, SBL3 and LK have no file system, and are used as RAW partition. So any attempt to resize might brick the board. You have been warned.
  • if you make any change to the GPT table you might not be able to reflash the Android releases from Inforce.

To flash the newly created boot image file into the boot partition:

sudo fastboot flash boot boot.img

If the boot.img content is too large to fit into the partition, it will fail before the flashing starts.

To flash the root file system image, it is recommended to use a partition which is large enough such as userdata or system

sudo fastboot flash userdata rootfs.img

On IFC6410 the maximum file size that can be transferred is 768MB. It is a hardcoded limit of the bootloader. Normally fastboot should split files larger than 768MB into multiple chunks, but there is a bug probably in the IFC6410 bootloader. However you can force fastboot to split a .img file into chunks in case you need to flash a file larger than 768M with:

sudo fastboot -S 768M flash userdata rootfs.img

Boards/IFC6410/HowTo-BuildFlash (last modified 2014-08-13 07:27:22)