at91: reorganize at91 subtargets
[openwrt/staging/jogo.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),sama5d2)
20 include ./sama5d2.mk
21 endif
22 ifeq ($(SUBTARGET),sama5d3)
23 include ./sama5d3.mk
24 endif
25 ifeq ($(SUBTARGET),sama5d4)
26 include ./sama5d4.mk
27 endif
28
29 AT91_SD_BOOT_PARTSIZE:=64
30 FAT32_BLOCK_SIZE:=1024
31 FAT32_BLOCKS:=$(shell echo \
32 $$(($(AT91_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
33
34 define Device/Default
35 $(Device/default-nand)
36 PROFILES := Default
37 FILESYSTEMS := squashfs ubifs ext4
38 DEVICE_DTS := $(1)
39 KERNEL_NAME := zImage
40 KERNEL_SIZE := 4096k
41 KERNEL := kernel-bin | append-dtb | lzma | uImage lzma
42 DTB_SIZE := 128k
43 endef
44
45 define Device/dtb
46 KERNEL := kernel-bin | lzma | uImage lzma
47 endef
48
49 define Build/at91-sdcard
50 $(if $(findstring ext4,$@), \
51 rm -f $@.boot
52 mkfs.fat -C $@.boot $(FAT32_BLOCKS)
53
54 mcopy -i $@.boot $(KDIR)/zImage ::zImage
55
56 $(foreach dts,$(DEVICE_DTS), \
57 mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb \
58 ::$(dts).dtb)
59
60 mcopy -i $@.boot \
61 $(BIN_DIR)/u-boot-$(DEVICE_NAME:at91-%=%)_mmc/u-boot.bin \
62 ::u-boot.bin
63
64 mcopy -i $@.boot \
65 $(BIN_DIR)/at91bootstrap-$(DEVICE_NAME:at91-%=%)sd*/at91bootstrap.bin \
66 ::BOOT.bin
67
68 ./gen_at91_sdcard_img.sh \
69 $@.img \
70 $@.boot \
71 $(KDIR)/root.ext4 \
72 $(AT91_SD_BOOT_PARTSIZE) \
73 $(CONFIG_TARGET_ROOTFS_PARTSIZE)
74
75 gzip -nc9 $@.img > $@
76
77 rm -f $@.img $@.boot )
78 endef
79
80 define Device/evaluation-sdimage
81 IMAGES += sdcard.img.gz
82 IMAGE/sdcard.img.gz := at91-sdcard
83 endef
84
85 define Device/evaluation
86 KERNEL_INSTALL := 1
87 KERNEL_SUFFIX := -uImage
88 IMAGES := root.ubi
89 IMAGE/root.ubi := append-ubi
90 endef
91
92 define Device/evaluation-zImage
93 IMAGES += zImage
94 IMAGE/zImage := at91-install-zImage
95 endef
96
97 define Device/evaluation-dtb
98 $(Device/evaluation)
99 $(Device/dtb)
100 $(Device/evaluation-zImage)
101 IMAGES += dtb
102 IMAGE/dtb := install-dtb
103 endef
104
105 define Device/evaluation-fit
106 $(Device/evaluation)
107 KERNEL_SUFFIX := -fit-uImage.itb
108 KERNEL := kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb
109 endef
110
111 define Device/production
112 UBINIZE_OPTS := -E 5
113 IMAGES := factory.bin
114 IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi
115 endef
116
117 define Device/production-dtb
118 $(Device/production)
119 $(Device/dtb)
120 IMAGE/factory.bin := append-dtb | pad-to $$$$(DTB_SIZE) \
121 | append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi
122 endef
123
124 $(eval $(call BuildImage))