at91: Merge SAMA5 subtargets
[openwrt/staging/mkresin.git] / target / linux / at91 / image / Makefile
1 #
2 # Copyright (C) 2006-2013 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 KERNEL_LOADADDR := 0x20008000
11
12 define Build/at91-install-zImage
13 $(CP) $(KDIR)/zImage $@
14 endef
15
16 ifeq ($(SUBTARGET),legacy)
17 include ./legacy.mk
18 endif
19 ifeq ($(SUBTARGET),sama5)
20 include ./sama5.mk
21 endif
22
23 AT91_SD_BOOT_PARTSIZE:=64
24 FAT32_BLOCK_SIZE:=1024
25 FAT32_BLOCKS:=$(shell echo \
26 $$(($(AT91_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
27
28 define Device/Default
29 $(Device/default-nand)
30 PROFILES := Default
31 FILESYSTEMS := squashfs ubifs ext4
32 DEVICE_DTS := $(1)
33 KERNEL_NAME := zImage
34 KERNEL_SIZE := 4096k
35 KERNEL := kernel-bin | append-dtb | lzma | uImage lzma
36 DTB_SIZE := 128k
37 endef
38
39 define Device/dtb
40 KERNEL := kernel-bin | lzma | uImage lzma
41 endef
42
43 define Build/at91-sdcard
44 $(if $(findstring ext4,$@), \
45 rm -f $@.boot
46 mkfs.fat -C $@.boot $(FAT32_BLOCKS)
47
48 mcopy -i $@.boot $(KDIR)/zImage ::zImage
49
50 $(foreach dts,$(DEVICE_DTS), \
51 mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb \
52 ::$(dts).dtb)
53
54 mcopy -i $@.boot \
55 $(BIN_DIR)/u-boot-$(DEVICE_NAME:at91-%=%)_mmc/u-boot.bin \
56 ::u-boot.bin
57
58 mcopy -i $@.boot \
59 $(BIN_DIR)/at91bootstrap-$(DEVICE_NAME:at91-%=%)sd*/at91bootstrap.bin \
60 ::BOOT.bin
61
62 ./gen_at91_sdcard_img.sh \
63 $@.img \
64 $@.boot \
65 $(KDIR)/root.ext4 \
66 $(AT91_SD_BOOT_PARTSIZE) \
67 $(CONFIG_TARGET_ROOTFS_PARTSIZE)
68
69 gzip -nc9 $@.img > $@
70
71 rm -f $@.img $@.boot )
72 endef
73
74 define Device/evaluation-sdimage
75 IMAGES += sdcard.img.gz
76 IMAGE/sdcard.img.gz := at91-sdcard
77 endef
78
79 define Device/evaluation
80 KERNEL_INSTALL := 1
81 KERNEL_SUFFIX := -uImage
82 IMAGES := root.ubi
83 IMAGE/root.ubi := append-ubi
84 endef
85
86 define Device/evaluation-zImage
87 IMAGES += zImage
88 IMAGE/zImage := at91-install-zImage
89 endef
90
91 define Device/evaluation-dtb
92 $(Device/evaluation)
93 $(Device/dtb)
94 $(Device/evaluation-zImage)
95 IMAGES += dtb
96 IMAGE/dtb := install-dtb
97 endef
98
99 define Device/evaluation-fit
100 $(Device/evaluation)
101 KERNEL_SUFFIX := -fit-uImage.itb
102 KERNEL := kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb
103 endef
104
105 define Device/production
106 UBINIZE_OPTS := -E 5
107 IMAGES := factory.bin
108 IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi
109 endef
110
111 define Device/production-dtb
112 $(Device/production)
113 $(Device/dtb)
114 IMAGE/factory.bin := append-dtb | pad-to $$$$(DTB_SIZE) \
115 | append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi
116 endef
117
118 $(eval $(call BuildImage))