image: fix jffs2(_nand) image generation
[openwrt/svn-archive/archive.git] / target / linux / kirkwood / image / Makefile
1 #
2 # Copyright (C) 2009-2013 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 NAND_BLOCKSIZE := 2048-128k
9
10 include $(TOPDIR)/rules.mk
11 include $(INCLUDE_DIR)/image.mk
12
13 define sanitize_profile_name
14 $(shell echo $(PROFILE) | tr '[:upper:]' '[:lower:]')
15 endef
16
17 define Image/BuildKernel/Template
18
19 $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
20 echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage
21 $(call Image/BuildKernel/MkuImage, \
22 none, 0x8000, 0x8000, \
23 $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
24 $(BIN_DIR)/$(IMG_PREFIX)-uImage \
25 )
26
27 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
28 $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
29 echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
30 $(call Image/BuildKernel/MkuImage, \
31 none, 0x8000, 0x8000, \
32 $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
33 $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
34 )
35 endif
36
37 ifneq ($(1),)
38 $(CP) $(DTS_DIR)/kirkwood-$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
39
40 $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage
41 cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb >> $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage
42 $(call Image/BuildKernel/MkuImage, \
43 none, 0x8000, 0x8000, \
44 $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage, \
45 $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-uImage \
46 )
47
48 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
49 $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage-initramfs
50 cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb >> $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage-initramfs
51 $(call Image/BuildKernel/MkuImage, \
52 none, 0x8000, 0x8000, \
53 $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-zImage-initramfs, \
54 $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-uImage-initramfs \
55 )
56 endif
57 endif
58 endef
59
60 define Image/InstallKernel/Template
61
62 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL),)
63 $(INSTALL_DIR) $(TARGET_DIR)/boot
64 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE),)
65 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/
66 ln -sf $(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/uImage
67 endif
68 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
69 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/
70 ln -sf $(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/zImage
71 endif
72 endif
73
74 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
75 $(INSTALL_DIR) $(TARGET_DIR)/boot
76 ifneq ($(1),)
77 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/
78 ln -sf $(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/$(1).dtb
79 endif
80 endif
81 endef
82
83 define Image/Build/jffs2-nand-2048-128k
84 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
85 bs=2048 conv=sync
86 endef
87
88 define Image/Build/squashfs
89 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
90 ( \
91 dd if=$(KDIR)/zImage bs=4096k conv=sync; \
92 dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
93 ) > $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img
94 endef
95
96 define Image/mkfs/targz
97
98 $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
99 endef
100
101 define Image/Build/ubifs
102
103 ifneq ($($(PROFILE)_UBIFS_OPTS),)
104 $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.ubifs
105 endif
106 endef
107
108 define Image/Build/ubi
109
110 ifneq ($($(PROFILE)_UBI_OPTS),)
111 $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.ubi
112 endif
113 endef
114
115 Image/BuildKernel/Template/Generic=$(call Image/BuildKernel/Template)
116 Image/InstallKernel/Template/Generic=$(call Image/InstallKernel/Template)
117
118 Image/BuildKernel/Template/DOCKSTAR=$(call Image/BuildKernel/Template,dockstar)
119 Image/InstallKernel/Template/DOCKSTAR=$(call Image/InstallKernel/Template,dockstar)
120
121 Image/BuildKernel/Template/EA3500=$(call Image/BuildKernel/Template,ea3500)
122 Image/InstallKernel/Template/EA3500=$(call Image/InstallKernel/Template,ea3500)
123
124 Image/BuildKernel/Template/EA4500=$(call Image/BuildKernel/Template,ea4500)
125 Image/InstallKernel/Template/EA4500=$(call Image/InstallKernel/Template,ea4500)
126
127 Image/BuildKernel/Template/GOFLEXHOME=$(call Image/BuildKernel/Template,goflexhome)
128 Image/InstallKernel/Template/GOFLEXHOME=$(call Image/InstallKernel/Template,goflexhome)
129
130 Image/BuildKernel/Template/GOFLEXNET=$(call Image/BuildKernel/Template,goflexnet)
131 Image/InstallKernel/Template/GOFLEXNET=$(call Image/InstallKernel/Template,goflexnet)
132
133 Image/BuildKernel/Template/IB62X0=$(call Image/BuildKernel/Template,ib62x0)
134 Image/InstallKernel/Template/IB62X0=$(call Image/InstallKernel/Template,ib62x0)
135
136 Image/BuildKernel/Template/ICONNECT=$(call Image/BuildKernel/Template,iconnect)
137 Image/InstallKernel/Template/ICONNECT=$(call Image/InstallKernel/Template,iconnect)
138
139 Image/BuildKernel/Template/IOMEGA_IX2_200=$(call Image/BuildKernel/Template,iomega_ix2_200)
140 Image/InstallKernel/Template/IOMEGA_IX2_200=$(call Image/InstallKernel/Template,iomega_ix2_200)
141
142 Image/BuildKernel/Template/POGOE02=$(call Image/BuildKernel/Template,pogo_e02)
143 Image/InstallKernel/Template/POGOE02=$(call Image/InstallKernel/Template,pogo_e02)
144
145 Image/BuildKernel/Template/SHEEVAPLUG=$(call Image/BuildKernel/Template,sheevaplug)
146 Image/InstallKernel/Template/SHEEVAPLUG=$(call Image/InstallKernel/Template,sheevaplug)
147
148 Image/BuildKernel/Template/SHEEVAPLUGSATA=$(call Image/BuildKernel/Template,sheevaplug-esata)
149 Image/InstallKernel/Template/SHEEVAPLUGSATA=$(call Image/InstallKernel/Template,sheevaplug-esata)
150
151 Image/BuildKernel/Template/GuruplugServerPlus=$(call Image/BuildKernel/Template,guruplug-server-plus)
152 Image/InstallKernel/Template/GuruplugServerPlus=$(call Image/InstallKernel/Template,guruplug-server-plus)
153
154 Image/BuildKernel/Template/Topkick1281P2=$(call Image/BuildKernel/Template,topkick)
155 Image/InstallKernel/Template/Topkick1281P2=$(call Image/InstallKernel/Template,topkick)
156
157 define Image/BuildKernel
158 $(call Image/BuildKernel/Template/$(PROFILE))
159 endef
160
161 define Image/InstallKernel
162 $(call Image/InstallKernel/Template/$(PROFILE))
163 endef
164
165 define Image/Build
166 $(if $(Image/Build/$(1)), \
167 $(call Image/Build/$(1),$(1)), \
168 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
169 )
170 endef
171
172 $(eval $(call BuildImage))