rockchip: move image generation command to default
[openwrt/staging/hauke.git] / target / linux / rockchip / image / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2
3 include $(TOPDIR)/rules.mk
4 include $(INCLUDE_DIR)/image.mk
5
6 DEVICE_VARS += UBOOT_DEVICE_NAME
7
8 define Build/Compile
9 $(CP) $(LINUX_DIR)/COPYING $(KDIR)/COPYING.linux
10 endef
11
12 ### Image scripts ###
13 define Build/boot-common
14 # This creates a new folder copies the dtb (as rockchip.dtb)
15 # and the kernel image (as kernel.img)
16 rm -fR $@.boot
17 mkdir -p $@.boot
18
19 $(CP) $(IMAGE_KERNEL) $@.boot/kernel.img
20 endef
21
22 define Build/boot-script
23 # Make an U-boot image and copy it to the boot partition
24 mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $(if $(1),$(1),mmc).bootscript $@.boot/boot.scr
25 endef
26
27 define Build/pine64-img
28 # Creates the final SD/eMMC images,
29 # combining boot partition, root partition as well as the u-boot bootloader
30
31 # Generate a new partition table in $@ with 32 MiB of
32 # alignment padding for the idbloader and u-boot to fit:
33 # http://opensource.rock-chips.com/wiki_Boot_option#Boot_flow
34 #
35 # U-Boot SPL expects the U-Boot ITB to be located at sector 0x4000 (8 MiB) on the MMC storage
36 PADDING=1 $(SCRIPT_DIR)/gen_image_generic.sh \
37 $@ \
38 $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
39 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
40 32768
41
42 # Copy the idbloader and the u-boot image to the image at sector 0x40 and 0x4000
43 dd if="$(STAGING_DIR_IMAGE)"/$(UBOOT_DEVICE_NAME)-idbloader.img of="$@" seek=64 conv=notrunc
44 dd if="$(STAGING_DIR_IMAGE)"/$(UBOOT_DEVICE_NAME)-u-boot.itb of="$@" seek=16384 conv=notrunc
45 endef
46
47 ### Devices ###
48 define Device/Default
49 PROFILES := Default
50 KERNEL = kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb
51 BOOT_SCRIPT :=
52 IMAGES := sysupgrade.img.gz
53 IMAGE/sysupgrade.img.gz = boot-common | boot-script $$(BOOT_SCRIPT) | pine64-img | gzip | append-metadata
54 DEVICE_DTS = rockchip/$$(SOC)-$(lastword $(subst _, ,$(1)))
55 UBOOT_DEVICE_NAME = $(lastword $(subst _, ,$(1)))-$$(SOC)
56 endef
57
58 include $(SUBTARGET).mk
59
60 $(eval $(call BuildImage))