2 # Copyright (C) 2009-2018 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
10 define Build
/copy-kernel.bin
11 $(call locked
,$(MAKE
) -C copy-kernel CROSS_COMPILE
=$(TARGET_CROSS
) O
=$(KDIR
),gemini-copy-kernel.bin
)
14 # Cook a "WRGG" image, this board is apparently one in the D-Link
15 # WRGG family and uses the exact same firmware format as other
17 define Build
/dir685-image
21 -s wrgns01_dlwbr_dir685RBWW \
29 # Padding added after the rootfs to an even 128k boundary
30 # as this is 128k eraseblocks flash.
31 define Build
/dir685-pad-rootfs
32 $(STAGING_DIR_HOST
)/bin
/padjffs2
$(IMAGE_ROOTFS
) -c
128 >>$@
35 # Build D-Link DNS-313 images using the special header tool.
36 # rootfs.tgz and rd.tgz contains nothing, we only need them
37 # to satisfy the boot loader on the device. The zImage is
38 # the only real content.
39 define Build
/dns313-images
41 chmod
755 $@.tmp
/.boot
43 echo
"dummy" > $@.tmp
/dummyfile
45 dns313-header
$@.tmp
/dummyfile \
46 $@.tmp
/.boot
/rootfs.tgz
47 dns313-header
$@.tmp
/dummyfile \
49 dns313-header
$(IMAGE_KERNEL
) \
54 genext2fs
--block-size
$(BLOCKSIZE
:%k
=%Ki
) \
55 --size-in-blocks
$$((1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE
))) \
57 --root
$@.tmp
$@.tmp-boot
59 # The device firmware needs revision 1 of EXT2
60 tune2fs
-O filetype
$@.tmp-boot
61 e2fsck
-pDf
$@.tmp-boot
> /dev
/null
63 .
/dns313_gen_hdd_img.sh
$@
$@.tmp-boot
$(IMAGE_ROOTFS
) \
64 $(CONFIG_TARGET_KERNEL_PARTSIZE
) \
65 $(CONFIG_TARGET_ROOTFS_PARTSIZE
)
70 define Build
/wiligear-image
71 $(STAGING_DIR_HOST
)/bin
/mkfwimage2 \
72 -m GEOS
-f
0x30000000 -z \
73 -v
$(1).v5.00.SL3512.OpenWrt
.00000.000000.000000 \
74 -p Kernel
:0x020000:0x100000:0:0:$(IMAGE_KERNEL
) \
75 -p Ramdisk
:0x120000:0x500000:0:0:$@ \
81 # Create the default image format used by the StorLink reference design
82 # SL93512r, Raidsonic NAS4220B and Itian Square One SQ201
83 # with the squashfs and overlay inside the "application" partition.
85 # These devices have a hard-coded partition table that the boot loader
86 # constantly reflashes back, so we need to work around it like this:
88 # 0x000000120000-0x000000320000 : "Kern" - small copy routine and first
89 # part of the kernel goes here
90 # 0x000000320000-0x000000920000 : "Ramdisk" - second part of the kernel and
91 # some padding goes here
92 # 0x000000920000-0x000000f20000 : "Application" - rootfs goes here
93 define Build
/storlink-default-images
96 # "App" partition is the rootfs
97 mv
$@
$@.tmp
/hddapp.tgz
98 # 256 bytes copy routine
99 dd if
=$(KDIR
)/copy-kernel.bin of
=$@.tmp
/zImage
100 $(call Image
/pad-to
,$@.tmp
/zImage
,512)
101 # Copy first part of the kernel into zImage
102 dd if
=$(IMAGE_KERNEL
) of
=$@.tmp
/zImage bs
=1 seek
=512 count
=2096640
103 # Put the rest of the kernel into the "ramdisk"
104 dd if
=$(IMAGE_KERNEL
) of
=$@.tmp
/rd.gz bs
=1 skip
=2096640 count
=6144k conv
=sync
105 cp .
/ImageInfo-
$(1) $@.tmp
/ImageInfo
107 sed
-i
-e
"s/DATESTR/`date +%Y%m%d $(if $(SOURCE_DATE_EPOCH),--date "@
$(SOURCE_DATE_EPOCH
)")`/g" $@.tmp
/ImageInfo
109 (cd
$@.tmp
; tar --sort=name
--owner
=0 --group
=0 --numeric-owner
-czf
$@
* \
110 $(if
$(SOURCE_DATE_EPOCH
),--mtime
="@$(SOURCE_DATE_EPOCH)"))
115 # WBD-111 and WBD-222:
116 # work around the bootloader's bug with extra nops
117 # FIXME: is this really needed now that we no longer append the code
118 # to change the machine ID number? Needs testing on Wiliboard.
119 define Build
/wbd-nops
121 echo
-en
"\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1" > $@
126 # All DTB files are prefixed with "gemini-"
127 define Device
/Default
129 KERNEL_DEPENDS
= $$(wildcard $(DTS_DIR
)/$$(DEVICE_DTS
).dts
)
130 KERNEL_NAME
:= zImage
131 KERNEL
:= kernel-bin | append-dtb
133 SUPPORTED_DEVICES
:= $(subst _
,$(comma
),$(1))
136 # A reasonable set of default packages handling the NAS type
137 # of devices out of the box (former NAS42x0 IcyBox defaults)
138 GEMINI_NAS_PACKAGES
:= $(DEFAULT_PACKAGES.nas
) \
139 kmod-md-mod kmod-md-linear kmod-md-multipath \
140 kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-md-raid456 \
141 kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \
142 kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \
143 kmod-nls-utf8 kmod-usb-storage-extras kmod-hwmon-drivetemp \
144 cfdisk e2fsprogs badblocks \
147 # The DIR-685 flash layout is kernel in WRGG format, padded and followed
148 # by the appended rootfs followed by some reasonable JFFS padding, the
149 # remainder will be used by JFFS2 through overlayfs.
151 # - For the factory image, the WRGG image includes the rootfs so that the
152 # default firmware will flash it properly as all it knows is WRGG format.
153 # - For the sysupgrade, we do not include the rootfs in the kernel image
154 # so it is not needelessly tossed into the RAM by the boot loader.
155 # This will be flashed from OpenWrt userland anyways so we only need
156 # the minimum to make the boot loader happy.
157 define Device
/dlink_dir-685
158 DEVICE_VENDOR
:= D-Link
159 DEVICE_MODEL
:= DIR-685 Xtreme N Storage Router
160 DEVICE_DTS
:= gemini-dlink-dir-685
161 DEVICE_PACKAGES
:= $(GEMINI_NAS_PACKAGES
) \
163 IMAGES
:= factory.bin sysupgrade.bin
164 # Pad to 128k erase blocks with 160 bytes WRGG header
165 IMAGE
/factory.bin
:= append-kernel | pad-offset
128k
160 | append-rootfs | dir685-pad-rootfs | dir685-image
166 IMAGE
/sysupgrade.bin
:= append-kernel | pad-offset
128k
160 | dir685-image | append-rootfs | dir685-pad-rootfs | append-metadata
168 TARGET_DEVICES
+= dlink_dir-685
170 define Device
/dlink_dns-313
171 DEVICE_VENDOR
:= D-Link
172 DEVICE_MODEL
:= DNS-313
1-Bay Network Storage Enclosure
173 DEVICE_DTS
:= gemini-dlink-dns-313
175 DEVICE_PACKAGES
:= $(GEMINI_NAS_PACKAGES
)
178 IMAGES
:= factory.bin.gz
179 IMAGE
/factory.bin.gz
:= dns313-images | gzip
181 TARGET_DEVICES
+= dlink_dns-313
183 # Default images setup used by the StorLink reference designs
184 define Device
/storlink-reference
185 COMPILE
:= copy-kernel-
$(1).bin
186 COMPILE
/copy-kernel-
$(1).bin
:= copy-kernel.bin
187 IMAGES
:= factory.bin
188 IMAGE
/factory.bin
:= append-rootfs | pad-rootfs | pad-to
6144k | \
189 storlink-default-images
$(1)
190 DEVICE_PACKAGES
:= $(GEMINI_NAS_PACKAGES
)
193 define Device
/itian_sq201
194 $(Device
/storlink-reference
)
195 DEVICE_VENDOR
:= ITian
196 DEVICE_MODEL
:= Square One SQ201
197 DEVICE_DTS
:= gemini-sq201
198 DEVICE_PACKAGES
+= kmod-rt61-pci kmod-usb2-pci
200 TARGET_DEVICES
+= itian_sq201
202 define Device
/raidsonic_ib-4220-b
203 $(Device
/storlink-reference
)
204 DEVICE_VENDOR
:= Raidsonic
205 DEVICE_MODEL
:= NAS IB-4220-B
206 DEVICE_DTS
:= gemini-nas4220b
209 TARGET_DEVICES
+= raidsonic_ib-4220-b
211 define Device
/storlink_sl93512r
212 $(Device
/storlink-reference
)
213 DEVICE_VENDOR
:= StorLink
214 DEVICE_MODEL
:= SL93512r
215 DEVICE_DTS
:= gemini-sl93512r
217 TARGET_DEVICES
+= storlink_sl93512r
220 # The wiliboard images need some changes to be functional and buildable.
222 # The dts would need to use the ecoscentric,redboot-fis-partitions partition
223 # parser to get the correct partition offsets and size.
225 # The mkfwimage2 call need to be adjusted to reflect the real size of kernel
226 # and rootfs. It is expected that the OEM firmware adjusts the on flash
227 # partition table with the values defined in the image header.
228 define Device
/wiliboard_wbd111
229 DEVICE_VENDOR
:= Wiliboard
230 DEVICE_MODEL
:= WBD-111
231 DEVICE_DTS
:= gemini-wbd111
232 KERNEL
:= kernel-bin | append-dtb | wbd-nops
233 IMAGES
:= factory.bin
234 IMAGE
/factory.bin
:= append-rootfs | pad-rootfs | wiligear-image
"WILI-S.WILIBOARD"
237 define Device
/wiliboard_wbd222
238 DEVICE_VENDOR
:= Wiliboard
239 DEVICE_MODEL
:= WBD-222
240 DEVICE_DTS
:= gemini-wbd222
241 KERNEL
:= kernel-bin | append-dtb | wbd-nops
242 IMAGES
:= factory.bin
243 IMAGE
/factory.bin
:= append-rootfs | pad-rootfs | wiligear-image
"WILI-S.WBD222"
246 $(eval
$(call BuildImage
))