This particular setup is for the OrangePI PC Plus, but should with some small
changes work for all sun8i-h3 or sun8i-h2 boards (sun8i-h3-*, sun8i-h2-*) (Note:
sun stands for sunxi, 8i indicates the particular processer. h2/h3 boards have 4
Cortex-A7 CPUs.)
The mainline kernel has good support for these boards. You'll still find a lot
of references/documentation on how to use the sunxi-branch for both kernel and
u-boot. However, development has moved upstream and some of these branches are
no longer supported. (Please be aware of this, i.e. no need the apply old
patches. (ref:https://lists.denx.de/pipermail/u-boot/2014-December/199351.html)
You'll need to setup a toolchain to compile a bootloader, kernel
and rootfile system for your target device. Please refer to
https://crux-arm.nu/Documentation/ToolchainSetup for more information.
Download/untar or git clone a recent version of uboot. You can browse
http://git.denx.de for more information. For our setup we will use the '2019.01'
version of u-boot. You can get it at
ftp://ftp.denx.de/pub/u-boot/u-boot-2019.01.tar.bz2
After extracting the source, you can check the available configs in the config/
directory. For our board we will use orangepi_pc_plus_defconfig. Before compiling,
you will need to set the CROSS_TOOLS environment.
Basically, the standard configuration is enough to load the bootloader. In case
you want to enable/disable options, you can run 'make menuconfig'. Now run the
following:
\\
export CROSS_TOOLS={prefix-to-your-crux-arm-crosstools} make orangepi_pc_plus_defconfig
This will build a couple a files, but only 'sunxi-with-splash.bin' is of
relevance here. This is your bootloader. You can either flash it over serial or
write it the the bootsector of an SD-card. Please see FORMAT SD-CARD.
You can find a generic arm 32 bit CRUX root filesystem at
http://resources.crux-arm.nu/releases/3.4/crux-arm-rootfs-3.4.tar.xz
If you want to cross-compile all the packages from scratch, you will need to
setup pkgutils-cross (please refer to
https://crux-arm.nu/Documentation/PkgutilsCross)
For sunxi boards you can use the following flags to optimize performance:
CFLAGS="-O2 -pipe -mfloat-abi=hard -march=armv7ve -mcpu=cortex-a7 -mfpu=neon-vfpv4" CXXFLAGS="$CFLAGS"
You can also choose to recompile packages later on the target system itself.
You will need to write a small bootscript to tell u-boot how to load your kernel into memory. The following scripts loads the kernel (zImage) and device tree (sun8i-h3-orangepi-pc-plus.dtb) into memory. For the OrangePI PC Plus you can create the following boot.cmd file:
setenv fdt_high ffffffff setenv bootargs root=/dev/mmcblk0p2 rootwait panic=10 load mmc 0x42000000 zImage load mmc 0x49000000 sun8i-h3-orangepi-pc-plus.dtb bootz 0x42000000 - 0x49000000
zImage and sun8i-h3-orangepi-pc-plus.dtb are located on the first partition. The
root filesystem should be located on the second partition. More on this in FORMAT SD-CARD.
An additional step is needed to convert this script so it is executable by
u-boot:
mkimage -C none -A arm -T script -d boot.cmd boot.scr
This will result in a bootscript named boot.scr.
In the above steps we have compiled a bootloader and kernel. Besides that, we have generated a device tree file and boot script. Now you can format an SD-card with the following structure:
bootloader [sunxi-with-splash.bin] /dev/sdX1: vfat (20MB) [zImage, sun8i-h3-orangpi-pc-plus.dtb, boot.scr] /dev/sdX2: ext4 (default) [root file system]
Please note the different filesystems used for the two partitions. If you don't
know how to partition a device correctly, please refer to basic Linux
documentation.
Write the bootloader to the master boot record of the device (not the first
partition!):
dd if=sunxi-spl.bin of=/dev/sdX bs=1024 seek=8
Write the bootloader script (boot.scr), kernel (zImage) and device tree file
(sun8i-h3-orangepi-pc-plus.dtb) to the first partition. Untar the root
filesystem on the second partition. The bootloader will automatically check for
a configuration file on the first partition. the bootscript will load the kernel
into memory and the kernel will mount the root file system on the second
partition.
That's it! You now have a basic working system. Boot and setup the different
configuration files (rc, pkgmk, resolv.conf)!
Still testing --> GPU 3D hardware acceleration (https://bootlin.com/blog/mali-opengl-support-on-allwinner-platforms-with-mainline-linux/)