image: fix jffs2(_nand) image generation
[openwrt/svn-archive/archive.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
8 JFFS2_BLOCKSIZE = 128k
9
10 include $(TOPDIR)/rules.mk
11 include $(INCLUDE_DIR)/image.mk
12
13 LOADADDR:=0x00008000
14
15
16 KDIR_TMP:=$(KDIR)/tmp
17
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 cp $(KDIR)/uImage-initramfs-$(2) $(BIN_DIR)/$(IMG_PREFIX)-$(2)-initramfs
48 endef
49
50 define Image/Build/Profile/$(1)/squashfs
51 $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m $(4) $(if $(5),-s $(5)) $(if $(6),-O $(6)))
52 endef
53
54 PROFILES_LIST += $(1)
55 endef
56
57 # $(1): Profile Name
58 # $(2): DTB Name
59 # $(3): Erase Block Size
60 define UBINORProfile
61 define Image/BuildKernel/Profile/$(1)
62 $(call Image/Build/DTB,$(2))
63 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
64 $(call Image/Build/Profile,$(1)/Initramfs)
65 endif
66 endef
67
68 define Image/Build/Profile/$(1)/Initramfs
69 $(call Image/Build/DTB,$(2),-initramfs)
70 endef
71
72 define Image/Build/Profile/$(1)/squashfs
73 $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m 1)
74 endef
75
76 PROFILES_LIST += $(1)
77 endef
78
79 # $(1): Profile Name
80 # $(2): DTB Name
81 # $(3): Erase Block Size
82 define NORProfile
83 define Image/BuildKernel/Profile/$(1)
84 $(call Image/Build/DTB,$(2))
85 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
86 $(call Image/Build/Profile,$(1)/Initramfs)
87 endif
88 endef
89
90 define Image/Build/Profile/$(1)/Initramfs
91 $(call Image/Build/DTB,$(2),-initramfs)
92 endef
93
94 define Image/Build/Profile/$(1)/squashfs
95 ( \
96 dd if=$(KDIR)/uImage-$(2) bs=$(3) conv=sync; \
97 dd if=$(KDIR)/root.squashfs bs=$(3) conv=sync; \
98 ) > $$(BIN_DIR)/$$(IMG_PREFIX)-$(2)-squashfs-firmware.bin
99 endef
100
101 PROFILES_LIST += $(1)
102 endef
103
104 # $(1): Profile Name
105 # $(2): Sub Profiles list
106 define MultiProfile
107 define Image/BuildKernel/Profile/$(1)
108 $(foreach profile, $(2),
109 $(call Image/BuildKernel/Profile/$(profile)))
110 endef
111
112 define Image/Build/Profile/$(1)/BuildSysupgrade
113 $(foreach profile, $(2),
114 $(call Image/Build/Profile/$(profile)/BuildSysupgrade,$$(1)))
115 endef
116
117 define Image/Build/Profile/$(1)/Initramfs
118 $(foreach profile, $(2),
119 $(call Image/Build/Profile/$(profile)/Initramfs))
120 endef
121
122 define Image/Build/Profile/$(1)/squashfs
123 $(foreach profile, $(2),
124 $(call Image/Build/Profile/$(profile)/squashfs))
125 endef
126 endef
127
128 # Boards with NAND, without subpages
129 $(eval $(call NANDProfile,370-DB,armada-370-db,512KiB,4096))
130 $(eval $(call NANDProfile,370-RD,armada-370-rd,512KiB,4096))
131 $(eval $(call NANDProfile,385-DB-AP,armada-385-db-ap,256KiB,4096))
132 $(eval $(call NANDProfile,Mirabox,armada-370-mirabox,512KiB,4096))
133 $(eval $(call NANDProfile,XP-DB,armada-xp-db,512KiB,4096))
134 $(eval $(call NANDProfile,XP-GP,armada-xp-gp,512KiB,4096))
135
136 # Boards with NAND, with subpages
137 $(eval $(call NANDProfile,Mamba,armada-xp-linksys-mamba,128KiB,2048,512,2048))
138 $(eval $(call NANDProfile,Caiman,armada-385-linksys-caiman,128KiB,2048,512,2048))
139 $(eval $(call NANDProfile,Cobra,armada-385-linksys-cobra,128KiB,2048,512,2048))
140
141 # Boards with large NOR, where we want to use UBI
142 $(eval $(call UBINORProfile,OpenBlocks-AX-3-4,armada-xp-openblocks-ax3-4,128KiB))
143
144 # Boards with small NOR, where UBI doesn't make sense
145 $(eval $(call NORProfile,385-RD,armada-385-rd,256KiB))
146
147 ###
148 ### Linksys
149 ###
150
151 # Caiman: Linksys WRT1200AC
152 define Image/Build/Profile/Caiman/squashfs
153 $(call Image/Build/UbinizeImage,armada-385-linksys-caiman,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
154 ( \
155 dd if=$(KDIR)/uImage-armada-385-linksys-caiman bs=6M conv=sync; \
156 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-caiman-squashfs-ubinized.bin \
157 bs=2048 conv=sync; \
158 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-caiman-squashfs-factory.img
159 endef
160
161 # Cobra: Linksys WRT1900ACv2
162 define Image/Build/Profile/Cobra/squashfs
163 $(call Image/Build/UbinizeImage,armada-385-linksys-cobra,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
164 ( \
165 dd if=$(KDIR)/uImage-armada-385-linksys-cobra bs=6M conv=sync; \
166 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-cobra-squashfs-ubinized.bin \
167 bs=2048 conv=sync; \
168 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-cobra-squashfs-factory.img
169 endef
170
171 # Mamba: Linksys WRT1900AC
172 define Image/Build/Profile/Mamba/squashfs
173 $(call Image/Build/UbinizeImage,armada-xp-linksys-mamba,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
174 ( \
175 dd if=$(KDIR)/uImage-armada-xp-linksys-mamba bs=3072k conv=sync; \
176 dd if=$(KDIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-ubinized.bin \
177 bs=2048 conv=sync; \
178 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-factory.img
179 endef
180
181 ###
182 ### Marvell
183 ###
184
185 # Marvell Armada 385 Access Point Development board (DB-88F6820-AP)
186 define Image/Build/Profile/385-DB-AP/squashfs
187 $(call Image/Build/UbinizeImage,armada-385-db-ap,,squashfs, -p 256KiB -m 4096)
188 ( \
189 dd if=$(KDIR)/uImage-armada-385-db-ap bs=8M conv=sync; \
190 dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-ubinized.bin \
191 bs=4096 conv=sync; \
192 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-factory.img
193 endef
194
195
196 # The Default profile should build everything
197 $(eval $(call MultiProfile,Default,$(PROFILES_LIST)))
198
199 define Image/BuildKernel
200 $(call Image/BuildKernel/Profile/$(PROFILE))
201 endef
202
203 define Image/Build/squashfs
204 # Align the squashfs image size before calling the profiles,
205 # otherwise the size would keep growing
206 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
207 $(call Image/Build/Profile/$(PROFILE)/squashfs)
208 endef
209
210 define Image/Build
211 $(call Image/Build/$(1))
212 $(call Image/Build/Profile/$(PROFILE)/BuildSysupgrade,$(1))
213 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
214 $(call Image/Build/Profile/$(PROFILE)/Initramfs)
215 endif
216 endef
217
218 $(eval $(call BuildImage))