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 DEVICE_DTS_DIR
= $$(DTS_DIR
)/gemini
128 KERNEL_DEPENDS
= $$(wildcard $(DTS_DIR
)/$$(DEVICE_DTS
).dts
)
129 KERNEL_NAME
:= zImage
130 KERNEL
:= kernel-bin | append-dtb
134 # A reasonable set of default packages handling the NAS type
135 # of devices out of the box (former NAS42x0 IcyBox defaults)
136 GEMINI_NAS_PACKAGES
:= $(DEFAULT_PACKAGES.nas
) \
137 kmod-md-mod kmod-md-linear kmod-md-multipath \
138 kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-md-raid456 \
139 kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \
140 kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \
141 kmod-nls-utf8 kmod-usb-storage-extras kmod-hwmon-drivetemp \
142 cfdisk e2fsprogs badblocks \
145 # The DIR-685 flash layout is kernel in WRGG format, padded and followed
146 # by the appended rootfs followed by some reasonable JFFS padding, the
147 # remainder will be used by JFFS2 through overlayfs.
149 # - For the factory image, the WRGG image includes the rootfs so that the
150 # default firmware will flash it properly as all it knows is WRGG format.
151 # - For the sysupgrade, we do not include the rootfs in the kernel image
152 # so it is not needelessly tossed into the RAM by the boot loader.
153 # This will be flashed from OpenWrt userland anyways so we only need
154 # the minimum to make the boot loader happy.
155 define Device
/dlink_dir-685
156 DEVICE_VENDOR
:= D-Link
157 DEVICE_MODEL
:= DIR-685 Xtreme N Storage Router
158 DEVICE_DTS
:= gemini-dlink-dir-685
159 DEVICE_PACKAGES
:= $(GEMINI_NAS_PACKAGES
) \
161 IMAGES
:= factory.bin sysupgrade.bin
162 # Pad to 128k erase blocks with 160 bytes WRGG header
163 IMAGE
/factory.bin
:= append-kernel | pad-offset
128k
160 | append-rootfs | dir685-pad-rootfs | dir685-image
164 IMAGE
/sysupgrade.bin
:= append-kernel | pad-offset
128k
160 | dir685-image | append-rootfs | dir685-pad-rootfs | append-metadata
166 TARGET_DEVICES
+= dlink_dir-685
168 define Device
/dlink_dns-313
169 DEVICE_VENDOR
:= D-Link
170 DEVICE_MODEL
:= DNS-313
1-Bay Network Storage Enclosure
171 DEVICE_DTS
:= gemini-dlink-dns-313
172 DEVICE_PACKAGES
:= $(GEMINI_NAS_PACKAGES
)
175 IMAGES
:= factory.bin.gz
176 IMAGE
/factory.bin.gz
:= dns313-images | gzip
178 TARGET_DEVICES
+= dlink_dns-313
180 # Default images setup used by the StorLink reference designs
181 define Device
/storlink-reference
182 COMPILE
:= copy-kernel-
$(1).bin
183 COMPILE
/copy-kernel-
$(1).bin
:= copy-kernel.bin
184 IMAGES
:= factory.bin
185 FILESYSTEMS
:= squashfs
186 IMAGE
/factory.bin
:= append-rootfs | pad-rootfs | pad-to
6144k | \
187 storlink-default-images
$(1)
188 DEVICE_PACKAGES
:= $(GEMINI_NAS_PACKAGES
)
191 define Device
/itian_sq201
192 $(Device
/storlink-reference
)
193 DEVICE_VENDOR
:= ITian
194 DEVICE_MODEL
:= Square One SQ201
195 DEVICE_DTS
:= gemini-sq201
196 DEVICE_PACKAGES
+= kmod-rt61-pci kmod-usb2-pci
198 TARGET_DEVICES
+= itian_sq201
200 define Device
/raidsonic_ib-4220-b
201 $(Device
/storlink-reference
)
202 DEVICE_VENDOR
:= Raidsonic
203 DEVICE_MODEL
:= NAS IB-4220-B
204 DEVICE_DTS
:= gemini-nas4220b
206 TARGET_DEVICES
+= raidsonic_ib-4220-b
208 define Device
/storlink_sl93512r
209 $(Device
/storlink-reference
)
210 DEVICE_VENDOR
:= StorLink
211 DEVICE_MODEL
:= SL93512r
212 DEVICE_DTS
:= gemini-sl93512r
214 TARGET_DEVICES
+= storlink_sl93512r
217 # The wiliboard images need some changes to be functional and buildable.
219 # The dts would need to use the redboot-fis partition parser to get
220 # the correct partition offsets and size.
222 # The mkfwimage2 call need to be adjusted to reflect the real size of kernel
223 # and rootfs. It is expected that the OEM firmware adjusts the on flash
224 # partition table with the values defined in the image header.
225 define Device
/wiliboard_wbd111
226 DEVICE_VENDOR
:= Wiliboard
227 DEVICE_MODEL
:= WBD-111
228 DEVICE_DTS
:= gemini-wbd111
229 KERNEL
:= kernel-bin | append-dtb | wbd-nops
230 IMAGES
:= factory.bin
231 IMAGE
/factory.bin
:= append-rootfs | pad-rootfs | wiligear-image
"WILI-S.WILIBOARD"
234 define Device
/wiliboard_wbd222
235 DEVICE_VENDOR
:= Wiliboard
236 DEVICE_MODEL
:= WBD-222
237 DEVICE_DTS
:= gemini-wbd222
238 KERNEL
:= kernel-bin | append-dtb | wbd-nops
239 IMAGES
:= factory.bin
240 IMAGE
/factory.bin
:= append-rootfs | pad-rootfs | wiligear-image
"WILI-S.WBD222"
243 $(eval
$(call BuildImage
))