2 # Copyright (C) 2012-2015 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
12 JFFS2_BLOCKSIZE = 128k
17 UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
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);
31 # $(3): Erase Block Size
33 # $(5): Sub-Page Size (optional)
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)
42 define Image/Build/Profile/$(1)/BuildSysupgrade
43 $(call Image/Build/SysupgradeNAND,$(2),$$(1),$(KDIR)/uImage-$(2))
46 define Image/Build/Profile/$(1)/Initramfs
47 $(call Image/Build/DTB,$(2),-initramfs)
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)
61 # $(3): Erase Block Size
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)
70 define Image/Build/Profile/$(1)/Initramfs
71 $(call Image/Build/DTB,$(2),-initramfs)
74 define Image/Build/Profile/$(1)/squashfs
75 $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m 1)
83 # $(3): Erase Block Size
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)
92 define Image/Build/Profile/$(1)/Initramfs
93 $(call Image/Build/DTB,$(2),-initramfs)
96 define Image/Build/Profile/$(1)/squashfs
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
103 PROFILES_LIST += $(1)
107 # $(2): Sub Profiles list
109 define Image/BuildKernel/Profile/$(1)
110 $(foreach profile, $(2),
111 $(call Image/BuildKernel/Profile/$(profile)))
114 define Image/Build/Profile/$(1)/BuildSysupgrade
115 $(foreach profile, $(2),
116 $(call Image/Build/Profile/$(profile)/BuildSysupgrade,$$(1)))
119 define Image/Build/Profile/$(1)/Initramfs
120 $(foreach profile, $(2),
121 $(call Image/Build/Profile/$(profile)/Initramfs))
124 define Image/Build/Profile/$(1)/squashfs
125 $(foreach profile, $(2),
126 $(call Image/Build/Profile/$(profile)/squashfs))
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))
138 # Boards with NAND, with subpages
139 $(eval $(call NANDProfile,Mamba,armada-xp-mamba,128KiB,2048,512))
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))
144 # Boards with small NOR, where UBI doesn't make sense
145 $(eval $(call NORProfile,385-RD,armada-385-rd,256KiB))
147 define Image/Build/Profile/Mamba/squashfs
148 $(call Image/Build/UbinizeImage,armada-xp-mamba,,squashfs, -p 128KiB -m 2048 -s 512)
150 dd if=$(KDIR)/uImage-armada-xp-mamba bs=3072k conv=sync; \
151 dd if=$(KDIR)/$(IMG_PREFIX)-armada-xp-mamba-squashfs-ubinized.bin \
153 ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-mamba-squashfs-factory.img
156 # The Default profile should build everything
157 $(eval $(call MultiProfile,Default,$(PROFILES_LIST)))
159 define Image/BuildKernel
160 $(call Image/BuildKernel/Profile/$(PROFILE))
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)
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)
180 $(eval $(call BuildImage))