024e77969ac4ce5505aeed50e931000686001ef7
[openwrt/staging/mkresin.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 $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
74 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
75 -f $@-fw/rootfs.tgz -C $(TARGET_DIR) .
76 $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
77 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
78 -f $@-fw/boot.tgz -C $@.boot .
79 $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
80 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
81 -f $(KDIR_TMP)/$(IMAGE_PREFIX)-firmware.tgz -C $@-fw .
82 endef
83
84 define Device/Default
85 PROFILES := Default
86 DEVICE_DTS = $$(SOC)-$(lastword $(subst _, ,$(1)))
87 DEVICE_DTS_DIR := $(DTS_DIR)
88 BOARD_NAME = $$(DEVICE_DTS)
89 KERNEL_NAME := zImage
90 KERNEL := kernel-bin | append-dtb | uImage none
91 IMAGES := sysupgrade.bin
92 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
93 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
94 SUPPORTED_DEVICES = $(subst _,$(comma),$(1))
95 UBINIZE_OPTS := -E 5
96 UBOOT :=
97 BOOT_SCRIPT :=
98 endef
99 DEVICE_VARS += BOOT_SCRIPT UBOOT
100
101 define Device/Default-arm64
102 BOOT_SCRIPT := generic-arm64
103 DEVICE_DTS_DIR := $(DTS_DIR)/marvell
104 IMAGES := sdcard.img.gz
105 IMAGE/sdcard.img.gz := boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
106 KERNEL_NAME := Image
107 KERNEL := kernel-bin
108 endef
109
110 define Device/NAND-128K
111 BLOCKSIZE := 128k
112 PAGESIZE := 2048
113 SUBPAGESIZE := 512
114 VID_HDR_OFFSET := 2048
115 endef
116
117 define Device/NAND-256K
118 BLOCKSIZE := 256k
119 PAGESIZE := 4096
120 endef
121
122 define Device/NAND-512K
123 BLOCKSIZE := 512k
124 PAGESIZE := 4096
125 endef
126
127 ifeq ($(SUBTARGET),cortexa9)
128 include cortexa9.mk
129 endif
130
131 ifeq ($(SUBTARGET),cortexa53)
132 include cortexa53.mk
133 endif
134
135 ifeq ($(SUBTARGET),cortexa72)
136 include cortexa72.mk
137 endif
138
139 $(eval $(call BuildImage))