ath79: add AR934x NAND Flash Controller driver
[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/boot-scr
19 rm -f $@-boot.scr
20 sed \
21 -e 's#@ROOT@#$(SIGNATURE)#g' \
22 -e 's#@DTB@#$(firstword $(DEVICE_DTS))#g' \
23 $(BOOT_SCRIPT).bootscript > $@-new.bootscript
24 mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $@-new.bootscript $@-boot.scr
25 endef
26
27 define Build/boot-img
28 rm -f $@.boot
29 mkfs.fat -C $@.boot $$(( $(CONFIG_TARGET_KERNEL_PARTSIZE) * 1024 ))
30 $(foreach dts,$(DEVICE_DTS), mcopy -i $@.boot $(KDIR)/image-$(dts).dtb ::$(dts).dtb;)
31 mcopy -i $@.boot $(IMAGE_KERNEL) ::$(KERNEL_NAME)
32 -mcopy -i $@.boot $@-boot.scr ::boot.scr
33 endef
34
35 define Build/boot-img-ext4
36 rm -fR $@.boot
37 mkdir -p $@.boot
38 $(foreach dts,$(DEVICE_DTS), $(CP) $(KDIR)/image-$(dts).dtb $@.boot/$(dts).dtb;)
39 $(CP) $(IMAGE_KERNEL) $@.boot/$(KERNEL_NAME)
40 -$(CP) $@-boot.scr $@.boot/boot.scr
41 make_ext4fs -J -l $(CONFIG_TARGET_KERNEL_PARTSIZE)M $@.bootimg $@.boot
42 endef
43
44 define Build/sdcard-img
45 SIGNATURE="$(SIGNATURE)" \
46 ./gen_mvebu_sdcard_img.sh $@ \
47 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
48 c $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
49 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
50 endef
51
52 define Build/sdcard-img-ext4
53 SIGNATURE="$(SIGNATURE)" \
54 ./gen_mvebu_sdcard_img.sh $@ \
55 $(if $(UBOOT),$(STAGING_DIR_IMAGE)/$(UBOOT)) \
56 83 $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.bootimg \
57 83 $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS)
58 endef
59
60 define Build/omnia-medkit-initramfs
61 $(TAR) -c -T /dev/null -f $@
62 rm -rf $(dir $(IMAGE_KERNEL))boot
63 mkdir -p $(dir $(IMAGE_KERNEL))boot/boot/
64 cp $(KDIR)/zImage-initramfs $(dir $(IMAGE_KERNEL))boot/boot/zImage
65 cp $(KDIR)/image-$(DEVICE_DTS).dtb $(dir $(IMAGE_KERNEL))boot/boot/dtb
66 $(TAR) -rp --numeric-owner --owner=0 --group=0 --sort=name \
67 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
68 --file=$@ -C $(dir $(IMAGE_KERNEL))boot/ .
69 endef
70
71 define Build/uDPU-firmware
72 (rm -fR $@-fw; mkdir -p $@-fw)
73 $(CP) $(BIN_DIR)/$(IMAGE_PREFIX)-initramfs.itb $@-fw/recovery.itb
74 $(CP) $@-boot.scr $@-fw/boot.scr
75 (cd $(TARGET_DIR); $(TAR) -cvzf $@-fw/rootfs.tgz .)
76 (cd $@.boot; $(TAR) -cvzf $@-fw/boot.tgz .)
77 (cd $@-fw; $(TAR) -cvzf $(KDIR_TMP)/$(IMAGE_PREFIX)-firmware.tgz .)
78 endef
79
80 define Device/Default
81 PROFILES := Default
82 BOARD_NAME = $$(DEVICE_DTS)
83 KERNEL_NAME := zImage
84 KERNEL := kernel-bin | append-dtb | uImage none
85 IMAGES := sysupgrade.bin
86 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE)
87 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
88 SUPPORTED_DEVICES = $(subst _,$(comma),$(1))
89 UBINIZE_OPTS := -E 5
90 UBOOT :=
91 BOOT_SCRIPT :=
92 endef
93 DEVICE_VARS += BOOT_SCRIPT UBOOT
94
95 define Device/Default-arm64
96 BOOT_SCRIPT := generic-arm64
97 DTS_DIR := $(DTS_DIR)/marvell
98 IMAGES := sdcard.img.gz
99 IMAGE/sdcard.img.gz := boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
100 KERNEL_NAME := Image
101 KERNEL := kernel-bin
102 endef
103
104 define Device/NAND-128K
105 BLOCKSIZE := 128k
106 PAGESIZE := 2048
107 SUBPAGESIZE := 512
108 VID_HDR_OFFSET := 2048
109 endef
110
111 define Device/NAND-256K
112 BLOCKSIZE := 256k
113 PAGESIZE := 4096
114 endef
115
116 define Device/NAND-512K
117 BLOCKSIZE := 512k
118 PAGESIZE := 4096
119 endef
120
121 include cortex-a9.mk
122 include cortex-a53.mk
123 include cortex-a72.mk
124
125 $(eval $(call BuildImage))