Building U-boot and Linux for H5/H3/H2+
Contents
1 Introduction to Mainline
Linux kernel distributions have several lines. The Mainline is maintained by Linus. Other variants and distributions are maintained by various groups and organizations. All the variants and distributions are submitted to Linux and will be merged to the Mainline. The latest mainline of U-boot and Linux kernel already has support for H3 SoC. FriendlyElec customized the latest mainline u-boot and Linux kernel and made that u-boot and kernel work for all FriendlyElec's H3 boards.
2 Make an Installation SD Card
2.1 Download Image Files
Visit this download link to download the image files under the "officail-ROMs" directory and flashing utility under the "tools" directory:
Image Files h3-mainline-ubuntu-core-qte-sd4g.img.zip Ubuntu-Core with Qt-Embedded Image File, for NanoPi NEO Only Flash Utility: win32diskimager.rar Windows utility. Under Linux users can use "dd"
2.2 Make an Installation TF Card with Ubuntu-Core with Qt-Embedded
Extract the h3-mainline-ubuntu-core-qte-sd4g.img.zip and win32diskimager.rar. Insert a TF card(at least 8G) into a Windows PC and run the win32diskimager utility as administrator. On the utility's main window select your TF card's drive, the wanted image file and click on "write" to start flashing the SD card till it is done.Insert this card into your H3 board's MicroSD card slot and power on (with a 5V/2A power source). If the green LED is on and blue LED is blinking this indicates your board has successfully booted.
3 Mainline ROM Features
3.1 Ubuntu-Core with Qt-Embedded
Index NanoPi NEO 1 U-boot-2017.03 and Linux-4.10.y 2 Dynamic CPU frequency and voltage scaling 3 100M Ethernet, Static MAC address 4 1 x USB Host 5 Good support for various USB WiFi chips 6 Automatic resizing of file system on first boot 7 File system check on system boot
4 How to Compile
4.1 Install Cross Compiler
Download and extract cross compiler:
git clone https://github.com/friendlyarm/prebuilts.git sudo mkdir -p /opt/FriendlyARM/toolchain sudo tar xf prebuilts/gcc-x64/arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz -C /opt/FriendlyARM/toolchain/
Add the compiler's path to the "PATH" variable by appending the following lines in the ~/.bashrc file:
export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH export GCC_COLORS=auto
Run the ~/.bashrc script to make the changes in effect immediately in your working shell. Attention: there is a space after ".":
. ~/.bashrc
This is a 64-bit compiler and it cannot run on a 32-bit Linux. You can check whether or not your compiler is setup correctly by running the following commands:
arm-linux-gcc -v Using built-in specs. COLLECT_GCC=arm-linux-gcc COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolchain/4.9.3/libexec/gcc/arm-cortexa9-linux-gnueabihf/4.9.3/lto-wrapper Target: arm-cortexa9-linux-gnueabihf Configured with: /work/toolchain/build/src/gcc-4.9.3/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=arm-cortexa9-linux-gnueabihf --prefix=/opt/FriendlyARM/toolchain/4.9.3 --with-sysroot=/opt/FriendlyARM/toolchain/4.9.3/arm-cortexa9-linux-gnueabihf/sys-root --enable-languages=c,c++ --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3 --with-float=hard ... Thread model: posix gcc version 4.9.3 (ctng-1.21.0-229g-FA)
4.2 Compile U-boot
Download the U-boot source code and enter the master-h3 branch:
git clone https://github.com/friendlyarm/uboot.git cd u-boot git checkout master-h3
Compile U-boot:
make nanopi_h3_defconfig make
Update U-boot on SD Card:
dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8
Note: you need to replace "/dev/sdx" with the device name in your system.
4.3 Compile Linux Kernel
Download Linux Kernel Source Code:
git clone https://github.com/friendlyarm/linux.git cd linux git checkout h3-4.10.y
Compile Linux Kernel:
touch .scmversion make sunxi_defconfig make zImage dtbs
If your compilation is successful a zImage will be generated under "arch/arm/boot/" and a dtb file will be generated under "arch/arm/boot/dts/".
If your SD card's boot section is mounted at "/media/SD/boot/" you can update the zImage and dtb files by running the following commands:
cp arch/arm/boot/zImage /media/SD/boot/ cp arch/arm/boot/dts/sun8i-h3-nanopi*.dtb /media/SD/boot/