3512c6a3b6338fdefa546f9f09fbddabe7342b21
[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 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 # The next line will be dropped, migrate your board to use a single firmware file
26 cp $(KDIR)/uImage$(2)-$(1) $(UIMAGE)$(2)-$(1);
27 endef
28
29 # $(1): Profile Name
30 # $(2): DTB Name
31 # $(3): Erase Block Size
32 # $(4): Page Size
33 # $(5): Sub-Page Size (optional)
34 define NANDProfile
35 define Image/BuildKernel/Profile/$(1)
36 $(call Image/Build/DTB,$(2))
37 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
38 $(call Image/Build/Profile,$(1)/Initramfs)
39 endif
40 endef
41
42 define Image/Build/Profile/$(1)/BuildSysupgrade
43 $(call Image/Build/SysupgradeNAND,$(2),$$(1),$(KDIR)/uImage-$(2))
44 endef
45
46 define Image/Build/Profile/$(1)/Initramfs
47 $(call Image/Build/DTB,$(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)))
52 # The next line will be dropped, migrate your board to use a single firmware file
53 cp $(KDIR)/$$(IMG_PREFIX)-$(2)-squashfs-ubinized.bin $(BIN_DIR)
54 endef
55
56 PROFILES_LIST += $(1)
57 endef
58
59 # $(1): Profile Name
60 # $(2): DTB Name
61 # $(3): Erase Block Size
62 define UBINORProfile
63 define Image/BuildKernel/Profile/$(1)
64 $(call Image/Build/DTB,$(2))
65 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
66 $(call Image/Build/Profile,$(1)/Initramfs)
67 endif
68 endef
69
70 define Image/Build/Profile/$(1)/Initramfs
71 $(call Image/Build/DTB,$(2),-initramfs)
72 endef
73
74 define Image/Build/Profile/$(1)/squashfs
75 $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m 1)
76 endef
77
78 PROFILES_LIST += $(1)
79 endef
80
81 # $(1): Profile Name
82 # $(2): DTB Name
83 # $(3): Erase Block Size
84 define NORProfile
85 define Image/BuildKernel/Profile/$(1)
86 $(call Image/Build/DTB,$(2))
87 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
88 $(call Image/Build/Profile,$(1)/Initramfs)
89 endif
90 endef
91
92 define Image/Build/Profile/$(1)/Initramfs
93 $(call Image/Build/DTB,$(2),-initramfs)
94 endef
95
96 define Image/Build/Profile/$(1)/squashfs
97 ( \
98 dd if=$(KDIR)/uImage-$(2) bs=$(3) conv=sync; \
99 dd if=$(KDIR)/root.squashfs bs=$(3) conv=sync; \
100 ) > $$(BIN_DIR)/$$(IMG_PREFIX)-$(2)-squashfs-firmware.bin
101 endef
102
103 PROFILES_LIST += $(1)
104 endef
105
106 # $(1): Profile Name
107 # $(2): Sub Profiles list
108 define MultiProfile
109 define Image/BuildKernel/Profile/$(1)
110 $(foreach profile, $(2),
111 $(call Image/BuildKernel/Profile/$(profile)))
112 endef
113
114 define Image/Build/Profile/$(1)/BuildSysupgrade
115 $(foreach profile, $(2),
116 $(call Image/Build/Profile/$(profile)/BuildSysupgrade,$$(1)))
117 endef
118
119 define Image/Build/Profile/$(1)/Initramfs
120 $(foreach profile, $(2),
121 $(call Image/Build/Profile/$(profile)/Initramfs))
122 endef
123
124 define Image/Build/Profile/$(1)/squashfs
125 $(foreach profile, $(2),
126 $(call Image/Build/Profile/$(profile)/squashfs))
127 endef
128 endef
129
130 # Boards with NAND, without subpages
131 $(eval $(call NANDProfile,370-DB,armada-370-db,512KiB,4096))
132 $(eval $(call NANDProfile,370-RD,armada-370-rd,512KiB,4096))
133 $(eval $(call NANDProfile,385-DB-AP,armada-385-db-ap,256KiB,4096))
134 $(eval $(call NANDProfile,Mirabox,armada-370-mirabox,512KiB,4096))
135 $(eval $(call NANDProfile,XP-DB,armada-xp-db,512KiB,4096))
136 $(eval $(call NANDProfile,XP-GP,armada-xp-gp,512KiB,4096))
137
138 # Boards with NAND, with subpages
139 $(eval $(call NANDProfile,Mamba,armada-xp-mamba,128KiB,2048,512))
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 define Image/Build/Profile/Mamba/squashfs
148 $(call Image/Build/UbinizeImage,armada-xp-mamba,,squashfs, -p 128KiB -m 2048 -s 512)
149 ( \
150 dd if=$(KDIR)/uImage-armada-xp-mamba bs=3072k conv=sync; \
151 dd if=$(KDIR)/$(IMG_PREFIX)-armada-xp-mamba-squashfs-ubinized.bin \
152 bs=2048 conv=sync; \
153 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-mamba-squashfs-factory.img
154 endef
155
156 # The Default profile should build everything
157 $(eval $(call MultiProfile,Default,$(PROFILES_LIST)))
158
159 define Image/BuildKernel
160 $(call Image/BuildKernel/Profile/$(PROFILE))
161 endef
162
163 define Image/Build/squashfs
164 # Align the squashfs image size before calling the profiles,
165 # otherwise the size would keep growing
166 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
167 $(call Image/Build/Profile/$(PROFILE)/squashfs)
168 endef
169
170 define Image/Build
171 $(call Image/Build/$(1))
172 # The next line will be dropped, migrate your board to use a single firmware file
173 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
174 $(call Image/Build/Profile/$(PROFILE)/BuildSysupgrade,$(1))
175 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
176 $(call Image/Build/Profile/$(PROFILE)/Initramfs)
177 endif
178 endef
179
180 $(eval $(call BuildImage))