165 lines
6.8 KiB
Plaintext
165 lines
6.8 KiB
Plaintext
#
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Copyright (c) 2013-2023 Igor Pecovnik, [email protected]
|
|
#
|
|
# This file is a part of the Armbian Build Framework
|
|
# https://github.com/armbian/build/
|
|
#
|
|
enable_extension "marvell-tools"
|
|
|
|
# The C++ compiler is no longer included by default in the Armbian build system (but required for mox related stuff)
|
|
# Enable the extension that brings includes it. It could've been an inline extension (eg: the function right here),
|
|
# but having a core extension allows it to be pre-included in the Dockerfile generation and thus in the Docker images.
|
|
enable_extension "c-plus-plus-compiler"
|
|
|
|
# The BLx stuff requires 32-bit compiler, add it using an inline hook.
|
|
# This is only used for non-Docker, since the Docker image already has it, since it includes compilers for all architectures.
|
|
function add_host_dependencies__mvebu64_add_32_bit_c_compiler() {
|
|
display_alert "Adding armhf C compiler to host dependencies" "for mvebu64 BLx compile" "debug"
|
|
declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} gcc-arm-linux-gnueabi" # @TODO: convert to array later
|
|
}
|
|
|
|
declare -g ARCH=arm64
|
|
declare -g BOOTBRANCH='tag:v2025.10'
|
|
declare -g BOOTPATCHDIR='v2025.10'
|
|
declare -g BOOTENV_FILE='mvebu64.txt'
|
|
declare -g BOOTSCRIPT_OUTPUT='boot.scr'
|
|
declare -g OVERLAY_DIR="/boot/dtb/marvell/overlay"
|
|
declare -g ATFSOURCE='https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git'
|
|
declare -g ATFDIR='arm-trusted-firmware-espressobin'
|
|
declare -g ATFBRANCH='tag:lts-v2.12.8'
|
|
|
|
if [[ $BOARD = macchiatobin-doubleshot ]]; then
|
|
export SCP_BL2=$SRC/cache/sources/marvell-binaries/mrvl_scp_bl2.img # ATTENTION! This is actually a required 'export', since it's picked up by ATF's make.
|
|
|
|
declare -g ATF_TARGET_MAP="USE_COHERENT_MEM=0 LOG_LEVEL=20 MV_DDR_PATH=$SRC/cache/sources/marvell-ddr SECURE=0 PLAT=a80x0_mcbin;;build/a80x0_mcbin/release/bl31.bin"
|
|
declare -g UBOOT_TARGET_MAP="DEVICE_TREE=armada-8040-mcbin ;;flash-image.bin"
|
|
|
|
declare -g BOOTSCRIPT="boot-macchiatobin-doubleshot.cmd:boot.cmd"
|
|
declare -g SERIALCON='ttyS0'
|
|
else
|
|
declare -g ATF_TARGET_MAP="USE_COHERENT_MEM=0 LOG_LEVEL=20 SECURE=0 CLOCKSPRESET=CPU_800_DDR_800 DDR_TOPOLOGY=2 BOOTDEV=SPINOR PARTNUM=0 PLAT=a3700;;build/a3700/release/bl31.bin"
|
|
declare -g UBOOT_TARGET_MAP="DEVICE_TREE=armada-3720-espressobin ;;flash-image-*.bin"
|
|
|
|
declare -g BOOTSCRIPT="boot-espressobin.cmd:boot.cmd"
|
|
declare -g SERIALCON='ttyMV0'
|
|
fi
|
|
|
|
case $BRANCH in
|
|
|
|
legacy)
|
|
declare -g KERNEL_MAJOR_MINOR="6.6" # Major and minor versions of this kernel.
|
|
declare -g KERNELBRANCH='branch:linux-6.6.y'
|
|
;;
|
|
|
|
current)
|
|
declare -g KERNEL_MAJOR_MINOR="6.12" # Major and minor versions of this kernel.
|
|
declare -g KERNELBRANCH='branch:linux-6.12.y'
|
|
;;
|
|
edge)
|
|
declare -g KERNEL_MAJOR_MINOR="6.18" # Major and minor versions of this kernel.
|
|
;;
|
|
|
|
esac
|
|
|
|
declare -g CPUMIN=200000
|
|
declare -g CPUMAX=1300000
|
|
declare -g GOVERNOR=ondemand
|
|
|
|
function write_uboot_platform() {
|
|
if [[ $BOARD = macchiatobin-doubleshot ]]; then
|
|
dd if=$1/flash-image.bin of=$2 bs=512 seek=1 status=noxfer > /dev/null 2>&1
|
|
else
|
|
# flashing process via u-boot only for now https://www.armbian.com/espressobin/
|
|
/bin/true
|
|
fi
|
|
}
|
|
|
|
function family_tweaks() {
|
|
if [[ $BOARD = "espressobin" ]]; then
|
|
echo "#Marvell Espressobin Console" >> "${SDCARD}/etc/securetty"
|
|
echo "ttyMV0" >> "${SDCARD}/etc/securetty"
|
|
fi
|
|
}
|
|
|
|
function family_tweaks_bsp() {
|
|
: "${destination:?destination is not set}"
|
|
if [[ $BOARD = "espressobin" ]]; then
|
|
cp "$SRC/packages/bsp/mvebu64/initramfs/99-uboot-fit" "$destination/etc/initramfs/post-update.d/"
|
|
fi
|
|
}
|
|
|
|
function atf_custom_postprocess() {
|
|
# prepare compilers for postprocess
|
|
ubootdir="$SRC/cache/sources/u-boot-worktree/$BOOTDIR/${BOOTBRANCH##*:}"
|
|
declare -g ATF1="${ATF_COMPILER}"
|
|
declare -g ATF2="arm-linux-gnueabi-"
|
|
declare -g BL33="${ubootdir}/u-boot.bin"
|
|
}
|
|
|
|
function uboot_custom_postprocess() {
|
|
# clean previous
|
|
run_host_command_logged rm -f "$ubootdir"/flash-image*
|
|
|
|
declare atfdir="$SRC/cache/sources/$ATFDIR/${ATFBRANCH##*:}"
|
|
declare ubootdir="$SRC/cache/sources/u-boot-worktree/$BOOTDIR/${BOOTBRANCH##*:}"
|
|
declare moxbootdir="$SRC/cache/sources/mox-boot"
|
|
|
|
cd "${atfdir}" || exit_with_error "Cannot enter ATF directory ${atfdir}"
|
|
|
|
if [[ $BOARD = macchiatobin-doubleshot ]]; then
|
|
run_host_command_logged make distclean
|
|
|
|
FILENAME="flash-image.bin"
|
|
display_alert "Building mvebu64 ${BOARD}" "$FILENAME" "info"
|
|
# http://wiki.macchiatobin.net/tiki-index.php?page=Build+from+source+-+Bootloader#Building_ATF
|
|
run_host_command_logged make distclean
|
|
run_host_command_logged "CFLAGS=-fdiagnostics-color=always" pipetty make USE_COHERENT_MEM=0 LOG_LEVEL=20 MV_DDR_PATH=$SRC/cache/sources/marvell-ddr PLAT=a80x0_mcbin CROSS_COMPILE=$ATF1 BL33=$BL33 mrvl_flash $CTHREADS
|
|
run_host_command_logged cp -pv build/a80x0_mcbin/release/flash-image.bin $ubootdir/$FILENAME
|
|
else
|
|
|
|
cd "${moxbootdir}" || exit_with_error "Cannot enter mox-boot directory ${moxbootdir}"
|
|
|
|
display_alert "Patching mox-boot for mvebu64 ${BOARD}" "crazy toolchain thing" "info"
|
|
[[ -f Makefile ]] && sed -i "s/aarch64-unknown-linux-gnu-/aarch64-linux-gnu-/" Makefile
|
|
[[ -f wtmi/a53_helper/Makefile ]] && sed -i "s/aarch64-unknown-linux-gnu-/aarch64-linux-gnu-/" wtmi/a53_helper/Makefile
|
|
run_host_command_logged pipetty regular_git diff -u || true
|
|
|
|
display_alert "Building" "mox-boot for mvebu64 ${BOARD}" "info"
|
|
run_host_command_logged make clean
|
|
run_host_command_logged "CFLAGS=-fdiagnostics-color=always" pipetty make "CROSS_CM3=$ATF2" wtmi_app.bin
|
|
|
|
cd "${atfdir}" || exit_with_error "Cannot enter ATF directory ${atfdir}"
|
|
display_alert "Building atf for mvebu64 ${BOARD}" "" "info"
|
|
declare -a clocks=("600_600" "800_800" "1000_800" "1200_750")
|
|
declare -a topology=("512m_1cs_0" "1g_2cs_2" "1g_1cs_4" "2g_2cs_7" "1g_1cs_5" "2g_2cs_6")
|
|
for i in "${clocks[@]}"; do
|
|
for j in "${topology[@]}"; do
|
|
declare ddrname="undetermined"
|
|
if [[ $j = *cs_5 || $j = *cs_6 ]]; then ddrname="DDR4"; else ddrname="DDR3"; fi
|
|
FILENAME="flash-image-$ddrname-$j-$i.bin"
|
|
DDR_TOPOLOGY="${j##*_}"
|
|
CLOCKSPRESET="CPU_${i%_*}_DDR_${i##*_}"
|
|
display_alert "Building mvebu64 not-macchiatobin-doubleshot: ${BOARD}" "$FILENAME" "info"
|
|
run_host_command_logged make distclean
|
|
run_host_command_logged "CFLAGS=-fdiagnostics-color=always" pipetty make "CROSS_COMPILE=$ATF1" \
|
|
"CROSS_CM3=$ATF2" \
|
|
USE_COHERENT_MEM=0 \
|
|
PLAT=a3700 \
|
|
"CLOCKSPRESET=$CLOCKSPRESET" "DDR_TOPOLOGY=$DDR_TOPOLOGY" \
|
|
"MV_DDR_PATH=$SRC/cache/sources/marvell-ddr" \
|
|
"WTP=$SRC/cache/sources/marvell-tools" \
|
|
"CRYPTOPP_PATH=$SRC/cache/sources/cryptopp" \
|
|
"BL33=$BL33" \
|
|
"WTMI_IMG=$moxbootdir/wtmi_app.bin" \
|
|
BOOTDEV=SPINOR PARTNUM=0 \
|
|
LOG_LEVEL=20 all fip mrvl_flash $CTHREADS
|
|
run_host_command_logged cp -pv build/a3700/release/flash-image.bin "${ubootdir}/${FILENAME}"
|
|
done
|
|
done
|
|
fi
|
|
|
|
cd "${ubootdir}" || exit_with_error "Cannot enter ATF directory ${ubootdir}"
|
|
}
|