Orange Pi PC 2
Requisitos
Gentoo
root # crossdev -t aarch64-unknown-linux-gnu --g 7.2.0 -v
root # PYTHON=python2 emerge u-boot-tools
ArchLinux
root # pacman -S uboot-tools aarch64-linux-gnu-binutils aarch64-linux-gnu-gcc aarch64-linux-gnu-glibc aarch64-linux-gnu-linux-api-headers
Preparar o cartão
Limpar cartão
root # dd if=/dev/zero of=/dev/sdX bs=1M count=8
Criar Partição
Criar a partição com o inicio a partir do sector 4096.
root # fdisk /dev/sdX
Filesystem
root # mkfs.ext4 -O ^metadata_csum /dev/sdX1
Copiar o Userland
root # mkdir /mnt/opipc
root # mount /dev/sdX1 /mnt/opipc
user $ mkdir ~/opipc
user $ cd ~/opipc
ArchLinux
user $ wget http://archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
user $ bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt/opipc
Gentoo
Sacar o mais recente de http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-arm64/
user $ tar xfa stage3-armv7a_hardfp-????????.tar.bz2 -C /mnt/opipc
boot.scr
Criar o ficheiro /mnt/opipc/boot/boot.cmd com o seguinte conteudo:
part uuid ${devtype} ${devnum}:${bootpart} uuid
setenv bootargs console=${console} root=PARTUUID=${uuid} rw rootwait
setenv fdtfile allwinner/sun50i-h5-orangepi-pc2.dtb
if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/Image; then
if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
else
booti ${kernel_addr_r} - ${fdt_addr_r};
fi;
fi;
fiE correr o mkimage para criar o boot.scr.
user $ cd /mnt/opipc/boot
user $ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Orange Pi PC 2 boot script" -d boot.cmd boot.scr
Sources
Sacar o source de tudo necessario para bootar, o Armbian é usado para ripar o config do kernel e os patches adicionais.
user $ cd ~/opipc
user $ git clone https://github.com/armbian/build.git armbian
user $ git clone git://git.denx.de/u-boot.git -b v2017.07 u-boot
user $ git clone https://github.com/apritzel/arm-trusted-firmware -b allwinner-stable arm-trusted-firmware-sunxi-main
user $ git clone https://github.com/Icenowy/linux/ -b sunxi64-4.13.y linux-sun50i-dev
ARM Trusted Firmware
user $ cd ~/opipc
user $ cd arm-trusted-firmware-sunxi-main
user $ make CROSS_COMPILE=aarch64-unknown-linux-gnu- PLAT=sun50iw1p1 DEBUG=1 bl31
user $ cp build/sun50iw1p1/debug/bl31.bin ../u-boot/
U-Boot
user $ cd ~/opipc
user $ cd u-boot
user $ make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 orangepi_pc2_defconfig
user $ make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4
user $ cat spl/sunxi-spl.bin u-boot.itb > u-boot-sunxi-with-spl.bin
E gravar o bootloader no cartão com:
root # dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=8k seek=1
Kernel
cd ~/opipc
cd linux-sun50i-dev
cp ../armbian/config/kernel/linux-sun50i-dev.config .config
#for i in ../armbian/patch/kernel/sun50i-dev/*.patch; do patch -p1 < $i; done
#for i in ../armbian/patch/kernel/sun50i-dev/scpi/*.patch; do patch -p1 < $i; done
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- INSTALL_MOD_PATH=/mnt/opipc -j4 modules_install
cp arch/arm64/boot/Image /mnt/opipc/boot
cp arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dtb /mnt/opipc/boot/dtbs/allwinner/sun50i-h5-orangepi-pc2.dtb
Finalizar
sudo sync
sudo umount /mnt/opipc
sudo eject /dev/sdX