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
11 $(MAKE
) -C copy-kernel CROSS_COMPILE
=$(TARGET_CROSS
)
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 $(call Build
/copy-kernel
)
97 # "App" partition is the rootfs
98 mv
$@
$@.tmp
/hddapp.tgz
99 # 256 bytes copy routine
100 dd if
=copy-kernel
/copy-kernel.bin of
=$@.tmp
/zImage
101 $(call Image
/pad-to
,$@.tmp
/zImage
,512)
102 # Copy first part of the kernel into zImage
103 dd if
=$(IMAGE_KERNEL
) of
=$@.tmp
/zImage bs
=1 seek
=512 count
=2096640
104 # Put the rest of the kernel into the "ramdisk"
105 dd if
=$(IMAGE_KERNEL
) of
=$@.tmp
/rd.gz bs
=1 skip
=2096640 count
=6144k conv
=sync
106 cp .
/ImageInfo-
$(1) $@.tmp
/ImageInfo
108 sed
-i
-e
"s/DATESTR/`date +%Y%m%d $(if $(SOURCE_DATE_EPOCH),--date "@
$(SOURCE_DATE_EPOCH
)")`/g" $@.tmp
/ImageInfo
110 (cd
$@.tmp
; tar --sort=name
--owner
=0 --group
=0 --numeric-owner
-czf
$@
* \
111 $(if
$(SOURCE_DATE_EPOCH
),--mtime
="@$(SOURCE_DATE_EPOCH)"))
116 # WBD-111 and WBD-222:
117 # work around the bootloader's bug with extra nops
118 # FIXME: is this really needed now that we no longer append the code
119 # to change the machine ID number? Needs testing on Wiliboard.
120 define Build
/wbd-nops
122 echo
-en
"\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1" > $@
127 # All DTB files are prefixed with "gemini-"
128 define Device
/Default
130 KERNEL_DEPENDS
= $$(wildcard $(DTS_DIR
)/$$(DEVICE_DTS
).dts
)
131 KERNEL_NAME
:= zImage
132 KERNEL
:= kernel-bin | append-dtb
134 SUPPORTED_DEVICES
:= $(subst _
,$(comma
),$(1))
137 # A reasonable set of default packages handling the NAS type
138 # of devices out of the box (former NAS42x0 IcyBox defaults)
139 GEMINI_NAS_PACKAGES
:=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 \
144 samba36-server mdadm cfdisk fdisk 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 IMAGES
:= factory.bin
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
207 TARGET_DEVICES
+= raidsonic_ib-4220-b
209 define Device
/storlink_sl93512r
210 $(Device
/storlink-reference
)
211 DEVICE_VENDOR
:= StorLink
212 DEVICE_MODEL
:= SL93512r
213 DEVICE_DTS
:= gemini-sl93512r
215 TARGET_DEVICES
+= storlink_sl93512r
218 # The wiliboard images need some changes to be functional and buildable.
220 # The dts would need to use the ecoscentric,redboot-fis-partitions partition
221 # parser to get the correct partition offsets and size.
223 # The mkfwimage2 call need to be adjusted to reflect the real size of kernel
224 # and rootfs. It is expected that the OEM firmware adjusts the on flash
225 # partition table with the values defined in the image header.
226 define Device
/wiliboard_wbd111
227 DEVICE_VENDOR
:= Wiliboard
228 DEVICE_MODEL
:= WBD-111
229 DEVICE_DTS
:= gemini-wbd111
230 KERNEL
:= kernel-bin | append-dtb | wbd-nops
231 IMAGES
:= factory.bin
232 IMAGE
/factory.bin
:= append-rootfs | pad-rootfs | wiligear-image
"WILI-S.WILIBOARD"
235 define Device
/wiliboard_wbd222
236 DEVICE_VENDOR
:= Wiliboard
237 DEVICE_MODEL
:= WBD-222
238 DEVICE_DTS
:= gemini-wbd222
239 KERNEL
:= kernel-bin | append-dtb | wbd-nops
240 IMAGES
:= factory.bin
241 IMAGE
/factory.bin
:= append-rootfs | pad-rootfs | wiligear-image
"WILI-S.WBD222"
244 $(eval
$(call BuildImage
))