Manual build howto

From linux-sunxi.org
(Redirected from FirstSteps)
Jump to navigation Jump to search

This page describes the process to combine sunxi U-Boot, linux kernel and other bits together to create a useful SD-card from scratch, the basis for further hacking.

This page is only suited for A10, A13/A10s and A20 based devices. The manual build howtos for other SoCs are at the end of this page.

We of course do not build a whole distribution, we only build U-Boot, the kernel and a handful of tools, and then use an existing rootfs to get a useful system. Depending on the rootfs size, you might want to use a 2GB or larger SD Card. SD-card partitioning and formatting will be taken care of later.

Get a cross toolchain

For this part, you need to refer to our toolchain page.

To build the kernel you may need some additional packages:

apt-get install flex bison

Build U-Boot

Sunxi/Legacy U-Boot

Please refer to Compile U-Boot. When the build has completed, there will be spl/sunxi-spl.bin and u-boot.img available in your U-Boot tree.

The installation to SD card is covered in Bootable_SD_card#Bootloader.

Upstream/Mainline U-Boot

If your device is supported by upstream/mainline U-Boot, you should probably use that instead.

Follow these instructions to create u-boot-sunxi-with-spl.bin.

If you intend to boot older 3.4.x kernels with mainline U-Boot, make sure you also understand its boot configuration. Some information presented on this page needs to be adjusted accordingly - especially bootm_boot_mode could be important in that case.

Build the kernel

Sunxi/Legacy kernel

Build script.bin

The sunxi kernel depends on Allwinners own hardware description file, called script.bin, which needs to be loaded into memory by the bootloader so that the kernel can access it.

To build script.bin follow our guide to building script.bin.

Build the actual kernel

Please refer to our Kernel compilation guide.

Upstream/Mainline kernel

Please refer to our upstream kernel howto.

Remember to also build the device tree binaries.

Set up SD-Card for booting

Clean SD-Card

Refer to our SD-Card cleaning howto.

Partition SD-Card

Refer to our SD-Card partitioning howto.

Install Bootloader to the SD-Card

Refer to our SD-Card bootloader installation howto.

Mount your boot or root partition

Mount your boot or root partition again:

mount /dev/${card}1 /mnt

Install bootloader configuration

Follow instructions to set up either mainline or legacy sunxi U-Boot:

Install kernel binary

Now you can install your built kernel into the boot partition:

cp /home/user/dir/linux-sunxi/arch/arm/boot/uImage /mnt

Install board description

script.bin (for sunxi kernel)

If you are using the sunxi kernel, you need to install script.bin to the boot partition:

cp /home/user/dir/sunxi-boards/sys_config/aXX/script.bin /mnt

device tree binary (for upstream kernel)

If you are using the upstream/mainline kernel, you need to install the compiled device tree into the boot partition as well.

cp /home/user/dir/linux/arch/arm/boot/dtbs/<your_board>.dtb /mnt

(assuming your kernel sources are in /home/user/dir/linux)

You can find available compiled trees by listing kernel directory arch/arm/boot/dts/

ls /home/user/dir/linux/arch/arm/boot/dts/*.dtb

What trees get compiled during kernel compilation depend on what you selected in "System Type" menuconfig during kernel configuration. However you can compile any tree without recompiling kernel.

By default U-Boot boots with a tree, specified with U-Boot config option CONFIG_DEFAULT_DEVICE_TREE=<your_board>

Unmount your boot or root partition

Unmount the partition again.

umount /mnt

Setting up the rootfs

Please refer to Bootable_SD_card#Rootfs

Install kernel modules

As a last step you need to copy the kernel modules into the newly created rootfs. Change into the top level directory of the newly created rootfs and run:

mount ${cardroot} /mnt
mkdir -p /mnt/lib/modules
rm -rf /mnt/lib/modules/
cp -r <PATH_TO_KERNEL_TREE>/output/lib /mnt/
umount /mnt

(Replace <PATH_TO_KERNEL_TREE> with the directory you have built your kernel in as described above.)

Boot!

Now you should be able to unmount your SDCard filesystems, and you should be able to boot your brand new installation.

See also

We have Manual build howtos for all SoCs: