distribution/projects/Rockchip/packages/u-boot/package.mk

93 lines
3.3 KiB
Makefile
Raw Normal View History

2022-02-05 14:23:32 +00:00
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
2022-05-27 22:33:28 +00:00
# Copyright (C) 2022-present Fewtarius
2022-02-05 14:23:32 +00:00
PKG_NAME="u-boot"
PKG_ARCH="arm aarch64"
PKG_LICENSE="GPL"
2022-07-23 17:56:47 +00:00
PKG_SITE="https://github.com/JustEnoughLinuxOS"
2022-02-05 14:23:32 +00:00
PKG_DEPENDS_TARGET="toolchain swig:host rkbin"
PKG_LONGDESC="Rockchip U-Boot is a bootloader for embedded systems."
GET_HANDLER_SUPPORT="git"
2022-05-27 22:33:28 +00:00
PKG_PATCH_DIRS+="${DEVICE}"
2022-02-05 14:23:32 +00:00
2022-07-23 17:56:47 +00:00
case ${DEVICE} in
RG351P|RG351V|RG351MP)
PKG_URL="${PKG_SITE}/rk3326-uboot.git"
PKG_VERSION="9f8c2e3936"
;;
RG552)
PKG_URL="${PKG_SITE}/rk3399-uboot.git"
2022-08-30 21:48:12 +00:00
PKG_VERSION="b2b3fa8268"
2022-07-23 17:56:47 +00:00
;;
RG353P|RG503)
PKG_URL="${PKG_SITE}/rk356x-uboot.git"
2022-07-29 11:40:00 +00:00
PKG_VERSION="ab7b555"
2022-07-23 17:56:47 +00:00
;;
esac
2022-05-27 22:33:28 +00:00
2022-02-05 14:23:32 +00:00
PKG_IS_KERNEL_PKG="yes"
2022-03-26 14:07:10 +00:00
PKG_STAMP="${UBOOT_CONFIG}"
2022-02-05 14:23:32 +00:00
[ -n "${ATF_PLATFORM}" ] && PKG_DEPENDS_TARGET+=" atf"
2022-02-05 14:23:32 +00:00
PKG_NEED_UNPACK="${PROJECT}_DIR/${PROJECT}/bootloader"
[ -n "${DEVICE}" ] && PKG_NEED_UNPACK+=" ${PROJECT}_DIR/${PROJECT}/devices/${DEVICE}/bootloader"
2022-02-05 14:23:32 +00:00
post_patch() {
2022-03-26 14:07:10 +00:00
if [ -n "${UBOOT_CONFIG}" ] && find_file_path bootloader/config; then
PKG_CONFIG_FILE="${UBOOT_CONFIG}"
2022-05-27 22:33:28 +00:00
if [ -f "${PKG_CONFIG_FILE}" ]; then
cat ${FOUND_PATH} >> "${PKG_CONFIG_FILE}"
2022-02-05 14:23:32 +00:00
fi
fi
}
make_target() {
2022-05-27 22:33:28 +00:00
. ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/options
2022-03-26 14:07:10 +00:00
if [ -z "${UBOOT_CONFIG}" ]; then
echo "UBOOT_CONFIG must be set to build an image"
2022-02-05 14:23:32 +00:00
else
2022-07-23 12:26:43 +00:00
if [ -e "${PROJECT_DIR}/projects/${PROJECT}/devices/${DEVICE}/u-boot/${UBOOT_CONFIG}" ]
2022-05-27 22:33:28 +00:00
then
2022-07-13 10:45:17 +00:00
cp ${PROJECT_DIR}/projects/${PROJECT}/devices/${DEVICE}/u-boot/${UBOOT_CONFIG} configs
2022-05-27 22:33:28 +00:00
fi
2022-02-05 14:23:32 +00:00
[ "${BUILD_WITH_DEBUG}" = "yes" ] && PKG_DEBUG=1 || PKG_DEBUG=0
2022-05-27 22:33:28 +00:00
if [ "${PKG_SOC}" = "rk356x" ]
then
cd ${PKG_BUILD}
2022-06-07 23:00:45 +00:00
git checkout make.sh
2022-05-27 22:33:28 +00:00
echo "Making for GPT (${UBOOT_DTB})..."
sed -i "s|TOOLCHAIN_ARM64=.*|TOOLCHAIN_ARM64=${TOOLCHAIN}/bin|" make.sh
sed -i "s|aarch64-linux-gnu|${TARGET_NAME}|g" make.sh
sed -i "s|../rkbin|$(get_build_dir rkbin)|" make.sh
./make.sh ${UBOOT_DTB}
else
echo "Building for MBR (${UBOOT_DTB})..."
[ -n "${ATF_PLATFORM}" ] && cp -av $(get_build_dir atf)/bl31.bin .
DEBUG=${PKG_DEBUG} CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="" ARCH=arm make mrproper
DEBUG=${PKG_DEBUG} CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="" ARCH=arm make ${UBOOT_CONFIG}
DEBUG=${PKG_DEBUG} CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="" ARCH=arm _python_sysroot="${TOOLCHAIN}" _python_prefix=/ _python_exec_prefix=/ make HOSTCC="$HOST_CC" HOSTLDFLAGS="-L${TOOLCHAIN}/lib" HOSTSTRIP="true" CONFIG_MKIMAGE_DTC_PATH="scripts/dtc/dtc"
fi
2022-02-05 14:23:32 +00:00
fi
}
makeinstall_target() {
mkdir -p ${INSTALL}/usr/share/bootloader
2022-02-05 14:23:32 +00:00
# Only install u-boot.img et al when building a board specific image
2022-03-26 14:07:10 +00:00
if [ -n "${UBOOT_CONFIG}" ]; then
2022-02-05 14:23:32 +00:00
find_file_path bootloader/install && . ${FOUND_PATH}
fi
# Always install the update script
find_file_path bootloader/update.sh && cp -av ${FOUND_PATH} ${INSTALL}/usr/share/bootloader
2022-02-05 14:23:32 +00:00
# Always install the canupdate script
if find_file_path bootloader/canupdate.sh; then
cp -av ${FOUND_PATH} ${INSTALL}/usr/share/bootloader
sed -e "s/@PROJECT@/${DEVICE:-${PROJECT}}/g" \
-i ${INSTALL}/usr/share/bootloader/canupdate.sh
2022-02-05 14:23:32 +00:00
fi
}