2 # Copyright (C) 2009-2013 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 NAND_BLOCKSIZE := 2048-128k
10 include $(TOPDIR)/rules.mk
11 include $(INCLUDE_DIR)/image.mk
13 KERNEL_LOADADDR:=0x8000
14 TARGET_DEVICES = linksys-audi linksys-viper dockstar goflexnet goflexhome
16 UBI_OPTS := -m 2048 -p 128KiB -s 512
17 UBIFS_OPTS := -m 2048 -e 126KiB -c 4096
20 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
21 KERNEL := kernel-bin | append-dtb | uImage none
23 KERNEL_SUFFIX := -uImage
29 IMAGES := sysupgrade.tar
31 IMAGE/sysupgrade.tar := sysupgrade-tar
34 define Device/dockstar
35 DEVICE_DTS := kirkwood-dockstar
36 FILESYSTEMS := squashfs
37 PROFILES := Generic DOCKSTAR
39 IMAGE/factory.bin := append-ubi
43 define Device/goflexnet
45 PROFILES := Generic GOFLEXNET
46 DEVICE_DTS := kirkwood-goflexnet
49 define Device/goflexhome
51 PROFILES := Generic GOFLEXHOME
52 DEVICE_DTS := kirkwood-goflexhome
55 define Device/linksys-audi
56 DEVICE_DTS := kirkwood-linksys-audi
58 FILESYSTEMS := squashfs
59 PROFILES := Generic AUDI
61 IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi
64 define Device/linksys-viper
65 DEVICE_DTS := kirkwood-linksys-viper
67 FILESYSTEMS := squashfs
68 PROFILES := Generic VIPER
70 IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi
73 define Image/BuildKernel/Template
75 $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
76 echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage
77 $(call Image/BuildKernel/MkuImage, \
78 none, 0x8000, 0x8000, \
79 $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
80 $(BIN_DIR)/$(IMG_PREFIX)-uImage \
83 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
84 $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
85 echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
86 $(call Image/BuildKernel/MkuImage, \
87 none, 0x8000, 0x8000, \
88 $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
89 $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
94 $(CP) $(DTS_DIR)/kirkwood-$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
96 $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage
97 cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb >> $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage
98 $(call Image/BuildKernel/MkuImage, \
99 none, 0x8000, 0x8000, \
100 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage, \
101 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-uImage \
104 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
105 $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage-initramfs
106 cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb >> $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage-initramfs
107 $(call Image/BuildKernel/MkuImage, \
108 none, 0x8000, 0x8000, \
109 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-zImage-initramfs, \
110 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-uImage-initramfs \
116 define Image/Build/jffs2-nand-2048-128k
117 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-$(1).img \
121 define Image/Build/squashfs
122 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
124 dd if=$(KDIR)/zImage bs=4096k conv=sync; \
125 dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
126 ) > $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-$(1).img
129 define Image/Build/ubifs
131 ifneq ($($(PROFILE)_UBIFS_OPTS),)
132 $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-rootfs.ubifs
136 define Image/Build/ubi
138 ifneq ($($(PROFILE)_UBI_OPTS),)
139 $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-rootfs.ubi
143 IOMEGA_IX2_200_UBIFS_OPTS := -m 512 -e 15872 -c 2048
144 IOMEGA_IX2_200_UBI_OPTS := -m 512 -p 16384 -s 256
146 Image/BuildKernel/Template/Generic=$(call Image/BuildKernel/Template)
147 Image/BuildKernel/Template/IB62X0=$(call Image/BuildKernel/Template,ib62x0)
148 Image/BuildKernel/Template/ICONNECT=$(call Image/BuildKernel/Template,iconnect)
149 Image/BuildKernel/Template/IOMEGA_IX2_200=$(call Image/BuildKernel/Template,iomega_ix2_200)
150 Image/BuildKernel/Template/NSA310S=$(call Image/BuildKernel/Template,nsa310s)
151 Image/BuildKernel/Template/POGOE02=$(call Image/BuildKernel/Template,pogo_e02)
152 Image/BuildKernel/Template/SHEEVAPLUG=$(call Image/BuildKernel/Template,sheevaplug)
153 Image/BuildKernel/Template/SHEEVAPLUGSATA=$(call Image/BuildKernel/Template,sheevaplug-esata)
154 Image/BuildKernel/Template/GuruplugServerPlus=$(call Image/BuildKernel/Template,guruplug-server-plus)
155 Image/BuildKernel/Template/Topkick1281P2=$(call Image/BuildKernel/Template,topkick)
157 define Image/BuildKernel
158 $(call Image/BuildKernel/Template/$(PROFILE))
161 define Image/InstallKernel
162 $(call Image/InstallKernel/Template/$(PROFILE))
166 $(if $(Image/Build/$(1)), \
167 $(call Image/Build/$(1),$(1)), \
168 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE_SANITIZED)-$(1).img \
172 $(eval $(call BuildImage))