build/config/sources/families/meson-s4t7.conf

102 lines
4.0 KiB
Plaintext

#
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2023 Ricardo Pardini <ricardo@pardini.net>
# This file is a part of the Armbian Build Framework https://github.com/armbian/build/
#
declare -g LINUXFAMILY="meson-s4t7"
declare -g ARCH="arm64"
declare -g ATF_COMPILE="no"
# Determine kernel
case $BRANCH in
legacy)
declare -g KERNEL_MAJOR_MINOR="5.4" # Major and minor versions of this kernel. For mainline caching.
declare -g KERNELSOURCE="https://github.com/khadas/linux.git" # Khadas kernel
declare -g KERNELBRANCH="branch:khadas-vims-5.4.y" # Branch or tag to build from. It should match MAJOR_MINOR
declare -g KERNELPATCHDIR='archive/meson-s4t7-5.4'
;;
esac
# Lets build uboot from source
BOOTSOURCE="https://github.com/khadas/u-boot.git"
BOOTBRANCH="branch:khadas-vims-v2019.01"
BOOTENV_FILE='meson.txt'
BOOTSCRIPT="boot-meson-s4t7.cmd:boot.cmd"
UBOOT_TARGET_MAP=";;build/u-boot.bin.sd.bin.signed:u-boot.bin.sd.bin.signed build/u-boot.bin.signed:u-boot.bin.signed"
## funny enough, the uboot+fip blobs go in the same spot as normal meson64...
function write_uboot_platform() {
dd if="$1/u-boot.bin.sd.bin.signed" of="$2" conv=fsync,notrunc bs=442 count=1 #> /dev/null 2>&1
dd if="$1/u-boot.bin.sd.bin.signed" of="$2" conv=fsync,notrunc bs=512 skip=1 seek=1 #> /dev/null 2>&1
}
# We'll need xxd to build the fip blobs
function add_host_dependencies__khadas_fips_needs_xxd() {
display_alert "Adding xxd to host dependencies" "for khadas bootloader compile" "debug"
declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} xxd"
}
# To be able to build the fip blobs, we need a riscv toolchain.
function pre_config_uboot_target__prepare_riscv_toolchain() {
display_alert "$BOARD" "preparing riscv toolchain for bootloader fip" "info"
declare tos="x64"
[[ "${HOSTARCH}" == "arm64" ]] && tos="arm64"
[[ "${HOSTARCH}" == "armhf" ]] && tos="arm"
declare tversion="8.3.0-1.2"
declare tbasedir="${SRC}/cache/toolchain"
declare tdir="${tbasedir}/xpack-riscv-none-embed-gcc-${tversion}"
declare tfile="xpack-riscv-none-embed-gcc-${tversion}-linux-${tos}.tar.gz"
declare turl="https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v${tversion}/${tfile}"
mkdir -p "${tbasedir}"
if [[ ! -d "${tdir}" ]]; then
run_host_command_logged wget --progress=dot:giga -O "${tbasedir}/${tfile}" "${turl}"
run_host_command_logged tar -C "${tbasedir}" -xzf "${tbasedir}/${tfile}"
run_host_command_logged rm -fv "${tbasedir}/${tfile}"
fi
# Symlinks are not enough: riscv-none-embed-ld: cannot find -lgcc, So we need to add the toolchain to the PATH
declare -g -r PRE_TOOLCHAIN_PATH="${PATH}"
export PATH="${tdir}/bin:${PATH}"
}
function post_config_uboot_target__downgrade_errors_to_warnings() {
uboot_cflags_array+=("-Wno-error=array-bounds")
return 0
}
# Invoke fip build script after the u-boot target
function post_uboot_custom_postprocess__build_fip() {
: "${uboot_work_dir:?uboot_work_dir not set}"
: "${KHADAS_BOARD_ID:?KHADAS_BOARD_ID not set}"
display_alert "$BOARD" "building fip" "info"
cd "${uboot_work_dir}" || exit_with_error "cray-cray about ${uboot_work_dir}"
run_host_command_logged bash fip/mk_script.sh "${KHADAS_BOARD_ID}" "${uboot_work_dir}"
return 0
}
function pre_package_kernel_image__copy_meson_s4t7_overlays() {
display_alert "Copy meson s4t7 overlays"
declare dtbo_destination="${tmp_kernel_install_dirs[INSTALL_DTBS_PATH]}"/amlogic
run_host_command_logged cp -r ${SRC}/patch/kernel/${KERNELPATCHDIR}/overlay ${dtbo_destination}/
display_alert "Enable Device Tree Overlays"
run_host_command_logged ln -sf amlogic/overlay "${tmp_kernel_install_dirs[INSTALL_DTBS_PATH]}"/overlay
}
function post_family_tweaks_bsp__disable_uinitrd_generation() {
if [[ -f "${destination}"/etc/initramfs/post-update.d/99-uboot ]]; then
run_host_command_logged rm "${destination}"/etc/initramfs/post-update.d/99-uboot
fi
}
function pre_update_initramfs__change_initrd_compression() {
run_host_command_logged sed -i 's/COMPRESS=.*/COMPRESS=xz/g' $MOUNT/etc/initramfs-tools/initramfs.conf
}