3a478780693d31023fae0a62b2152c3dc4e79ce7
[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 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/buffalo-kernel-jffs2
44 rm -rf $(KDIR)/kernel_jffs2 $@.fakerd
45 mkdir -p $(KDIR)/kernel_jffs2
46 dd if=/dev/zero of=$@.fakerd bs=131008 count=1 conv=sync
47 $(STAGING_DIR_HOST)/bin/mkimage \
48 -T ramdisk -A $(LINUX_KARCH) -O linux -C gzip -n 'fake initrd' \
49 -d $@.fakerd $(KDIR)/kernel_jffs2/initrd.buffalo
50 cp $@ $(KDIR)/kernel_jffs2/uImage.buffalo
51 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 \
52 --little-endian -v --squash-uids -q -f -n -x lzma -x rtime -m none \
53 --eraseblock=128KiB --pad=$(KERNEL_SIZE) -d $(KDIR)/kernel_jffs2 -o $@
54 rm -rf $(KDIR)/kernel_jffs2 $@.fakerd
55 endef
56
57 define Build/sdcard-img
58 SIGNATURE="$(IMG_PART_SIGNATURE)" \
59 ./gen_mvebu_sdcard_img.sh $@ \
60 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
61 c $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
62 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
63 endef
64
65 define Build/sdcard-img-ext4
66 SIGNATURE="$(IMG_PART_SIGNATURE)" \
67 ./gen_mvebu_sdcard_img.sh $@ \
68 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
69 83 $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.bootimg \
70 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
71 endef
72
73 define Build/omnia-medkit-initramfs
74 $(TAR) -c -T /dev/null -f $@
75 rm -rf $(dir $(IMAGE_KERNEL))boot
76 mkdir -p $(dir $(IMAGE_KERNEL))boot/boot/
77 cp $(KDIR)/zImage-initramfs $(dir $(IMAGE_KERNEL))boot/boot/zImage
78 cp $(KDIR)/image-$(DEVICE_DTS).dtb $(dir $(IMAGE_KERNEL))boot/boot/dtb
79 $(TAR) -rp --numeric-owner --owner=0 --group=0 --sort=name \
80 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
81 --file=$@ -C $(dir $(IMAGE_KERNEL))boot/ .
82 endef
83
84 define Build/uDPU-firmware
85 (rm -fR $@-fw; mkdir -p $@-fw)
86 $(CP) $(BIN_DIR)/$(IMAGE_PREFIX)-initramfs.itb $@-fw/recovery.itb
87 $(CP) $@-boot.scr $@-fw/boot.scr
88 $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
89 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
90 -f $@-fw/rootfs.tgz -C $(TARGET_DIR) .
91 $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
92 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
93 -f $@-fw/boot.tgz -C $@.boot .
94 $(TAR) -cvzp --numeric-owner --owner=0 --group=0 --sort=name \
95 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
96 -f $(KDIR_TMP)/$(IMAGE_PREFIX)-firmware.tgz -C $@-fw .
97 endef
98
99 define Device/Default
100 PROFILES := Default
101 DEVICE_DTS = $$(SOC)-$(lastword $(subst _, ,$(1)))
102 DEVICE_DTS_DIR := $(DTS_DIR)
103 BOARD_NAME = $$(DEVICE_DTS)
104 KERNEL_NAME := zImage
105 KERNEL := kernel-bin | append-dtb | uImage none
106 IMAGES := sysupgrade.bin
107 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
108 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
109 SUPPORTED_DEVICES = $(subst _,$(comma),$(1))
110 UBINIZE_OPTS := -E 5
111 UBOOT :=
112 BOOT_SCRIPT :=
113 endef
114
115 define Device/Default-arm64
116 BOOT_SCRIPT := generic-arm64
117 DEVICE_DTS_DIR := $(DTS_DIR)/marvell
118 IMAGES := sdcard.img.gz
119 IMAGE/sdcard.img.gz := boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
120 KERNEL_NAME := Image
121 KERNEL := kernel-bin
122 endef
123
124 define Device/NAND-128K
125 BLOCKSIZE := 128k
126 PAGESIZE := 2048
127 SUBPAGESIZE := 512
128 VID_HDR_OFFSET := 2048
129 endef
130
131 define Device/NAND-256K
132 BLOCKSIZE := 256k
133 PAGESIZE := 4096
134 endef
135
136 define Device/NAND-512K
137 BLOCKSIZE := 512k
138 PAGESIZE := 4096
139 endef
140
141 ifeq ($(SUBTARGET),cortexa9)
142 include cortexa9.mk
143 endif
144
145 ifeq ($(SUBTARGET),cortexa53)
146 include cortexa53.mk
147 endif
148
149 ifeq ($(SUBTARGET),cortexa72)
150 include cortexa72.mk
151 endif
152
153 $(eval $(call BuildImage))