diff --git a/config/sources/families/k3.conf b/config/sources/families/k3.conf new file mode 100644 index 0000000000..3b6b7817ca --- /dev/null +++ b/config/sources/families/k3.conf @@ -0,0 +1,83 @@ +# +# 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/ +# + +declare -g ARCH="arm64" +declare -g LINUXFAMILY="k3" + +declare -g SKIP_BOOTSPLASH="yes" + +case "${BRANCH}" in + + current) + + declare -g KERNEL_MAJOR_MINOR="6.1" + declare -g KERNELBRANCH="branch:linux-6.1.y" + ;; + + edge) + + declare -g KERNEL_MAJOR_MINOR="6.3" + declare -g KERNELBRANCH='branch:linux-6.3.y' + ;; + +esac + +ATF_PLAT="k3" +ATF_BOARD="lite" +ATF_TARGET_MAP="PLAT=$ATF_PLAT TARGET_BOARD=$ATF_BOARD DEBUG=1 bl31;;build/$ATF_PLAT/$ATF_BOARD/debug/bl31.bin:bl31.bin" + +UBOOT_TARGET_MAP="ATF=bl31.bin all;;tiboot3.bin tispl.bin u-boot.img" + +# To match what our current SDK produces +BOOT_FS_LABEL="boot" +ROOT_FS_LABEL="root" + +function add_host_dependencies__k3_python3_dep() { + display_alert "Preparing K3 U-Boot host-side dependencies" "${EXTENSION}" "info" + declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} python3-yaml python3-jsonschema" +} + +function compile_k3_bootgen() { + # Source code checkout + ( fetch_from_repo "https://git.ti.com/cgit/processor-firmware/ti-linux-firmware" "ti-linux-firmware" "branch:ti-linux-firmware" ) + ( fetch_from_repo "https://git.ti.com/cgit/ti-u-boot/ti-u-boot" "ti-u-boot" "branch:ti-u-boot-2023.04" ) + + pushd ${SRC}/cache/sources/ti-u-boot || exit + + run_host_command_logged make -j$(nproc) CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm am64x_evm_r5_defconfig + run_host_command_logged make -j$(nproc) CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm BINMAN_INDIRS=${SRC}/cache/sources/ti-linux-firmware + + popd +} + +function uboot_custom_postprocess() { + # Compile first stage bootloader + compile_k3_bootgen + + cp ${SRC}/cache/sources/ti-u-boot/${TIBOOT3_FILE} tiboot3.bin +} + +function post_create_partitions() { + display_alert "Setting boot partition flags on" "${SDCARD}.raw" "debug" + + # ROM is very particular about boot flags + run_host_command_logged parted "${SDCARD}".raw set 1 boot on + run_host_command_logged parted "${SDCARD}".raw set 1 bls_boot off +} + +function format_partitions() { + # ROM is very particular about partition IDs + run_host_command_logged parted ${LOOP} set 1 lba on +} + +function write_uboot_platform() { + cp $1/tiboot3.bin ${MOUNT}/boot + cp $1/tispl.bin ${MOUNT}/boot + cp $1/u-boot.img ${MOUNT}/boot +}