Building the kernel and u-boot for the CuBox-i and the HummingBoard
Following are details on building u-boot and Freescale kernel 3.0.35 (BSP 4.1.0) for the CuBox-i and the HummingBoard
Building from sources
You need to have installed arm-linux-gnueabi:
sudo apt-get install arm-linux-gnueabi
If arm-linux-gnueabi is not located try:
sudo apt-get install gcc-arm-linux-gnueabi
You also need to have u-boot-tools installed (for mkimage):
sudo apt-get install u-boot-tools
You also need to have lzop installed (for "make zImage"):
sudo apt-get install lzop
Set your environment variables:
export ARCH=arm export CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-
Originally there were two u-boot versions that are support; a patched version of Freescale u-boot (based on u-boot 2009.08) and second is a fork from upstream port.
All the development now is focused on the upstream port.
This version of U-Boot is a fork from the upstream and patched by Jon Nettelton. Main feature is addition of console on HDMI support, and the SPL support for Cubox-i. To build the bootloader, do:
git clone https://github.com/SolidRun/u-boot-imx6.git cd u-boot-imx6 make mx6_cubox-i_config make
A successful build will create two files in the source tree directory, SPL and u-boot.img
- SPL file is the actual machine detection and initialization and must be flashed on offset 1KByte of the boot micro SD.
- u-boot.img is the second stage bootloader; it can be flashed at offset 42KByte from the starting of the boot micro SD; or alternatively can be put as-is on the first partition of the micro SD.
The general bootloader flashing procedure is:
- Flashing SPL -
sudo dd if=SPL of=/dev/sdX bs=1K seek=1
- Flashing u-boot.img as raw to the micro SD -
sudo dd if=u-boot.img of=/dev/sdX bs=1K seek=42
Notice that you need to replace 'sdX' with your micro SD block device.
|Putting the wrong 'sdX' might wipe your hard drive. Be sure that you're flashing u-boot to your micro SD and not another local drive.|
ARM toolchain must be installed. If there is no such package in Ubuntu you can download it from the internet and add it to your $PATH.
Take a look at what is arm-linux-gcc.
During compiling it might be, that your makefile is looking for different filenames, than you have (for example in Ubuntu 14.04).
Try locating arm-linux-gnueabi-gcc file. Go to that directory and you may create links for each file with arm-linux-gnueabi- prefix. e.g.
sudo ln -s arm-linux-gnueabi-gcc arm-linux-gcc sudo ln -s arm-linux-gnueabi-cc arm-linux-cc
You must do this for each file otherwise it will come to errors preventing you to compile right.
Alternatively, edit arch/arm/config.mk and edit the line:
CROSS_COMPILE ?= arm-linux-
CROSS_COMPILE ?= arm-linux-gnu-
CROSS_COMPILE ?= arm-linux-gnueabi-
depending on the name of your cross compiler.
For a program to read or set U-Boot environment variables in an image file, or (on a CuBox) the installed SD card, see https://github.com/s-e-p/uboot-env This also has an alternative boot environment available.
There are currently two supported kernels for the CuBox-i and HummingBoard -
- Kernel 3.14 LTS - The current kernel for CuBox-i and HummingBoard. The drive is that all projects focus on this kernel as much as possible.
- Kernel 3.10 LTS - This kernel announced here. It is based on Linaro kernel 3.10 LTS, i.MX6 Freescale patches and patches from Russell King, Jon Nettleton and various other developers. This kernel is the main kernel to be used for end users and general availability.
- The older 3.0.35 with BSP 4.1.0 kernel will be mainly used for Android drops and once kernel 3.10 LTS is ported to Android then it will become obsolete and not maintained anymore.
Kernel 3.14 LTS
The kernel can be built using the following instructions -
#make sure you have packages bc and lzop installed e.g. apt-get install bc lzop git clone https://github.com/SolidRun/linux-imx6-3.14 cd linux-imx6-3.14 export ARCH=arm export CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- make imx_v7_cbi_hb_defconfig make zImage imx6q-cubox-i.dtb imx6dl-cubox-i.dtb imx6dl-hummingboard.dtb imx6q-hummingboard.dtb make modules make modules_install INSTALL_MOD_PATH=<install path of the modules>
The generated files are -
arch/arm/boot/zImage arch/arm/boot/dts/imx6q-cubox-i.dtb arch/arm/boot/dts/imx6dl-cubox-i.dtb arch/arm/boot/dts/imx6dl-hummingboard.dtb arch/arm/boot/dts/imx6q-hummingboard.dtb
The first one is the actual kernel, the other four are device tree files to be loaded by the boot loader according to it's configuration.
Notice that using the maintained u-boot; when running 'run autodetectfdt' as part of the boot sequence, an environment variable 'fdt_file' is automatically generated which sets the correct dtb to load according to the processor and board configuration.
For reporting issues, either use linux-imx6-3.14 issue tracking or linux4kix/linux-linaro-stable-mx6.
For development, if those are minor fixes then fork the linux-imx6-3.14 and issue pull request. For major development, bug fixes and improvements then fork linux4kix/linux-linaro-stable-mx6 on github (the 3.14 branch) and pull request once the fix/enhancement is ready.
Kernel 3.10 LTS
The kernel can be built using the following instructions -
git clone https://github.com/SolidRun/linux-linaro-stable-mx6.git cd linux-linaro-stable-mx6 make imx_v7_cubox-i_hummingboard_defconfig make zImage imx6q-cubox-i.dtb imx6dl-cubox-i.dtb imx6dl-hummingboard.dtb make modules
The generated files are -
arch/arm/boot/zImage arch/arm/boot/dts/imx6q-cubox-i.dtb arch/arm/boot/dts/imx6dl-cubox-i.dtb arch/arm/boot/dts/imx6dl-hummingboard.dtb
The first one is the actual kernel, the other four are device tree files to be loaded by the boot loader according to it's configuration. Notice that using the maintained u-boot; an environment variable 'fdt_file' is automatically generated according to the board it is running on, and the processor configuration.
Kernel 3.0.35 (patched with BSP 4.1.0 and CuBox-i and HummingBoard support)
Kernel for the CuBox-i and HummingBoard is initially based on Freescale kernel 3.0.35 with BSP 4.1.0 patches.
git clone https://github.com/SolidRun/linux-imx6.git cd linux-imx6 make imx6_cubox-i_hummingboard_defconfig make uImage make modules
After successful build the output kernel is arch/arm/boot/uImage and kernel modules are scattered inside the build tree.
Ready to use binary images
You can alternatively download images from here
Download the u-boot and the uImage binaries; where the first one is the u-boot mentioned above but the uImage is a kernel with a buildroot based initramfs (root password '123456').
See this post for a newer version using the alternative SPL and u-boot.img.
Flashing U-boot and the kernel - full example
The Cubox-i is hard-programmed to boot from a MicroSD card. Even if you want to load the OS from another media (e.g. SATA or network), the bootloader must be loaded from the card.
- The first stage bootloader (the SPL file generated by U-boot build) must reside at 1KByte offset from the beginning of the card
- The second stage bootloader (the boot.img file generated by U-boot build) must reside at 42Kbyte offset from the beginning of the card
SPL and U-Boot, along with the save area for U-Boot environment variables, currently takes up 392K, or 784 sectors, so the first partition should be created beyond that point, usually 1024 or 2048 for the starting sector of the first partition, else your bootloader will overwrite your filesystem or vice versa.
For the following example, we will be assuming you are creating a single partition that occupies the whole card which will house your OS root filesystem, and that partition is /dev/sdX1
|Putting the wrong 'sdX' might wipe your hard drive. Be sure that you're using the device name that corresponds to your card.|
Note that this procedure has been updated for the newer U-boot with SPL support; the previous procedure here was for the older U-boot, and was removed.
fdisk /dev/sdX <Create primary partition 1, ensuring that the first begins at 1Mb (offset 2048); it will become /dev/sdX1> # Hat tip to hste and jas for this recipe mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=1024 -b 4096 /dev/sdX1 sudo mount /dev/sdX1 <mount point> mkdir <mount point>/boot # Install the kernel and its modules cd <linux tree> cp arch/arm/boot/uImage <mount point>/boot INSTALL_MOD_PATH=<mount point> make modules_install cd .. <copy the root filesystem and do any other modifications on the mounted partition> # Install U-boot and create uEnv.txt dd if=<Uboot tree>/SPL of=$DEVICE bs=1K seek=1 dd if=<Uboot tree>/u-boot.img of=$DEVICE bs=1K seek=42 echo "bootfile=/boot/uImage" > <mount point>/uEnv.txt # In the line below, the root parameter reflects the name of the partition on which your # root filesystem resides as your kernel perceives it echo "mmcargs=setenv bootargs root=/dev/mmcblk0p1 rootwait video=mxcfb0:dev=hdmi \ consoleblank=0" >> <mount point>/uEnv.txt umount <mount point> sync <wait for several seconds to compensate for the host OS, the card reader and the card's cleverness>
The micro SD should be ready. Before removing it make sure it's completely unmounted; put it in the micro SD slot in the HummingBoard or the micro SD slot beneath the HDMI port in CuBox-i and then power it up.
Booting the kernel
After powering up and serial console is set you should get the u-boot prompt. Now you can boot the kernel with the following command line -
setenv bootargs 'console=ttymxc0,115200 video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24,bpp=32' fatload mmc 0:1 0x10800000 /uImage bootm 0x10800000