6e012a61e1ad8bd2edc7692480890d3ecac0c981
[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 mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $(DEVICE_NAME).bootscript $@-boot.scr
31 endef
32
33 define Build/boot-img
34 rm -f $@.boot
35 mkfs.fat -C $@.boot 16384
36 $(foreach dts,$(DEVICE_DTS), mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::$(dts).dtb;)
37 mcopy -i $@.boot $(IMAGE_KERNEL) ::zImage
38 -mcopy -i $@.boot $@-boot.scr ::boot.scr
39 endef
40
41 define Build/sdcard-img
42 if [ -n "$(UBOOT)" ]; then UBOOT="$(STAGING_DIR_IMAGE)/$(UBOOT)"; fi; \
43 ROOTFS_SIZE=$$(( $(CONFIG_TARGET_ROOTFS_PARTSIZE) * 1024 * 2 )); \
44 SIGNATURE="$(SIGNATURE)" \
45 ./gen_mvebu_sdcard_img.sh $@ \
46 $$UBOOT \
47 c 32768 $@.boot \
48 83 $$ROOTFS_SIZE $(IMAGE_ROOTFS)
49 endef
50
51 define Build/omnia-medkit-initramfs
52 $(TAR) -c -T /dev/null -f $@
53 rm -rf $(dir $(IMAGE_KERNEL))boot
54 mkdir -p $(dir $(IMAGE_KERNEL))boot/boot/
55 cp $(KDIR)/zImage-initramfs $(dir $(IMAGE_KERNEL))boot/boot/zImage
56 cp $(DTS_DIR)/$(DEVICE_DTS).dtb $(dir $(IMAGE_KERNEL))boot/boot/dtb
57 $(TAR) -rp --numeric-owner --owner=0 --group=0 --sort=name \
58 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
59 --file=$@ -C $(dir $(IMAGE_KERNEL))boot/ .
60 endef
61
62 define Device/Default
63 PROFILES := Default
64 DEVICE_DTS := $(1)
65 BOARD_NAME = $$(DEVICE_DTS)
66 KERNEL_NAME := zImage
67 KERNEL := kernel-bin | append-dtb | uImage none
68 SUPPORTED_DEVICES = $$(DEVICE_DTS)
69 endef
70
71 define Device/UBI
72 IMAGES := sysupgrade.bin
73 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
74 endef
75
76 define Device/UBI-factory
77 $(Device/UBI)
78 UBINIZE_OPTS := -E 5
79 IMAGES += factory.img
80 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
81 endef
82
83 define Device/NAND-128K
84 $(Device/UBI)
85 BLOCKSIZE := 128k
86 PAGESIZE := 2048
87 SUBPAGESIZE := 512
88 VID_HDR_OFFSET := 2048
89 endef
90
91 define Device/NAND-256K
92 $(Device/UBI)
93 BLOCKSIZE := 256k
94 PAGESIZE := 4096
95 endef
96
97 define Device/NAND-512K
98 $(Device/UBI)
99 BLOCKSIZE := 512k
100 PAGESIZE := 4096
101 endef
102
103 include cortex-a9.mk
104
105 $(eval $(call BuildImage))