7076e876e06c6c1f2cfa8cd3b8b4bb290004c878
[librecmc/librecmc.git] / target / linux / mvebu / image / Makefile
1 #
2 # Copyright (C) 2012-2014 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         cp $(KDIR)/uImage$(2)-$(1) $(UIMAGE)$(2)-$(1);
26 endef
27
28 # $(1): Profile Name
29 # $(2): DTB Name
30 # $(3): Erase Block Size
31 # $(4): Page Size
32 # $(5): Sub-Page Size (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)))
51         cp $(KDIR)/$$(IMG_PREFIX)-$(2)-squashfs-ubinized.bin $(BIN_DIR)
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): Sub Profiles list
81 define MultiProfile
82   define Image/BuildKernel/Profile/$(1)
83         $(foreach profile, $(2),
84                 $(call Image/BuildKernel/Profile/$(profile)))
85   endef
86
87   define Image/Build/Profile/$(1)/BuildSysupgrade
88         $(foreach profile, $(2),
89                 $(call Image/Build/Profile/$(profile)/BuildSysupgrade,$$(1)))
90   endef
91
92   define Image/Build/Profile/$(1)/Initramfs
93         $(foreach profile, $(2),
94                 $(call Image/Build/Profile/$(profile)/Initramfs))
95   endef
96
97   define Image/Build/Profile/$(1)/squashfs
98         $(foreach profile, $(2),
99                 $(call Image/Build/Profile/$(profile)/squashfs))
100   endef
101 endef
102
103 # Boards with NAND, with subpages
104 $(eval $(call NANDProfile,370-DB,armada-370-db,128KiB,2048,512))
105 $(eval $(call NANDProfile,370-RD,armada-370-rd,128KiB,2048,512))
106 $(eval $(call NANDProfile,Mamba,armada-xp-mamba,128KiB,2048,512))
107 $(eval $(call NANDProfile,Mirabox,armada-370-mirabox,128KiB,2048,512))
108 $(eval $(call NANDProfile,OpenBlocks-AX-3-4,armada-xp-openblocks-ax3-4,128KiB,2048,512))
109 $(eval $(call NANDProfile,XP-DB,armada-xp-db,128KiB,2048,512))
110 $(eval $(call NANDProfile,XP-GP,armada-xp-gp,128KiB,2048,512))
111
112 define Image/Build/Profile/Mamba/squashfs
113         $(call Image/Build/UbinizeImage,armada-xp-mamba,,squashfs, -p 128KiB -m 2048 -s 512)
114         ( \
115                 dd if=$(KDIR)/uImage-armada-xp-mamba bs=3072k conv=sync; \
116                 dd if=$(KDIR)/$(IMG_PREFIX)-armada-xp-mamba-squashfs-ubinized.bin \
117                 bs=2048 conv=sync; \
118         ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-mamba-squashfs-factory.img
119 endef
120
121 $(eval $(call MultiProfile,Generic,$(PROFILES_LIST)))
122 $(eval $(call MultiProfile,Evalboards,$(PROFILES_LIST)))
123
124 define Image/BuildKernel
125         $(call Image/BuildKernel/Profile/$(PROFILE))
126 endef
127
128 define Image/Build/squashfs
129         # Align the squashfs image size before calling the profiles,
130         # otherwise the size would keep growing
131         $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
132         $(call Image/Build/Profile/$(PROFILE)/squashfs)
133 endef
134
135 define Image/Build
136         $(call Image/Build/$(1))
137         dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
138         $(call Image/Build/Profile/$(PROFILE)/BuildSysupgrade,$(1))
139 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
140         $(call Image/Build/Profile/$(PROFILE)/Initramfs)
141 endif
142 endef
143
144 $(eval $(call BuildImage))