c08b113b36f810ea45f518999cd1947d49fc0e2d
[openwrt/staging/wigyori.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 DEVICE_DTS = $$(SOC)-$(lastword $(subst _, ,$(1)))
81 BOARD_NAME = $$(DEVICE_DTS)
82 KERNEL_NAME := zImage
83 KERNEL := kernel-bin | append-dtb | uImage none
84 IMAGES := sysupgrade.bin
85 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
86 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
87 SUPPORTED_DEVICES = $(subst _,$(comma),$(1))
88 UBINIZE_OPTS := -E 5
89 UBOOT :=
90 BOOT_SCRIPT :=
91 endef
92 DEVICE_VARS += BOOT_SCRIPT UBOOT
93
94 define Device/Default-arm64
95 BOOT_SCRIPT := generic-arm64
96 DTS_DIR := $(DTS_DIR)/marvell
97 IMAGES := sdcard.img.gz
98 IMAGE/sdcard.img.gz := boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
99 KERNEL_NAME := Image
100 KERNEL := kernel-bin
101 endef
102
103 define Device/NAND-128K
104 BLOCKSIZE := 128k
105 PAGESIZE := 2048
106 SUBPAGESIZE := 512
107 VID_HDR_OFFSET := 2048
108 endef
109
110 define Device/NAND-256K
111 BLOCKSIZE := 256k
112 PAGESIZE := 4096
113 endef
114
115 define Device/NAND-512K
116 BLOCKSIZE := 512k
117 PAGESIZE := 4096
118 endef
119
120 ifeq ($(SUBTARGET),cortexa9)
121 include cortex-a9.mk
122 endif
123
124 ifeq ($(SUBTARGET),cortexa53)
125 include cortex-a53.mk
126 endif
127
128 ifeq ($(SUBTARGET),cortexa72)
129 include cortex-a72.mk
130 endif
131
132 $(eval $(call BuildImage))