mvebu: add comments to image generation
[oweals/openwrt.git] / target / linux / mvebu / image / Makefile
1 #
2 # Copyright (C) 2012-2015 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 LOADADDR:=0x00008000
11
12 JFFS2_BLOCKSIZE = 128k
13
14 KDIR_TMP:=$(KDIR)/tmp
15
16
17 UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
18
19 define Image/Build/DTB
20         cp $(KDIR)/zImage$(2) $(KDIR)/zImage$(2)-$(1);
21         cat $(DTS_DIR)/$(1).dtb >> $(KDIR)/zImage$(2)-$(1);
22         $(call Image/BuildKernel/MkuImage, \
23                 none, $(LOADADDR), $(LOADADDR), \
24                 $(KDIR)/zImage$(2)-$(1), $(KDIR)/uImage$(2)-$(1))
25 endef
26
27 # $(1): Profile Name
28 # $(2): DTB Name
29 # $(3): Erase Block Size
30 # $(4): Page Size
31 # $(5): Sub-Page Size (optional)
32 # $(6): VID offset (optional)
33 define NANDProfile
34   define Image/BuildKernel/Profile/$(1)
35         $(call Image/Build/DTB,$(2))
36     ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
37         $(call Image/Build/Profile,$(1)/Initramfs)
38     endif
39   endef
40
41   define Image/Build/Profile/$(1)/BuildSysupgrade
42         $(call Image/Build/SysupgradeNAND,$(2),$$(1),$(KDIR)/uImage-$(2))
43   endef
44
45   define Image/Build/Profile/$(1)/Initramfs
46         $(call Image/Build/DTB,$(2),-initramfs)
47   endef
48
49   define Image/Build/Profile/$(1)/squashfs
50         $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m $(4) $(if $(5),-s $(5)) $(if $(6),-O $(6)))
51   endef
52
53   PROFILES_LIST += $(1)
54 endef
55
56 # $(1): Profile Name
57 # $(2): DTB Name
58 # $(3): Erase Block Size
59 define UBINORProfile
60   define Image/BuildKernel/Profile/$(1)
61         $(call Image/Build/DTB,$(2))
62     ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
63         $(call Image/Build/Profile,$(1)/Initramfs)
64     endif
65   endef
66
67   define Image/Build/Profile/$(1)/Initramfs
68         $(call Image/Build/DTB,$(2),-initramfs)
69   endef
70
71   define Image/Build/Profile/$(1)/squashfs
72         $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m 1)
73   endef
74
75   PROFILES_LIST += $(1)
76 endef
77
78 # $(1): Profile Name
79 # $(2): DTB Name
80 # $(3): Erase Block Size
81 define NORProfile
82   define Image/BuildKernel/Profile/$(1)
83         $(call Image/Build/DTB,$(2))
84     ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
85         $(call Image/Build/Profile,$(1)/Initramfs)
86     endif
87   endef
88
89   define Image/Build/Profile/$(1)/Initramfs
90         $(call Image/Build/DTB,$(2),-initramfs)
91   endef
92
93   define Image/Build/Profile/$(1)/squashfs
94         ( \
95                 dd if=$(KDIR)/uImage-$(2) bs=$(3) conv=sync; \
96                 dd if=$(KDIR)/root.squashfs bs=$(3) conv=sync; \
97         ) > $$(BIN_DIR)/$$(IMG_PREFIX)-$(2)-squashfs-firmware.bin
98   endef
99
100   PROFILES_LIST += $(1)
101 endef
102
103 # $(1): Profile Name
104 # $(2): Sub Profiles list
105 define MultiProfile
106   define Image/BuildKernel/Profile/$(1)
107         $(foreach profile, $(2),
108                 $(call Image/BuildKernel/Profile/$(profile)))
109   endef
110
111   define Image/Build/Profile/$(1)/BuildSysupgrade
112         $(foreach profile, $(2),
113                 $(call Image/Build/Profile/$(profile)/BuildSysupgrade,$$(1)))
114   endef
115
116   define Image/Build/Profile/$(1)/Initramfs
117         $(foreach profile, $(2),
118                 $(call Image/Build/Profile/$(profile)/Initramfs))
119   endef
120
121   define Image/Build/Profile/$(1)/squashfs
122         $(foreach profile, $(2),
123                 $(call Image/Build/Profile/$(profile)/squashfs))
124   endef
125 endef
126
127 # Boards with NAND, without subpages
128 $(eval $(call NANDProfile,370-DB,armada-370-db,512KiB,4096))
129 $(eval $(call NANDProfile,370-RD,armada-370-rd,512KiB,4096))
130 $(eval $(call NANDProfile,385-DB-AP,armada-385-db-ap,256KiB,4096))
131 $(eval $(call NANDProfile,Mirabox,armada-370-mirabox,512KiB,4096))
132 $(eval $(call NANDProfile,XP-DB,armada-xp-db,512KiB,4096))
133 $(eval $(call NANDProfile,XP-GP,armada-xp-gp,512KiB,4096))
134
135 # Boards with NAND, with subpages
136 $(eval $(call NANDProfile,Mamba,armada-xp-linksys-mamba,128KiB,2048,512,2048))
137
138 # Boards with large NOR, where we want to use UBI
139 $(eval $(call UBINORProfile,OpenBlocks-AX-3-4,armada-xp-openblocks-ax3-4,128KiB))
140
141 # Boards with small NOR, where UBI doesn't make sense
142 $(eval $(call NORProfile,385-RD,armada-385-rd,256KiB))
143
144 ###
145 ### Linksys
146 ###
147
148 # Mamba: Linksys WRT1900AC
149 define Image/Build/Profile/Mamba/squashfs
150         $(call Image/Build/UbinizeImage,armada-xp-linksys-mamba,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
151         ( \
152                 dd if=$(KDIR)/uImage-armada-xp-linksys-mamba bs=3072k conv=sync; \
153                 dd if=$(KDIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-ubinized.bin \
154                 bs=2048 conv=sync; \
155         ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-factory.img
156 endef
157
158 ###
159 ### Marvell
160 ###
161
162 # Marvell Armada 385 Access Point Development board (DB-88F6820-AP)
163 define Image/Build/Profile/385-DB-AP/squashfs
164         $(call Image/Build/UbinizeImage,armada-385-db-ap,,squashfs, -p 256KiB -m 4096)
165         ( \
166                 dd if=$(KDIR)/uImage-armada-385-db-ap bs=8M conv=sync; \
167                 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-ubinized.bin \
168                 bs=4096 conv=sync; \
169         ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-factory.img
170 endef
171
172
173 # The Default profile should build everything
174 $(eval $(call MultiProfile,Default,$(PROFILES_LIST)))
175
176 define Image/BuildKernel
177         $(call Image/BuildKernel/Profile/$(PROFILE))
178 endef
179
180 define Image/Build/squashfs
181         # Align the squashfs image size before calling the profiles,
182         # otherwise the size would keep growing
183         $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
184         $(call Image/Build/Profile/$(PROFILE)/squashfs)
185 endef
186
187 define Image/Build
188         $(call Image/Build/$(1))
189         $(call Image/Build/Profile/$(PROFILE)/BuildSysupgrade,$(1))
190 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
191         $(call Image/Build/Profile/$(PROFILE)/Initramfs)
192 endif
193 endef
194
195 $(eval $(call BuildImage))