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