How to decrease boot time on iMX6
This tutorial shows how to decrease boot time on a NXP i.MX6 Sabre SD using Falcon mode. The Kernel used is the 4.8 linux stable version.
Falcon mode skips U-Boot completely and leverages SPL to boot the Kernel and load the rootfs faster.
It still adds U-Boot to the image as it’s used during configuration and loading the Kernel and dtb, but after this configuration is done it can skip U-Boot completely jumping directly to the Kernel.
If you want to know more about Falcon mode, please check here.
i.MX6Q Sabre SD
U-Boot
U-Boot 2016.11 already enables Falcon mode for i.MX6 sabresd board.
The patch is available here.
To build an U-Boot image follow the next steps:
Download U-Boot:
$ git clone git://git.denx.de/u-boot.git
Change to the most recent branch:
$ git checkout -b 2016.11 v2016.11
Configure U-Boot to using the following command:
$ make mx6sabresd_spl_defconfig
Compile it:
$ make
Kernel
Download the patch here or the config file here.
I’m reducing the kernel configuration in order to get a smaller kernel, which reduces the booting time.
To do that, follow the next steps:
Download the Kernel:
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Change to the most recent branch:
$ git checkout origin/linux-4.8.y -b local_linux-4.8
Apply the patch:
$ git am 0001-Minimal-Kernel-Features-for-i.MX6Q.patch
$ make minimal_imx6q_defconfig
Compile it generating uImage:
$ make uImage LOADADDR=0x10800000
Root File System
Download the local.conf here.
$ bitbake core-image-base
After that, extract using cpio command:
$ mkdir rootfs
$ cd rootfs/
$ cpio -id < core-image-minimal-mx6sabresd.rootfs.cpio
Preparing SD card
Create a partition using a tool such as GParted. The raw space must have at least 5MB and the rootfs partition 15MB.
Copying U-Boot
The SPL file and u-boot.img are flashed into the raw space:
$ DEV=/dev/sdX
$ sudo dd if=SPL of=$DEV bs=1K seek=1 && sync
$ sudo dd if=u-boot.img of=$DEV bs=1K seek=69 && sync
Copying the File System
Copy the file system into the root partition:
$ sudo cp -aR rootfs/* /media/root
Copying Kernel and DTB
Power up the board and go into U-Boot.
Upload Kernel and dtb to the board using TFTP with the following steps:
Set up your host IP:
# setenv serverip 192.168.1.10
Download the dtb file:
# dhcp ${fdt_addr} imx6q-sabresd.dtb
Download the Kernel image:
# dhcp ${loadaddr} uImage
Writing the Kernel at 2MB offset:
# mmc write ${loadaddr} 0x1000 0x4000
Setup the Kernel bootargs:
# setenv bootargs 'console=ttymxc0,115200 root=/dev/mmcblk1p1 rootfstype=ext4 rootwait quiet rw'
Prepare args:
# spl export fdt ${loadaddr} - ${fdt_addr}
Writing args 1MB data (0x800 sectors) to 1MB offset (0x800 sectors):
# mmc write 18000000 0x800 0x800
Boot the board with KEY_VOL_UP pressed and the SPL binary are launched the kernel directly.
Images
Download the SD card image here.
The image is available for download. To copy this image into the SD card, use the following command:
$ sudo dd if=falconmode_imx6sabresd.sdcard of=/dev/sdX
The video showing this process is available here.