ef9274866de3e8b4ef4796c1fc05e2d529875e93
[oweals/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 DEVICE_VARS += BOOT_SCRIPT UBOOT
15 KERNEL_LOADADDR := 0x00008000
16
17 define Build/boot-scr
18         rm -f $@-boot.scr
19         sed \
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
24 endef
25
26 define Build/boot-img
27         rm -f $@.boot
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
32 endef
33
34 define Build/boot-img-ext4
35         rm -fR $@.boot
36         mkdir -p $@.boot
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
41 endef
42
43 define Build/sdcard-img
44         SIGNATURE="$(IMG_PART_SIGNATURE)" \
45         ./gen_mvebu_sdcard_img.sh $@ \
46                 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
47                 c $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
48                 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
49 endef
50
51 define Build/sdcard-img-ext4
52         SIGNATURE="$(IMG_PART_SIGNATURE)" \
53         ./gen_mvebu_sdcard_img.sh $@ \
54                 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
55                 83 $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.bootimg \
56                 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
57 endef
58
59 define Build/omnia-medkit-initramfs
60         $(TAR) -c -T /dev/null -f $@
61         rm -rf $(dir $(IMAGE_KERNEL))boot
62         mkdir -p $(dir $(IMAGE_KERNEL))boot/boot/
63         cp $(KDIR)/zImage-initramfs $(dir $(IMAGE_KERNEL))boot/boot/zImage
64         cp $(KDIR)/image-$(DEVICE_DTS).dtb $(dir $(IMAGE_KERNEL))boot/boot/dtb
65         $(TAR) -rp --numeric-owner --owner=0 --group=0 --sort=name \
66                 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
67                 --file=$@ -C $(dir $(IMAGE_KERNEL))boot/ .
68 endef
69
70 define Build/uDPU-firmware
71         (rm -fR $@-fw; mkdir -p $@-fw)
72         $(CP) $(BIN_DIR)/$(IMAGE_PREFIX)-initramfs.itb $@-fw/recovery.itb
73         $(CP) $@-boot.scr $@-fw/boot.scr
74         $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
75                 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
76                 -f $@-fw/rootfs.tgz -C $(TARGET_DIR) .
77         $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
78                 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
79                 -f $@-fw/boot.tgz -C $@.boot .
80         $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
81                 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
82                 -f $(KDIR_TMP)/$(IMAGE_PREFIX)-firmware.tgz -C $@-fw .
83 endef
84
85 define Device/Default
86   PROFILES := Default
87   DEVICE_DTS = $$(SOC)-$(lastword $(subst _, ,$(1)))
88   DEVICE_DTS_DIR := $(DTS_DIR)
89   BOARD_NAME = $$(DEVICE_DTS)
90   KERNEL_NAME := zImage
91   KERNEL := kernel-bin | append-dtb | uImage none
92   IMAGES := sysupgrade.bin
93   IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
94   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
95   SUPPORTED_DEVICES = $(subst _,$(comma),$(1))
96   UBINIZE_OPTS := -E 5
97   UBOOT :=
98   BOOT_SCRIPT :=
99 endef
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))