225 kx
225 kx COMPONENT_TARGETS = $(HARDWARE_ORANGE_PI5)
225 kx
225 kx NEED_ABS_PATH = true
225 kx
225 kx COMPONENT_IS_3PP = true
225 kx
225 kx
225 kx include ../../../../build-system/constants.mk
225 kx
225 kx
225 kx SOURCE_REQUIRES = sources/U-Boot/rkbin
225 kx SOURCE_REQUIRES += sources/U-Boot/OrangePi/u-boot
225 kx
225 kx REQUIRES = boot/kernel/orange-pi5/5.10.110
225 kx
225 kx # ======= __END_OF_REQUIRES__ =======
225 kx
225 kx
225 kx version = 2023.10
225 kx tar_xz_archive = $(SRC_PACKAGE_PATH)/U-Boot/OrangePi/u-boot/u-boot-$(version).tar.xz
225 kx SRC_ARCHIVE = $(tar_xz_archive)
225 kx SRC_DIR = $(TARGET_BUILD_DIR)/u-boot-$(version)
225 kx src_done = $(TARGET_BUILD_DIR)/.source_done
225 kx
225 kx rkbin_version = 20230519
225 kx rkbin_archive = $(SRC_PACKAGE_PATH)/U-Boot/rkbin/rkbin-$(rkbin_version).tar.xz
225 kx RKBIN_SRC_DIR = $(TARGET_BUILD_DIR)/rkbin-$(rkbin_version)
225 kx rkbin_src_done = $(TARGET_BUILD_DIR)/.rkbin-source-done
225 kx
225 kx
225 kx PATCHES = PATCHES
225 kx
225 kx
225 kx bl31 = $(TARGET_DEST_DIR)/bootfs/rk3588_bl31_v1.38.elf
225 kx tpl = $(TARGET_DEST_DIR)/bootfs/rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.11.bin
225 kx
225 kx u_boot = $(TARGET_BUILD_DIR)/.u_boot_done
225 kx u_boot_config = orangepi-5-rk3588s_defconfig
225 kx
225 kx #
225 kx # Image, zImage from Linux kernel package:
225 kx #
225 kx kernel_version = 5.10.110
225 kx linux_Image = $(TARGET_DEST_DIR)/bootfs/Image
225 kx linux_zImage = $(TARGET_DEST_DIR)/bootfs/vmlinuz
225 kx
225 kx #
225 kx # uImage, uzImage for U-Boot (see u-boot-2023.04/include/configs/rk3399_common.h):
225 kx #
225 kx kernel_addr = 0x02080000
225 kx entry_point = $(kernel_addr)
225 kx uImage = $(TARGET_BUILD_DIR)/uImage
225 kx uzImage = $(TARGET_BUILD_DIR)/uzImage
225 kx
225 kx fdt_addr = 0x01f00000
225 kx kernel_comp_addr = 0x08000000
225 kx ramdisk_addr = 0x06000000
225 kx
225 kx #
225 kx # Boot Scripts:
225 kx #
225 kx boot_sdhc_script = $(TARGET_BUILD_DIR)/boot.sdhc.script
225 kx boot_sdhc_scr = $(TARGET_BUILD_DIR)/boot.sdhc.scr
225 kx
225 kx
225 kx boot_records = $(TARGET_BUILD_DIR)/$(HARDWARE).boot-records
225 kx install_boot_records = $(TARGET_BUILD_DIR)/.boot_records_done
225 kx
225 kx
225 kx ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_RK358X_GLIBC)),)
225 kx ARCH = arm64
225 kx endif
225 kx
225 kx USE_TARGET_DEST_DIR_SYSROOT = no
225 kx
225 kx
225 kx ####### Targets
225 kx
225 kx PKG_GROUP = boot
225 kx
225 kx
225 kx UBOOT_BIN_PKG_NAME = u-boot
225 kx UBOOT_BIN_PKG_VERSION = 2023.10
225 kx UBOOT_BIN_PKG_ARCH = $(PKGARCH)
225 kx UBOOT_BIN_PKG_DISTRO_NAME = $(DISTRO_NAME)
225 kx UBOOT_BIN_PKG_DISTRO_VERSION = $(DISTRO_VERSION)
225 kx UBOOT_BIN_PKG_GROUP = $(PKG_GROUP)
225 kx ### |---handy-ruler-------------------------------|
225 kx UBOOT_BIN_PKG_SHORT_DESCRIPTION = Rockchip U-Boot
225 kx UBOOT_BIN_PKG_URL = $(BUG_URL)
225 kx UBOOT_BIN_PKG_LICENSE = custom
225 kx UBOOT_BIN_PKG_DESCRIPTION_FILE = $(TARGET_BUILD_DIR)/$(UBOOT_BIN_PKG_NAME)-pkg-description
225 kx UBOOT_BIN_PKG_DESCRIPTION_FILE_IN = $(UBOOT_BIN_PKG_NAME)-pkg-description.in
225 kx UBOOT_BIN_PKG_INSTALL_SCRIPT = $(UBOOT_BIN_PKG_NAME)-pkg-install.sh
225 kx
225 kx UBOOT_BIN_PKG = $(CURDIR)/$(TARGET_BUILD_DIR)/$(UBOOT_BIN_PKG_NAME)-package
225 kx
225 kx build_uboot_pkg = $(TARGET_BUILD_DIR)/.u_boot_pkg_done
225 kx
225 kx pkg_basename = $(UBOOT_BIN_PKG_NAME)-$(UBOOT_BIN_PKG_VERSION)-$(UBOOT_BIN_PKG_ARCH)-$(UBOOT_BIN_PKG_DISTRO_NAME)-$(UBOOT_BIN_PKG_DISTRO_VERSION)
225 kx
225 kx pkg_archive = $(TARGET_BUILD_DIR)/$(PKG_GROUP)/$(pkg_basename).$(pkg_arch_suffix)
225 kx
225 kx pkg_certificate = $(call cert-name,$(pkg_archive))
225 kx pkg_signature = $(call sign-name,$(pkg_archive))
225 kx pkg_description = $(call desc-name,$(pkg_archive))
225 kx products = $(call pkg-files,$(pkg_archive))
225 kx
225 kx BUILD_TARGETS = $(bl31)
225 kx BUILD_TARGETS += $(tpl)
225 kx BUILD_TARGETS += $(u_boot)
225 kx BUILD_TARGETS += $(uImage)
225 kx BUILD_TARGETS += $(uzImage)
225 kx BUILD_TARGETS += $(boot_sdhc_script)
225 kx BUILD_TARGETS += $(boot_sdhc_scr)
225 kx BUILD_TARGETS += $(build_uboot_pkg)
225 kx BUILD_TARGETS += $(install_boot_records)
225 kx
225 kx PRODUCT_TARGETS = $(products)
225 kx
225 kx ROOTFS_TARGETS = $(pkg_archive)
225 kx
225 kx
225 kx include ../../../../build-system/core.mk
225 kx
225 kx
225 kx HOST_TOOLS_SETTINGS = PYTHON3=/usr/bin/python3 HOSTLDFLAGS='-L/usr/lib64' HOSTCFLAGS='-I/usr/include'
225 kx
225 kx device_dtb = rk3588s-orangepi-5.dtb
225 kx
225 kx #
225 kx # Extra kernel boot arguments:
225 kx #
225 kx extra = consoleblank=0
225 kx extra += no_console_suspend
225 kx
225 kx
225 kx ####### Dependencies
225 kx
225 kx
225 kx $(rkbin_src_done): $(rkbin_archive)
225 kx @echo "Expanding $(rkbin_archive)"
225 kx @tar xJf $(rkbin_archive) -C $(TARGET_BUILD_DIR)
225 kx @touch $@
225 kx
225 kx $(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP) $(rkbin_src_done)
225 kx $(UNPACK_SRC_ARCHIVE)
225 kx $(APPLY_PATCHES)
225 kx @( cd $(SRC_DIR)/configs ; \
225 kx echo '# Set BOOTDELAY options:' >> $(u_boot_config) ; \
225 kx echo 'CONFIG_SYS_PROMPT="$(HARDWARE)# "' >> $(u_boot_config) ; \
225 kx echo 'CONFIG_BOOTDELAY=3' >> $(u_boot_config) ; \
225 kx echo 'CONFIG_AUTOBOOT_KEYED=y' >> $(u_boot_config) ; \
225 kx echo 'CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n"' >> $(u_boot_config) ; \
225 kx echo 'CONFIG_AUTOBOOT_STOP_STR=" "' >> $(u_boot_config) ; \
225 kx )
225 kx # ======= Suppress '_elf.so has a LOAD segment with RWX permissions' warnings =======
225 kx @( cd $(SRC_DIR) ; \
225 kx sed -i 's,^\(KBUILD_LDFLAGS[ \t]*:=\).*,\1 --no-warn-rwx-segments,' Makefile ; \
225 kx sed -i 's,^\(cmd_efi_ld = $$(LD)\),\1 --no-warn-rwx-segments,' scripts/Makefile.lib ; \
225 kx )
225 kx @touch $@
225 kx
225 kx $(bl31): $(src_done)
225 kx @cp -a $(RKBIN_SRC_DIR)/bin/rk35/rk3588_bl31_v1.38.elf $@
225 kx
225 kx $(tpl): $(src_done)
225 kx @cp -a $(RKBIN_SRC_DIR)/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.11.bin $@
225 kx
225 kx UMAKE := $(HOST_TOOLS_SETTINGS) $(MAKE) -C $(SRC_DIR) BL31=$(bl31) ROCKCHIP_TPL=$(tpl) CROSS_COMPILE='$(CROSS_PREFIX)'
225 kx
225 kx $(u_boot): $(bl31) $(tpl)
225 kx +$(UMAKE) $(u_boot_config)
225 kx +$(UMAKE)
225 kx @touch $@
225 kx
225 kx $(uImage): $(u_boot)
225 kx $(CURDIR)/$(SRC_DIR)/tools/mkimage \
225 kx -A $(ARCH) -O linux -T kernel -C none -a $(kernel_addr) -e $(entry_point) \
225 kx -n $(kernel_version) -d $(linux_Image) $@
225 kx
225 kx $(uzImage): $(u_boot)
225 kx $(CURDIR)/$(SRC_DIR)/tools/mkimage \
225 kx -A $(ARCH) -O linux -T kernel -C lzma -a $(kernel_addr) -e $(entry_point) \
225 kx -n $(kernel_version) -d $(linux_zImage) $@
225 kx
225 kx #
225 kx # NOTE:
225 kx # ====
225 kx # sdhc is always mmc0 in u-boot and mmcblk0 in kernel
225 kx #
225 kx
225 kx $(boot_sdhc_script): $(uzImage)
225 kx @( echo "" > $(boot_sdhc_script) && \
225 kx echo "mmc dev 0" >> $(boot_sdhc_script) && \
225 kx echo "mmcinfo" >> $(boot_sdhc_script) && \
225 kx echo "ext4load mmc 0:1 \$${kernel_comp_addr_r} /boot/uzImage" >> $(boot_sdhc_script) && \
225 kx echo "ext4load mmc 0:1 \$${fdt_addr_r} /boot/rockchip/$(device_dtb)" >> $(boot_sdhc_script) && \
225 kx echo "setenv bootargs 'earlyprintk console=ttyS2,1500000n8 console=tty1 ro root=/dev/mmcblk0p1 rootwait rootfstype=ext4 $(extra)'" >> $(boot_sdhc_script) && \
225 kx echo "bootm \$${kernel_comp_addr_r} - \$${fdt_addr_r}" >> $(boot_sdhc_script) \
225 kx )
225 kx
225 kx $(boot_sdhc_scr): $(boot_sdhc_script)
225 kx $(CURDIR)/$(SRC_DIR)/tools/mkimage -A $(ARCH) -T script -C none -n "Boot Script" -d $< $@
225 kx
225 kx $(build_uboot_pkg): $(boot_sdhc_scr)
225 kx @mkdir -p $(TARGET_DEST_DIR)/bootfs/u-boot
225 kx @mkdir -p $(UBOOT_BIN_PKG)/boot/u-boot
225 kx # ======= install U-Boot images =======
225 kx @cp -a $(SRC_DIR)/idbloader.img $(SRC_DIR)/u-boot.itb $(UBOOT_BIN_PKG)/boot/u-boot
225 kx # ======= install signed kernel and script images =======
225 kx @cp -a $(uImage) $(uzImage) $(boot_sdhc_scr) $(UBOOT_BIN_PKG)/boot
225 kx @( cd $(UBOOT_BIN_PKG)/boot ; \
225 kx ln -sf boot.sdhc.scr boot.scr ; \
225 kx )
225 kx # ======= install-u-boot service script =======
225 kx @cp $(CURDIR)/scripts/install-u-boot $(UBOOT_BIN_PKG)/boot/u-boot
225 kx @chmod 755 $(UBOOT_BIN_PKG)/boot/u-boot/install-u-boot
225 kx # ======= copy U-Boot images and binaries into devenv =======
225 kx @cp -a $(uImage) $(uzImage) $(boot_sdhc_scr) $(TARGET_DEST_DIR)/bootfs
225 kx @cp -a $(SRC_DIR)/idbloader.img $(SRC_DIR)/u-boot.itb $(TARGET_DEST_DIR)/bootfs/u-boot
225 kx # ======= install Documentation =======
225 kx @mkdir -p $(UBOOT_BIN_PKG)/usr/doc/u-boot-$(version)
225 kx @cp -a $(SRC_DIR)/Licenses $(SRC_DIR)/MAINTAINERS $(SRC_DIR)/README \
225 kx $(UBOOT_BIN_PKG)/usr/doc/u-boot-$(version)
225 kx @touch $@
225 kx
225 kx $(boot_records): $(build_uboot_pkg)
225 kx @$(DD) if=/dev/zero of=$@ bs=512 count=32768 conv=notrunc
225 kx # ======= Setup u-boot into unallocated space of disk image =======
225 kx @$(DD) if=$(UBOOT_BIN_PKG)/boot/u-boot/idbloader.img of=$@ bs=512 seek=64 conv=notrunc
225 kx @$(DD) if=$(UBOOT_BIN_PKG)/boot/u-boot/u-boot.itb of=$@ bs=512 seek=16384 conv=notrunc
225 kx @touch $@
225 kx
225 kx $(install_boot_records): $(boot_records)
225 kx @$(BUILDSYSTEM)/install_targets \
225 kx --destination=$(PRODUCTS_DEST_DIR) \
225 kx --toolchain=$(TOOLCHAIN) \
225 kx --hardware=$(HARDWARE) \
225 kx --flavour=$(FLAVOUR) \
225 kx $^
225 kx @touch $@
225 kx
225 kx $(UBOOT_BIN_PKG_DESCRIPTION_FILE): $(UBOOT_BIN_PKG_DESCRIPTION_FILE_IN)
225 kx @cat $< | $(SED) -e "s/@VERSION@/$(UBOOT_BIN_PKG_VERSION)/g" | \
225 kx $(SED) -e "s/@HARDWARE_SPEC@/$(HW_SPEC)/g"> $@
225 kx
225 kx $(pkg_certificate) : $(pkg_archive) ;
225 kx $(pkg_signature) : $(pkg_archive) ;
225 kx $(pkg_description) : $(pkg_archive) ;
225 kx
225 kx $(pkg_archive): $(install_boot_records) $(UBOOT_BIN_PKG_DESCRIPTION_FILE) $(UBOOT_BIN_PKG_INSTALL_SCRIPT)
225 kx @cp $(UBOOT_BIN_PKG_DESCRIPTION_FILE) $(UBOOT_BIN_PKG)/.DESCRIPTION
225 kx @cp $(UBOOT_BIN_PKG_INSTALL_SCRIPT) $(UBOOT_BIN_PKG)/.INSTALL
225 kx @chmod a+x $(UBOOT_BIN_PKG)/.INSTALL
225 kx @$(BUILD_PKG_REQUIRES) $(UBOOT_BIN_PKG)/.REQUIRES
225 kx @echo "pkgname=$(UBOOT_BIN_PKG_NAME)" > $(UBOOT_BIN_PKG)/.PKGINFO ; \
225 kx echo "pkgver=$(UBOOT_BIN_PKG_VERSION)" >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
225 kx echo "arch=$(UBOOT_BIN_PKG_ARCH)" >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
225 kx echo "distroname=$(UBOOT_BIN_PKG_DISTRO_NAME)" >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
225 kx echo "distrover=$(UBOOT_BIN_PKG_DISTRO_VERSION)" >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
225 kx echo "group=$(UBOOT_BIN_PKG_GROUP)" >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
225 kx echo "short_description=\"$(UBOOT_BIN_PKG_SHORT_DESCRIPTION)\"" >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
225 kx echo "url=$(UBOOT_BIN_PKG_URL)" >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
225 kx echo "license=$(UBOOT_BIN_PKG_LICENSE)" >> $(UBOOT_BIN_PKG)/.PKGINFO
225 kx @$(PSEUDO) sh -c "cd $(UBOOT_BIN_PKG) && \
225 kx chown -R root:root . && \
225 kx $(MAKE_PACKAGE) -J --linkadd=yes $(GNUPG_OPTIONS) -m -d .. ."