gemini: Generate harddisk image for DNS-313
[openwrt/staging/dedeckeh.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-images
14 mkwrggimg -i $(IMAGE_KERNEL) \
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 # Build D-Link DNS-313 images using the special header tool.
26 # rootfs.tgz and rd.tgz contains nothing, we only need them
27 # to satisfy the boot loader on the device. The zImage is
28 # the only real content.
29 define Build/dns313-images
30 mkdir -p $@.tmp/.boot
31 chmod 755 $@.tmp/.boot
32
33 echo "dummy" > $@.tmp/dummyfile
34
35 dns313-header $@.tmp/dummyfile \
36 $@.tmp/.boot/rootfs.tgz
37 dns313-header $@.tmp/dummyfile \
38 $@.tmp/.boot/rd.gz
39 dns313-header $(IMAGE_KERNEL) \
40 $@.tmp/.boot/zImage
41
42 rm $@.tmp/dummyfile
43
44 genext2fs --block-size $(BLOCKSIZE:%k=%Ki) \
45 --size-in-blocks $$((1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE))) \
46 --squash-uids \
47 --root $@.tmp $@.tmp-boot
48
49 # The device firmware needs revision 1 of EXT2
50 tune2fs -O filetype $@.tmp-boot
51 e2fsck -pDf $@.tmp-boot > /dev/null
52
53 ./dns313_gen_hdd_img.sh $@ $@.tmp-boot $(IMAGE_ROOTFS) \
54 $(CONFIG_TARGET_KERNEL_PARTSIZE) \
55 $(CONFIG_TARGET_ROOTFS_PARTSIZE)
56
57 rm -rf $@.tmp
58 endef
59
60 define Build/wiligear-image
61 $(STAGING_DIR_HOST)/bin/mkfwimage2 \
62 -m GEOS -f 0x30000000 -z \
63 -v $(1).v5.00.SL3512.OpenWrt.00000.000000.000000 \
64 -p Kernel:0x020000:0x100000:0:0:$(IMAGE_KERNEL) \
65 -p Ramdisk:0x120000:0x500000:0:0:$@ \
66 -o $@.new
67
68 mv $@.new $@
69 endef
70
71 # Create the special NAS4220B and Itian Square One SQ201 image
72 # format with the squashfs and overlay inside the "rd.gz" file.
73 # We pad it out to 6144K which is the size of the initramfs partition.
74 #
75 # The "application" partition is just blank. You can put anything
76 # there when using OpenWRT. We just use that to create the
77 # "sysupgrade" firmware image.
78 define Build/nas4220b-sq201-images
79 mkdir -p $@.tmp
80
81 mv $@ $@.tmp/rd.gz
82 dd if=/dev/zero of=$@.tmp/hddapp.tgz bs=6144k count=1
83 cp $(IMAGE_KERNEL) $@.tmp/zImage
84 cp ./ImageInfo-$(1) $@.tmp/ImageInfo
85
86 sed -i -e "s/DATESTR/`date +%Y%m%d $(if $(SOURCE_DATE_EPOCH),--date "@$(SOURCE_DATE_EPOCH)")`/g" $@.tmp/ImageInfo
87
88 (cd $@.tmp; tar --sort=name --owner=0 --group=0 --numeric-owner -czf $@ * \
89 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)"))
90
91 rm -rf $@.tmp
92 endef
93
94 # WBD-111 and WBD-222:
95 # work around the bootloader's bug with extra nops
96 # FIXME: is this really needed now that we no longer append the code
97 # to change the machine ID number? Needs testing on Wiliboard.
98 define Build/wbd-nops
99 mv $@ $@.tmp
100 echo -en "\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1" > $@
101 cat $@.tmp >> $@
102 rm -f $@.tmp
103 endef
104
105 # All DTB files are prefixed with "gemini-"
106 define Device/Default
107 PROFILES := Default
108 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
109 KERNEL_NAME := zImage
110 KERNEL := kernel-bin | append-dtb
111 BLOCKSIZE := 128k
112 endef
113
114 # A reasonable set of default packages handling the NAS type
115 # of devices out of the box (former NAS42x0 IcyBox defaults)
116 GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \
117 kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-md-raid456 \
118 kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \
119 kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \
120 kmod-nls-utf8 kmod-usb-storage-extras \
121 samba36-server mdadm cfdisk fdisk e2fsprogs badblocks \
122 partx-utils
123
124 define Device/dlink_dir-685
125 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router
126 DEVICE_DTS := gemini-dlink-dir-685
127 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \
128 kmod-switch-rtl8366rb swconfig \
129 kmod-rt2800-pci
130 IMAGES := factory.bin
131 IMAGE/factory.bin := dir685-images
132 endef
133 TARGET_DEVICES += dlink_dir-685
134
135 define Device/dlink_dns-313
136 DEVICE_TITLE := D-Link DNS-313 1-Bay Network Storage Enclosure
137 DEVICE_DTS := gemini-dlink-dns-313
138 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
139 BLOCKSIZE := 1k
140 FILESYSTEMS := ext4
141 IMAGES := factory.bin.gz
142 IMAGE/factory.bin.gz := dns313-images | gzip
143 endef
144 TARGET_DEVICES += dlink_dns-313
145
146 define Device/itian-raidsonic
147 IMAGES := factory.bin
148 IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 6144k | \
149 nas4220b-sq201-images $(1)
150 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
151 endef
152
153 define Device/itian_sq201
154 $(Device/itian-raidsonic)
155 DEVICE_TITLE := ITian Square One SQ201
156 DEVICE_DTS := gemini-sq201
157 DEVICE_PACKAGES += kmod-rt61-pci kmod-usb2-pci
158 endef
159 TARGET_DEVICES += itian_sq201
160
161 define Device/raidsonic_ib-4220-b
162 $(Device/itian-raidsonic)
163 DEVICE_TITLE := Raidsonic NAS IB-4220-B
164 DEVICE_DTS := gemini-nas4220b
165 endef
166 TARGET_DEVICES += raidsonic_ib-4220-b
167
168 # The wiliboard images need some changes to be functional and buildable.
169 #
170 # The dts would need to use the ecoscentric,redboot-fis-partitions partition
171 # parser to get the correct partition offsets and size.
172 #
173 # The mkfwimage2 call need to be adjusted to reflect the real size of kernel
174 # and rootfs. It is expected that the OEM firmware adjusts the on flash
175 # partition table with the values defined in the image header.
176 define Device/wiliboard_wbd111
177 DEVICE_TITLE := Wiliboard WBD-111
178 DEVICE_DTS := gemini-wbd111
179 KERNEL := kernel-bin | append-dtb | wbd-nops
180 IMAGES := factory.bin
181 IMAGE/factory.bin := append-rootfs | pad-rootfs | wiligear-image "WILI-S.WILIBOARD"
182 endef
183
184 define Device/wiliboard_wbd222
185 DEVICE_TITLE := Wiliboard WBD-222
186 DEVICE_DTS := gemini-wbd222
187 KERNEL := kernel-bin | append-dtb | wbd-nops
188 IMAGES := factory.bin
189 IMAGE/factory.bin := append-rootfs | pad-rootfs | wiligear-image "WILI-S.WBD222"
190 endef
191
192 $(eval $(call BuildImage))