ce1344a5470e8b74f4a7c6347b6c488e8d898764
[openwrt/openwrt.git] / target / linux / mvebu / image / Makefile
1 #
2 # Copyright (C) 2012-2016 OpenWrt.org
3 # Copyright (C) 2016 LEDE-project.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 JFFS2_BLOCKSIZE = 128k
10
11 include $(TOPDIR)/rules.mk
12 include $(INCLUDE_DIR)/image.mk
13
14 KERNEL_LOADADDR := 0x00008000
15
16 define Build/boot-scr
17 rm -f $@-boot.scr
18 sed \
19 -e 's#@ROOT@#$(IMG_PART_SIGNATURE)#g' \
20 -e 's#@DTB@#$(firstword $(DEVICE_DTS))#g' \
21 $(BOOT_SCRIPT).bootscript > $@-new.bootscript
22 mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $@-new.bootscript $@-boot.scr
23 endef
24
25 define Build/boot-img
26 rm -f $@.boot
27 mkfs.fat -C $@.boot $$(( $(CONFIG_TARGET_KERNEL_PARTSIZE) * 1024 ))
28 $(foreach dts,$(DEVICE_DTS), mcopy -i $@.boot $(KDIR)/image-$(dts).dtb ::$(dts).dtb;)
29 mcopy -i $@.boot $(IMAGE_KERNEL) ::$(KERNEL_NAME)
30 -mcopy -i $@.boot $@-boot.scr ::boot.scr
31 endef
32
33 define Build/boot-img-ext4
34 rm -fR $@.boot
35 mkdir -p $@.boot
36 $(foreach dts,$(DEVICE_DTS), $(CP) $(KDIR)/image-$(dts).dtb $@.boot/$(dts).dtb;)
37 $(CP) $(IMAGE_KERNEL) $@.boot/$(KERNEL_NAME)
38 -$(CP) $@-boot.scr $@.boot/boot.scr
39 make_ext4fs -J -L kernel -l $(CONFIG_TARGET_KERNEL_PARTSIZE)M $@.bootimg $@.boot
40 endef
41
42 define Build/sdcard-img
43 SIGNATURE="$(IMG_PART_SIGNATURE)" \
44 ./gen_mvebu_sdcard_img.sh $@ \
45 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
46 c $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
47 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
48 endef
49
50 define Build/sdcard-img-ext4
51 SIGNATURE="$(IMG_PART_SIGNATURE)" \
52 ./gen_mvebu_sdcard_img.sh $@ \
53 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
54 83 $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.bootimg \
55 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
56 endef
57
58 define Build/omnia-medkit-initramfs
59 $(TAR) -c -T /dev/null -f $@
60 rm -rf $(dir $(IMAGE_KERNEL))boot
61 mkdir -p $(dir $(IMAGE_KERNEL))boot/boot/
62 cp $(KDIR)/zImage-initramfs $(dir $(IMAGE_KERNEL))boot/boot/zImage
63 cp $(KDIR)/image-$(DEVICE_DTS).dtb $(dir $(IMAGE_KERNEL))boot/boot/dtb
64 $(TAR) -rp --numeric-owner --owner=0 --group=0 --sort=name \
65 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
66 --file=$@ -C $(dir $(IMAGE_KERNEL))boot/ .
67 endef
68
69 define Build/uDPU-firmware
70 (rm -fR $@-fw; mkdir -p $@-fw)
71 $(CP) $(BIN_DIR)/$(IMAGE_PREFIX)-initramfs.itb $@-fw/recovery.itb
72 $(CP) $@-boot.scr $@-fw/boot.scr
73 (cd $(TARGET_DIR); $(TAR) -cvzf $@-fw/rootfs.tgz .)
74 (cd $@.boot; $(TAR) -cvzf $@-fw/boot.tgz .)
75 (cd $@-fw; $(TAR) -cvzf $(KDIR_TMP)/$(IMAGE_PREFIX)-firmware.tgz .)
76 endef
77
78 define Device/Default
79 PROFILES := Default
80 BOARD_NAME = $$(DEVICE_DTS)
81 KERNEL_NAME := zImage
82 KERNEL := kernel-bin | append-dtb | uImage none
83 IMAGES := sysupgrade.bin
84 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
85 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
86 SUPPORTED_DEVICES = $(subst _,$(comma),$(1))
87 UBINIZE_OPTS := -E 5
88 UBOOT :=
89 BOOT_SCRIPT :=
90 endef
91 DEVICE_VARS += BOOT_SCRIPT UBOOT
92
93 define Device/Default-arm64
94 BOOT_SCRIPT := generic-arm64
95 DTS_DIR := $(DTS_DIR)/marvell
96 IMAGES := sdcard.img.gz
97 IMAGE/sdcard.img.gz := boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
98 KERNEL_NAME := Image
99 KERNEL := kernel-bin
100 endef
101
102 define Device/NAND-128K
103 BLOCKSIZE := 128k
104 PAGESIZE := 2048
105 SUBPAGESIZE := 512
106 VID_HDR_OFFSET := 2048
107 endef
108
109 define Device/NAND-256K
110 BLOCKSIZE := 256k
111 PAGESIZE := 4096
112 endef
113
114 define Device/NAND-512K
115 BLOCKSIZE := 512k
116 PAGESIZE := 4096
117 endef
118
119 include cortex-a9.mk
120 include cortex-a53.mk
121 include cortex-a72.mk
122
123 $(eval $(call BuildImage))