2 # Copyright (C) 2012-2016 OpenWrt.org
3 # Copyright (C) 2016 LEDE-project.org
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
11 include $(TOPDIR)/rules.mk
12 include $(INCLUDE_DIR)/image.mk
14 DEVICE_VARS += BOOT_SCRIPT UBOOT
15 KERNEL_LOADADDR := 0x00008000
20 -e 's#@ROOT@#$(IMG_PART_SIGNATURE)#g' \
21 -e 's#@DTB@#$(firstword $(DEVICE_DTS))#g' \
22 $(BOOT_SCRIPT).bootscript > $@-new.bootscript
23 mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $@-new.bootscript $@-boot.scr
28 mkfs.fat -C $@.boot $$(( $(CONFIG_TARGET_KERNEL_PARTSIZE) * 1024 ))
29 $(foreach dts,$(DEVICE_DTS), mcopy -i $@.boot $(KDIR)/image-$(dts).dtb ::$(dts).dtb;)
30 mcopy -i $@.boot $(IMAGE_KERNEL) ::$(KERNEL_NAME)
31 -mcopy -i $@.boot $@-boot.scr ::boot.scr
34 define Build/boot-img-ext4
37 $(foreach dts,$(DEVICE_DTS), $(CP) $(KDIR)/image-$(dts).dtb $@.boot/$(dts).dtb;)
38 $(CP) $(IMAGE_KERNEL) $@.boot/$(KERNEL_NAME)
39 -$(CP) $@-boot.scr $@.boot/boot.scr
40 make_ext4fs -J -L kernel -l $(CONFIG_TARGET_KERNEL_PARTSIZE)M $@.bootimg $@.boot
43 define Build/buffalo-kernel-jffs2
44 rm -rf $(KDIR)/kernel_jffs2 $@.fakerd
45 mkdir -p $(KDIR)/kernel_jffs2
46 dd if=/dev/zero of=$@.fakerd bs=131008 count=1 conv=sync
47 $(STAGING_DIR_HOST)/bin/mkimage \
48 -T ramdisk -A $(LINUX_KARCH) -O linux -C gzip -n 'fake initrd' \
49 -d $@.fakerd $(KDIR)/kernel_jffs2/initrd.buffalo
50 cp $@ $(KDIR)/kernel_jffs2/uImage.buffalo
51 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 \
52 --little-endian -v --squash-uids -q -f -n -x lzma -x rtime -m none \
53 --eraseblock=128KiB --pad=$(KERNEL_SIZE) -d $(KDIR)/kernel_jffs2 -o $@
54 rm -rf $(KDIR)/kernel_jffs2 $@.fakerd
57 define Build/sdcard-img
58 SIGNATURE="$(IMG_PART_SIGNATURE)" \
59 ./gen_mvebu_sdcard_img.sh $@ \
60 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
61 c $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
62 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
65 define Build/sdcard-img-ext4
66 SIGNATURE="$(IMG_PART_SIGNATURE)" \
67 ./gen_mvebu_sdcard_img.sh $@ \
68 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
69 83 $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.bootimg \
70 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
73 define Build/omnia-medkit-initramfs
74 $(TAR) -c -T /dev/null -f $@
75 rm -rf $(dir $(IMAGE_KERNEL))boot
76 mkdir -p $(dir $(IMAGE_KERNEL))boot/boot/
77 cp $(KDIR)/zImage-initramfs $(dir $(IMAGE_KERNEL))boot/boot/zImage
78 cp $(KDIR)/image-$(DEVICE_DTS).dtb $(dir $(IMAGE_KERNEL))boot/boot/dtb
79 $(TAR) -rp --numeric-owner --owner=0 --group=0 --sort=name \
80 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
81 --file=$@ -C $(dir $(IMAGE_KERNEL))boot/ .
84 define Build/uDPU-firmware
85 (rm -fR $@-fw; mkdir -p $@-fw)
86 $(CP) $(BIN_DIR)/$(IMAGE_PREFIX)-initramfs.itb $@-fw/recovery.itb
87 $(CP) $@-boot.scr $@-fw/boot.scr
88 $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
89 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
90 -f $@-fw/rootfs.tgz -C $(TARGET_DIR) .
91 $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
92 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
93 -f $@-fw/boot.tgz -C $@.boot .
94 $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
95 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
96 -f $(KDIR_TMP)/$(IMAGE_PREFIX)-firmware.tgz -C $@-fw .
101 DEVICE_DTS = $$(SOC)-$(lastword $(subst _, ,$(1)))
102 DEVICE_DTS_DIR := $(DTS_DIR)
103 BOARD_NAME = $$(DEVICE_DTS)
104 KERNEL_NAME := zImage
105 KERNEL := kernel-bin | append-dtb | uImage none
106 IMAGES := sysupgrade.bin
107 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
108 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
109 SUPPORTED_DEVICES = $(subst _,$(comma),$(1))
115 define Device/Default-arm64
116 BOOT_SCRIPT := generic-arm64
117 DEVICE_DTS_DIR := $(DTS_DIR)/marvell
118 IMAGES := sdcard.img.gz
119 IMAGE/sdcard.img.gz := boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
124 define Device/NAND-128K
128 VID_HDR_OFFSET := 2048
131 define Device/NAND-256K
136 define Device/NAND-512K
141 include $(SUBTARGET).mk
143 $(eval $(call BuildImage))