#!/bin/bash # Build ARM Trusted Firmware for Slackware ARM and AArch64 # Created By: Brenton Earl # Date: 3/21/2021 # Built and tested on Slackware64-current # Modifed by MoZes@slackware for use within the Slackware ARM build environment. # Reference: https://src.fedoraproject.org/rpms/arm-trusted-firmware/blob/f34/f/arm-trusted-firmware.spec ######################################################################################################### # Install a cross compiler for arm and aarch64 (x-toolchain) # cross compiler: ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-devtools/x-toolchain/ ######################################################################################################### # Note: This can only be run on the x86 using the x-toolchain cross compiler that's used # to build SlackwareARM/AArch64. This is because the rk3399 (RockPro64)'s ARM trusted # firmware won't build natively! # This isn't too much of an issue, it just means we cannot automate this but given that # it is entirely separate from the Slackware OS, it's acceptable. ######################################################################################################### CWD=$PWD TMP=/tmp/build-arm-trusted-firmware BINS=$PWD/../bin/ rm -rf $TMP mkdir -p $TMP export NUMJOBS=-j$( nproc ) # Set path to include your cross compiler, aarch64 first, then arm export PATH="/devel/build-servers/x86_64/aarch64/bin:/devel/build-servers/x86_64/arm/bin:$PATH" # The 'SOCCHIPSET' is the chipset name, where as 'SOCS' may be the chipset # name and/or the marketing name. # The ARM Trusted Firmware uses the marketing names. # For consistency with the Kernel module loader, we'll be naming our binaries # using the chipset name. SOCS[0]="rk3399" SOCCHIPSET[0]="rk3399" # The RPI4 doesn't need this: #SOCS[1]="rpi3" #SOCCHIPSET[1]="bcm2837" #SOCS[2]="rpi4" #SOCCHIPSET[2]="bcm2711" # Extract source: cd $TMP tar xf $CWD/sources/arm-trusted-firmware-*.tar.xz cd trusted-firmware*/ || exit 1 for (( i=0 ; i <= $((${#SOCS[@]}-1)) ; i++ )); do echo "Building ATF for: ${SOCS[$i]} ( ${SOCCHIPSET[$i]} )" rm -rf $BINS/${SOCCHIPSET[$i]} mkdir -p $BINS/${SOCCHIPSET[$i]} make realclean # Yes this still needs the 32bit toolchain. Yuck. sed -i 's/arm-none-eabi-/arm-slackware-linux-gnueabihf-/' plat/rockchip/rk3399/drivers/m0/Makefile LDFLAGS="--no-warn-rwx-segment" \ V=1 DEBUG=1 \ CROSS_COMPILE="aarch64-slackware-linux-gnu-" \ make $NUMJOBS PLAT=${SOCS[$i]} bl31 || exit 1 # Copy licences and documentation: install -vpm644 readme.rst docs/license.rst $BINS/${SOCCHIPSET[$i]} # Rockchips wants the bl31.elf, plus rk3399 wants power management co-processor bits echo "*** There may be install errors here due to missing files - it's probably ok ;-) " for file in bl31.bin bl31.elf rk3399m0.bin rk3399m0.elf ; do # Store it within the bins directory for this platform: install -vpm644 $( find . -name $file ) $BINS/${SOCCHIPSET[$i]} done done