mvebu: initial support for Marvell Armada 3720 DB board
[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 SIGNATURE:=$(shell printf "%.8s" $(SOURCE_DATE_EPOCH))
17
18 define Build/dtb
19 $(call Image/BuildDTB,$(DTS_DIR)/$(DEVICE_DTS).dts,$@.dtb)
20 endef
21
22 # SD-Card Images:
23 # these values are optimized for a 4GB labeled sdcard that actually holds 7744512 sectors of 512 byte
24 # MBR: 2048 sectors
25 # Partition 1: 32768 sectors
26 # Partition 2: 98304 sectors (configurable)
27
28 define Build/boot-scr
29 rm -f $@-boot.scr
30 sed -e 's#@ROOT@#$(SIGNATURE)#g' \
31 $(DEVICE_NAME).bootscript > $@-new.bootscript
32 mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $@-new.bootscript $@-boot.scr
33 endef
34
35 define Build/boot-img
36 rm -f $@.boot
37 mkfs.fat -C $@.boot 16384
38 $(foreach dts,$(DEVICE_DTS), mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::$(dts).dtb;)
39 mcopy -i $@.boot $(IMAGE_KERNEL) ::$(KERNEL_NAME)
40 -mcopy -i $@.boot $@-boot.scr ::boot.scr
41 endef
42
43 define Build/boot-img-ext4
44 rm -fR $@.boot
45 mkdir -p $@.boot
46 $(foreach dts,$(DEVICE_DTS), $(CP) $(DTS_DIR)/$(dts).dtb $@.boot;)
47 $(CP) $(IMAGE_KERNEL) $@.boot/$(KERNEL_NAME)
48 -$(CP) $@-boot.scr $@.boot/boot.scr
49 make_ext4fs -J -l 16384K $@.bootimg $@.boot
50 endef
51
52 define Build/sdcard-img
53 if [ -n "$(UBOOT)" ]; then UBOOT="$(STAGING_DIR_IMAGE)/$(UBOOT)"; fi; \
54 ROOTFS_SIZE=$$(( $(CONFIG_TARGET_ROOTFS_PARTSIZE) * 1024 * 2 )); \
55 SIGNATURE="$(SIGNATURE)" \
56 ./gen_mvebu_sdcard_img.sh $@ \
57 $$UBOOT \
58 c 32768 $@.boot \
59 83 $$ROOTFS_SIZE $(IMAGE_ROOTFS)
60 endef
61
62 define Build/sdcard-img-ext4
63 if [ -n "$(UBOOT)" ]; then UBOOT="$(STAGING_DIR_IMAGE)/$(UBOOT)"; fi; \
64 ROOTFS_SIZE=$$(( $(CONFIG_TARGET_ROOTFS_PARTSIZE) * 1024 * 2 )); \
65 SIGNATURE="$(SIGNATURE)" \
66 ./gen_mvebu_sdcard_img.sh $@ \
67 $$UBOOT \
68 83 32768 $@.bootimg \
69 83 $$ROOTFS_SIZE $(IMAGE_ROOTFS)
70 endef
71
72 define Build/omnia-medkit-initramfs
73 $(TAR) -c -T /dev/null -f $@
74 rm -rf $(dir $(IMAGE_KERNEL))boot
75 mkdir -p $(dir $(IMAGE_KERNEL))boot/boot/
76 cp $(KDIR)/zImage-initramfs $(dir $(IMAGE_KERNEL))boot/boot/zImage
77 cp $(DTS_DIR)/$(DEVICE_DTS).dtb $(dir $(IMAGE_KERNEL))boot/boot/dtb
78 $(TAR) -rp --numeric-owner --owner=0 --group=0 --sort=name \
79 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
80 --file=$@ -C $(dir $(IMAGE_KERNEL))boot/ .
81 endef
82
83 define Device/Default
84 PROFILES := Default
85 DEVICE_DTS := $(1)
86 BOARD_NAME = $$(DEVICE_DTS)
87 KERNEL_NAME := zImage
88 KERNEL := kernel-bin | append-dtb | uImage none
89 SUPPORTED_DEVICES = $$(DEVICE_DTS)
90 UBOOT :=
91 endef
92 DEVICE_VARS += UBOOT
93
94 define Device/UBI
95 IMAGES := sysupgrade.bin
96 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
97 endef
98
99 define Device/UBI-factory
100 $(Device/UBI)
101 UBINIZE_OPTS := -E 5
102 IMAGES += factory.img
103 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
104 endef
105
106 define Device/NAND-128K
107 $(Device/UBI)
108 BLOCKSIZE := 128k
109 PAGESIZE := 2048
110 SUBPAGESIZE := 512
111 VID_HDR_OFFSET := 2048
112 endef
113
114 define Device/NAND-256K
115 $(Device/UBI)
116 BLOCKSIZE := 256k
117 PAGESIZE := 4096
118 endef
119
120 define Device/NAND-512K
121 $(Device/UBI)
122 BLOCKSIZE := 512k
123 PAGESIZE := 4096
124 endef
125
126 include cortex-a9.mk
127 include cortex-a53.mk
128 include cortex-a72.mk
129
130 $(eval $(call BuildImage))