# # SPDX-License-Identifier: GPL-2.0 # # Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com # # This file is a part of the Armbian Build Framework # https://github.com/armbian/build/ # enable_extension "marvell-tools" ARCH=arm64 BOOTBRANCH='tag:v2022.04' BOOTPATCHDIR="v2022.07" BOOTENV_FILE='mvebu64.txt' BOOTSCRIPT_OUTPUT='boot.scr' ATFSOURCE='https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git' ATFDIR='arm-trusted-firmware-espressobin' ATFBRANCH='branch:master' ATF_USE_GCC='> 7.2' if [[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]]; then ATF_COMPILER='aarch64-linux-gnu-' else ATF_COMPILER='aarch64-none-linux-gnu-' fi if [[ $BOARD = macchiatobin-doubleshot ]]; then export SCP_BL2=$SRC/cache/sources/marvell-binaries/mrvl_scp_bl2.img 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" UBOOT_TARGET_MAP="DEVICE_TREE=armada-8040-mcbin ;;flash-image.bin" BOOTSCRIPT="boot-macchiatobin-doubleshot.cmd:boot.cmd" SERIALCON='ttyS0' else 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" UBOOT_TARGET_MAP="DEVICE_TREE=armada-3720-espressobin ;;flash-image-*.bin" BOOTSCRIPT="boot-espressobin.cmd:boot.cmd" SERIALCON='ttyMV0' fi case $BRANCH in current) export KERNEL_MAJOR_MINOR="5.15" # Major and minor versions of this kernel. KERNELBRANCH='branch:linux-5.15.y' ;; edge) export KERNEL_MAJOR_MINOR="6.1" # Major and minor versions of this kernel. KERNELBRANCH='branch:linux-6.1.y' ;; esac CPUMIN=200000 CPUMAX=1300000 GOVERNOR=ondemand NM_IGNORE_DEVICES="interface-name:eth*,interface-name:wan*,interface-name:lan*,interface-name:br*" 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 } family_tweaks() { chroot_sdcard_apt_get remove --auto-remove linux-sound-base alsa-base alsa-utils bluez [[ -f $SDCARD/etc/netplan/armbian-default.yaml ]] && sed -i "s/^ renderer.*/ renderer: networkd/" $SDCARD/etc/netplan/armbian-default.yaml cp $SRC/packages/bsp/mvebu64/networkd/10* $SDCARD/etc/systemd/network/ if [[ $BOARD = "espressobin" ]]; then echo "#Marvell Espressobin Console" >> $SDCARD/etc/securetty echo "ttyMV0" >> $SDCARD/etc/securetty fi } family_tweaks_bsp() { if [[ $BOARD = "espressobin" ]]; then cp "$SRC/packages/bsp/mvebu64/initramfs/99-uboot-fit" "$destination/etc/initramfs/post-update.d/" fi } atf_custom_postprocess() { # prepare compilers for postprocess ubootdir="$SRC/cache/sources/$BOOTDIR/${BOOTBRANCH##*:}" export ATF1=$toolchain/$ATF_COMPILER if [[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]]; then export TOOLCHAIN_NAME="arm-linux-gnueabi-" else export TOOLCHAIN_NAME="arm-none-linux-gnueabihf-" fi export ATF2=$(find_toolchain "$TOOLCHAIN_NAME" "> 10.0")/$TOOLCHAIN_NAME export BL33=$ubootdir"/u-boot.bin" } uboot_custom_postprocess() { # clean previous rm $ubootdir/flash-image* local atfdir="$SRC/cache/sources/$ATFDIR/${ATFBRANCH##*:}" local ubootdir="$SRC/cache/sources/$BOOTDIR/${BOOTBRANCH##*:}" local moxbootdir="$SRC/cache/sources/mox-boot" cd $atfdir if [[ $BOARD = macchiatobin-doubleshot ]]; then run_host_command_logged make distclean FILENAME="flash-image.bin" display_alert "Building $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 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 make clean # @TODO: rpardini: why? run_host_command_logged make CROSS_CM3=$ATF2 wtmi_app.bin cd $atfdir clocks=(600_600 800_800 1000_800 1200_750) 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 if [[ $j = *cs_5 || $j = *cs_6 ]]; then local ddrname="DDR4"; else ddrname="DDR3"; fi FILENAME="flash-image-$ddrname-$j-$i.bin" DDR_TOPOLOGY="${j##*_}" CLOCKSPRESET="CPU_${i%_*}_DDR_${i##*_}" display_alert "Building $FILENAME" "" "info" run_host_command_logged make distclean run_host_command_logged 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 }