BananaPro/Pi:Building u-boot, script.bin and linux-kernel

From BananaPro/Pi
Jump to: navigation, search

Note: all of the following instructions (and also in the sections 2, 3 and 4 
following on from this page) have to be carried out on a Linux computer, not the Bananan Pro/Pi itself!!

This page describes the process of combining sunxi u-boot, the Linux kernel and other bits together to create the basis of a bootable OS from scratch, and which can also be the basis for further hacking.

Of course, we are not building a whole distribution here, we're only building u-boot, the kernel and a handful of tools, and then using an existing root file system to get a usable OS. Depending on the size of the root file system, we suggest you use a 4GB or larger SD card – a type class 10 would be faster and more stable. SD card partitioning and formatting will be taken care of later.

We'll outline two methods on this page to build what we need: one is step by step, the other is the easiest way by using sunxi BSP(Board Support Package).

Get a cross toolchain

The toolchain is a set of binaries, system libraries and tools which allow you to build (in our case, cross-compile) u-boot and the kernel for a target platform. This will, to some limited extent, need to match the target rootfs. If you use Ubuntu or Debian, you can get all you need by installing the tools below:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential u-boot-tools uboot-mkimage \
binutils-arm-linux-gnueabihf gcc-4.7-arm-linux-gnueabihf-base g++-4.7-arm-linux-gnueabihf 
sudo apt-get install gcc-arm-linux-gnueabihf cpp-arm-linux-gnueabihf \
libusb-1.0-0 libusb-1.0-0-dev git wget fakeroot kernel-package zlib1g-dev libncurses5-dev

Note: On Debian (wheezy)/Ubuntu 13.10 (saucy) onwards, the uboot-mkimage package has been removed; the mkimage command is included in the u-boot-tools package. On Ubuntu 12.04, change

gcc-4.7-arm-linux-gnueabihf-base and g++-4.7-arm-linux-gnueabihf


gcc-4.6-arm-linux-gnueabihf-base and g++-4.6-arm-linux-gnueabihf

You also can use the Linaro tool chain or the Code Sourcery tool chain - they are standalone toolchains with big tarballs which come with everything you need.

Use the BSP

BSP stands for “Board Support Package”.


Get the BSP repository:

git clone


After getting the BSP, then navigate into the lemaker-bsp directory, and run the build command:

If for Banana Pro:

cd lemaker-bsp
./configure BananaPro

If for Banana Pi:

cd lemaker-bsp
./configure BananaPi

This will take a long time to build all the things. After it has been built, you can get all you want from the build/BananaPro_hwpack or build/BananaPi_hwpack directory, such as the u-boot-sunxi-with-spl.bin, uImage, and scritp.bin, modules. You can tweak your kernel configuration too by running:

make linux-config

This will override the .config file in the /build/sun7i_defconfig-linux.

Step by step

Building u-boot

U-boot is the bootloader commonly used on our Allwinner SoCs. Similar to many others, it provides the basic infrastructure to bring an SBC (single board computer) up to a point where it can load a Linux kernel and start booting your operating system.
First you need to clone the repository from Github:

git clone

After the repository has been retrieved, you can build the u-boot.

First make the u-boot configure:

If for Banana Pro:

make CROSS_COMPILE=arm-linux-gnueabihf- BananaPro_config

If for Banana Pi:

make CROSS_COMPILE=arm-linux-gnueabihf- BananaPi_config

And then make the u-boot:

make CROSS_COMPILE=arm-linux-gnueabihf-

After that you may get the u-boot-sunxi-with-spl.bin, u-boot.img, u-boot.bin, spl/sunxi-spl.bin. Here we are only using the u-boot-sunxi-with-spl.bin file.

Building script.bin

First, get the following repositories:

git clone
git clone

Go into sunxi-tools and run the command:


You may need install the dependent packages:

sudo apt-get install pkg-config

You will get the tools fex2bin, bin2fex and some others.

Then go into the sunxi-boards tree and find the fex file for the Banana Pi. We can customize some of the configurations in the file, such as [gmac_para], [usb_wifi_para], etc.

Create the script.bin file:
If for Banana Pro:

${sunxi-tools}/fex2bin BananaPro.fex script.bin

If for Banana Pi:

${sunxi-tools}/fex2bin BananaPi.fex script.bin

The prefix ${sunxi-tools} indicates that you are in your sunxi-tools tree.

You will need this script.bin file later on when finishing the u-boot installation.

Building the kernel

First, get the linux kernel repository by following:

git clone

Second, set default kernel configuration:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun7i_defconfig

Third, tweak the config. You can open some kind of kernel configuring software or close the useless kernel configuration by editing your kernel configuration:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Building uImage and modules:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules

As a final step, create the full module tree:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=output modules_install

The INSTALL_MOD_PATH option specifies the directory where the full module tree will be made available. In this example, it will be the output directory under the kernel build directory itself.

Now you have the following residing in your kernel tree:


The uImage file needs to be started by u-boot, and the modules directory needs to be copied to the /lib/modules on the target root file system.

Using four files

Through either “step by step” or “using the bsp”, you will get at least the four files or packages you need, which are:


We will use these four files to set up the bootable SD card in Part 2, BananaPro/Pi:Setting up the bootable SD card.



(With thanks to native speaker “roses” for checking and upgrading this document)