2021-02-10 14:52:34 +01:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
2020-04-12 13:57:25 +02:00
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
include $(INCLUDE_DIR)/image.mk
|
|
|
|
|
|
|
|
DEVICE_VARS += UBOOT_DEVICE_NAME
|
|
|
|
|
|
|
|
define Build/Compile
|
|
|
|
$(CP) $(LINUX_DIR)/COPYING $(KDIR)/COPYING.linux
|
|
|
|
endef
|
|
|
|
|
|
|
|
### Image scripts ###
|
|
|
|
define Build/boot-common
|
|
|
|
# This creates a new folder copies the dtb (as rockchip.dtb)
|
|
|
|
# and the kernel image (as kernel.img)
|
|
|
|
rm -fR $@.boot
|
|
|
|
mkdir -p $@.boot
|
|
|
|
|
|
|
|
$(CP) $(DTS_DIR)/$(DEVICE_DTS).dtb $@.boot/rockchip.dtb
|
|
|
|
$(CP) $(IMAGE_KERNEL) $@.boot/kernel.img
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/boot-script
|
|
|
|
# Make an U-boot image and copy it to the boot partition
|
2020-12-20 12:49:38 +08:00
|
|
|
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $(if $(1),$(1),mmc).bootscript $@.boot/boot.scr
|
2020-04-12 13:57:25 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/pine64-img
|
|
|
|
# Creates the final SD/eMMC images,
|
|
|
|
# combining boot partition, root partition as well as the u-boot bootloader
|
|
|
|
|
|
|
|
# Generate a new partition table in $@ with 32 MiB of
|
|
|
|
# alignment padding for the idbloader and u-boot to fit:
|
|
|
|
# http://opensource.rock-chips.com/wiki_Boot_option#Boot_flow
|
|
|
|
#
|
|
|
|
# U-Boot SPL expects the U-Boot ITB to be located at sector 0x4000 (8 MiB) on the MMC storage
|
2021-09-23 21:01:37 +02:00
|
|
|
PADDING=1 $(SCRIPT_DIR)/gen_image_generic.sh \
|
2020-04-12 13:57:25 +02:00
|
|
|
$@ \
|
|
|
|
$(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
|
|
|
|
$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
|
|
|
|
32768
|
|
|
|
|
|
|
|
# Copy the idbloader and the u-boot image to the image at sector 0x40 and 0x4000
|
|
|
|
dd if="$(STAGING_DIR_IMAGE)"/$(UBOOT_DEVICE_NAME)-idbloader.img of="$@" seek=64 conv=notrunc
|
|
|
|
dd if="$(STAGING_DIR_IMAGE)"/$(UBOOT_DEVICE_NAME)-u-boot.itb of="$@" seek=16384 conv=notrunc
|
|
|
|
endef
|
|
|
|
|
2021-03-05 16:55:17 +08:00
|
|
|
define Build/pine64-bin
|
2021-03-08 12:00:17 +08:00
|
|
|
# Typical Rockchip boot flow with Rockchip miniloader
|
|
|
|
# Rockchp idbLoader which is combinded by Rockchip ddr init bin
|
|
|
|
# and miniloader bin from Rockchip rkbin project
|
2021-03-05 16:55:17 +08:00
|
|
|
|
2021-03-08 12:00:17 +08:00
|
|
|
# Generate a new partition table in $@ with 32 MiB of alignment
|
|
|
|
# padding for the idbloader, uboot and trust image to fit:
|
|
|
|
# http://opensource.rock-chips.com/wiki_Boot_option#Boot_flow
|
2021-09-26 11:43:58 +08:00
|
|
|
PADDING=1 $(SCRIPT_DIR)/gen_image_generic.sh \
|
2021-03-05 16:55:17 +08:00
|
|
|
$@ \
|
|
|
|
$(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
|
|
|
|
$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
|
|
|
|
32768
|
|
|
|
|
2021-03-08 12:00:17 +08:00
|
|
|
# Copy the idbloader, uboot and trust image to the image at sector 0x40, 0x4000 and 0x6000
|
2021-08-12 23:51:19 +08:00
|
|
|
dd if="$(STAGING_DIR_IMAGE)"/$(SOC)-idbloader.bin of="$@" seek=64 conv=notrunc
|
2021-03-05 16:55:17 +08:00
|
|
|
dd if="$(STAGING_DIR_IMAGE)"/$(UBOOT_DEVICE_NAME)-uboot.img of="$@" seek=16384 conv=notrunc
|
2021-08-12 23:51:19 +08:00
|
|
|
dd if="$(STAGING_DIR_IMAGE)"/$(SOC)-trust.bin of="$@" seek=24576 conv=notrunc
|
2021-03-05 16:55:17 +08:00
|
|
|
endef
|
|
|
|
|
2020-04-12 13:57:25 +02:00
|
|
|
### Devices ###
|
|
|
|
define Device/Default
|
|
|
|
PROFILES := Default
|
|
|
|
KERNEL := kernel-bin
|
|
|
|
IMAGES := sysupgrade.img.gz
|
|
|
|
DEVICE_DTS = rockchip/$$(SOC)-$(lastword $(subst _, ,$(1)))
|
|
|
|
endef
|
|
|
|
|
2020-06-07 13:11:15 +02:00
|
|
|
include $(SUBTARGET).mk
|
2020-04-12 13:57:25 +02:00
|
|
|
|
|
|
|
$(eval $(call BuildImage))
|