gemini: split up DEVICE_TITLE
[openwrt/staging/lynxis.git] / target / linux / gemini / image / Makefile
1 #
2 # Copyright (C) 2009-2018 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 # Cook a "WRGG" image, this board is apparently one in the D-Link
11 # WRGG family and uses the exact same firmware format as other
12 # D-Link devices.
13 define Build/dir685-image
14 mkwrggimg -i $@ \
15 -o $@.new \
16 -d /dev/mtdblock/1 \
17 -s wrgns01_dlwbr_dir685RBWW \
18 -v 'N/A' \
19 -m dir685 \
20 -B 96bb
21
22 mv $@.new $@
23 endef
24
25 # Padding added after the rootfs to an even 128k boundary
26 # as this is 128k eraseblocks flash.
27 define Build/dir685-pad-rootfs
28 $(STAGING_DIR_HOST)/bin/padjffs2 $(IMAGE_ROOTFS) -c 128 >>$@
29 endef
30
31 # Build D-Link DNS-313 images using the special header tool.
32 # rootfs.tgz and rd.tgz contains nothing, we only need them
33 # to satisfy the boot loader on the device. The zImage is
34 # the only real content.
35 define Build/dns313-images
36 mkdir -p $@.tmp/.boot
37 chmod 755 $@.tmp/.boot
38
39 echo "dummy" > $@.tmp/dummyfile
40
41 dns313-header $@.tmp/dummyfile \
42 $@.tmp/.boot/rootfs.tgz
43 dns313-header $@.tmp/dummyfile \
44 $@.tmp/.boot/rd.gz
45 dns313-header $(IMAGE_KERNEL) \
46 $@.tmp/.boot/zImage
47
48 rm $@.tmp/dummyfile
49
50 genext2fs --block-size $(BLOCKSIZE:%k=%Ki) \
51 --size-in-blocks $$((1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE))) \
52 --squash-uids \
53 --root $@.tmp $@.tmp-boot
54
55 # The device firmware needs revision 1 of EXT2
56 tune2fs -O filetype $@.tmp-boot
57 e2fsck -pDf $@.tmp-boot > /dev/null
58
59 ./dns313_gen_hdd_img.sh $@ $@.tmp-boot $(IMAGE_ROOTFS) \
60 $(CONFIG_TARGET_KERNEL_PARTSIZE) \
61 $(CONFIG_TARGET_ROOTFS_PARTSIZE)
62
63 rm -rf $@.tmp
64 endef
65
66 define Build/wiligear-image
67 $(STAGING_DIR_HOST)/bin/mkfwimage2 \
68 -m GEOS -f 0x30000000 -z \
69 -v $(1).v5.00.SL3512.OpenWrt.00000.000000.000000 \
70 -p Kernel:0x020000:0x100000:0:0:$(IMAGE_KERNEL) \
71 -p Ramdisk:0x120000:0x500000:0:0:$@ \
72 -o $@.new
73
74 mv $@.new $@
75 endef
76
77 # Create the default image format used by the StorLink reference design
78 # SL93512r, Raidsonic NAS4220B and Itian Square One SQ201
79 # with the squashfs and overlay inside the "rd.gz" file.
80 # We pad it out to 6144K which is the size of the initramfs partition.
81 #
82 # The "application" partition is just blank. You can put anything
83 # there when using OpenWRT. We just use that to create the
84 # "sysupgrade" firmware image.
85 define Build/storlink-default-images
86 mkdir -p $@.tmp
87
88 mv $@ $@.tmp/rd.gz
89 dd if=/dev/zero of=$@.tmp/hddapp.tgz bs=6144k count=1
90 cp $(IMAGE_KERNEL) $@.tmp/zImage
91 cp ./ImageInfo-$(1) $@.tmp/ImageInfo
92
93 sed -i -e "s/DATESTR/`date +%Y%m%d $(if $(SOURCE_DATE_EPOCH),--date "@$(SOURCE_DATE_EPOCH)")`/g" $@.tmp/ImageInfo
94
95 (cd $@.tmp; tar --sort=name --owner=0 --group=0 --numeric-owner -czf $@ * \
96 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)"))
97
98 rm -rf $@.tmp
99 endef
100
101 # WBD-111 and WBD-222:
102 # work around the bootloader's bug with extra nops
103 # FIXME: is this really needed now that we no longer append the code
104 # to change the machine ID number? Needs testing on Wiliboard.
105 define Build/wbd-nops
106 mv $@ $@.tmp
107 echo -en "\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1" > $@
108 cat $@.tmp >> $@
109 rm -f $@.tmp
110 endef
111
112 # All DTB files are prefixed with "gemini-"
113 define Device/Default
114 PROFILES := Default
115 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
116 KERNEL_NAME := zImage
117 KERNEL := kernel-bin | append-dtb
118 BLOCKSIZE := 128k
119 SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
120 endef
121
122 # A reasonable set of default packages handling the NAS type
123 # of devices out of the box (former NAS42x0 IcyBox defaults)
124 GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \
125 kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-md-raid456 \
126 kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \
127 kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \
128 kmod-nls-utf8 kmod-usb-storage-extras \
129 samba36-server mdadm cfdisk fdisk e2fsprogs badblocks \
130 partx-utils
131
132 # The DIR-685 flash layout is kernel in WRGG format, padded and followed
133 # by the appended rootfs followed by some reasonable JFFS padding, the
134 # remainder will be used by JFFS2 through overlayfs.
135 #
136 # - For the factory image, the WRGG image includes the rootfs so that the
137 # default firmware will flash it properly as all it knows is WRGG format.
138 # - For the sysupgrade, we do not include the rootfs in the kernel image
139 # so it is not needelessly tossed into the RAM by the boot loader.
140 # This will be flashed from OpenWrt userland anyways so we only need
141 # the minimum to make the boot loader happy.
142 define Device/dlink_dir-685
143 DEVICE_VENDOR := D-Link
144 DEVICE_MODEL := DIR-685 Xtreme N Storage Router
145 DEVICE_DTS := gemini-dlink-dir-685
146 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \
147 kmod-rt2800-pci
148 IMAGES := factory.bin sysupgrade.bin
149 # Pad to 128k erase blocks with 160 bytes WRGG header
150 IMAGE/factory.bin := append-kernel | pad-offset 128k 160 | append-rootfs | dir685-pad-rootfs | dir685-image
151 IMAGE/sysupgrade.bin := append-kernel | pad-offset 128k 160 | dir685-image | append-rootfs | dir685-pad-rootfs | append-metadata
152 endef
153 TARGET_DEVICES += dlink_dir-685
154
155 define Device/dlink_dns-313
156 DEVICE_VENDOR := D-Link
157 DEVICE_MODEL := DNS-313 1-Bay Network Storage Enclosure
158 DEVICE_DTS := gemini-dlink-dns-313
159 DEVICE_TYPE := nas
160 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
161 BLOCKSIZE := 1k
162 FILESYSTEMS := ext4
163 IMAGES := factory.bin.gz
164 IMAGE/factory.bin.gz := dns313-images | gzip
165 endef
166 TARGET_DEVICES += dlink_dns-313
167
168 # Default images setup used by the StorLink reference designs
169 define Device/storlink-reference
170 IMAGES := factory.bin
171 IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 6144k | \
172 storlink-default-images $(1)
173 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
174 endef
175
176 define Device/itian_sq201
177 $(Device/storlink-reference)
178 DEVICE_VENDOR := ITian
179 DEVICE_MODEL := Square One SQ201
180 DEVICE_DTS := gemini-sq201
181 DEVICE_PACKAGES += kmod-rt61-pci kmod-usb2-pci
182 endef
183 TARGET_DEVICES += itian_sq201
184
185 define Device/raidsonic_ib-4220-b
186 $(Device/storlink-reference)
187 DEVICE_VENDOR := Raidsonic
188 DEVICE_MODEL := NAS IB-4220-B
189 DEVICE_DTS := gemini-nas4220b
190 DEVICE_TYPE := nas
191 endef
192 TARGET_DEVICES += raidsonic_ib-4220-b
193
194 define Device/storlink_sl93512r
195 $(Device/storlink-reference)
196 DEVICE_VENDOR := StorLink
197 DEVICE_MODEL := SL93512r
198 DEVICE_DTS := gemini-sl93512r
199 endef
200 TARGET_DEVICES += storlink_sl93512r
201
202
203 # The wiliboard images need some changes to be functional and buildable.
204 #
205 # The dts would need to use the ecoscentric,redboot-fis-partitions partition
206 # parser to get the correct partition offsets and size.
207 #
208 # The mkfwimage2 call need to be adjusted to reflect the real size of kernel
209 # and rootfs. It is expected that the OEM firmware adjusts the on flash
210 # partition table with the values defined in the image header.
211 define Device/wiliboard_wbd111
212 DEVICE_VENDOR := Wiliboard
213 DEVICE_MODEL := WBD-111
214 DEVICE_DTS := gemini-wbd111
215 KERNEL := kernel-bin | append-dtb | wbd-nops
216 IMAGES := factory.bin
217 IMAGE/factory.bin := append-rootfs | pad-rootfs | wiligear-image "WILI-S.WILIBOARD"
218 endef
219
220 define Device/wiliboard_wbd222
221 DEVICE_VENDOR := Wiliboard
222 DEVICE_MODEL := WBD-222
223 DEVICE_DTS := gemini-wbd222
224 KERNEL := kernel-bin | append-dtb | wbd-nops
225 IMAGES := factory.bin
226 IMAGE/factory.bin := append-rootfs | pad-rootfs | wiligear-image "WILI-S.WBD222"
227 endef
228
229 $(eval $(call BuildImage))