gemini: unify and fix ib-nas4220b and sq201 image creation
[openwrt/openwrt.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 $(BIN_DIR)/$(IMG_PREFIX)-dir685-fwupdate.bin \
16 -d /dev/mtdblock/1 \
17 -s wrgns01_dlwbr_dir685RBWW \
18 -v 'N/A' \
19 -m dir685 \
20 -B 96bb
21 endef
22
23 # Build D-Link DNS-313 images using the special header tool.
24 # rootfs.tgz and rd.tgz contains nothing, we only need them
25 # to satisfy the boot loader on the device. The zImage is
26 # the only real content.
27 define Build/dns313-images
28 if [ -d $(BIN_DIR)/.boot ] ; then rm -rf $(BIN_DIR)/.boot ; fi
29 mkdir -p $(BIN_DIR)/.boot
30 echo "dummy" > $(BIN_DIR)/.boot/dummyfile
31 dns313-header $(BIN_DIR)/.boot/dummyfile \
32 $(BIN_DIR)/.boot/rootfs.tgz
33 dns313-header $(BIN_DIR)/.boot/dummyfile \
34 $(BIN_DIR)/.boot/rd.gz
35 dns313-header $(IMAGE_KERNEL) \
36 $(BIN_DIR)/.boot/zImage
37 rm -f $(BIN_DIR)/.boot/dummyfile
38 (cd $(BIN_DIR); tar -czf $(IMG_PREFIX)-dns313-bootpart.tar.gz .boot)
39 if [ -d $(BIN_DIR)/.boot ] ; then rm -rf $(BIN_DIR)/.boot ; fi
40 endef
41
42 # Create the special NAS4220B and Itian Square One SQ201 image
43 # format with the squashfs and overlay inside the "rd.gz" file.
44 # We pad it out to 6144K which is the size of the initramfs partition.
45 #
46 # The "application" partition is just blank. You can put anything
47 # there when using OpenWRT. We just use that to create the
48 # "sysupgrade" firmware image.
49 define Build/nas4220b-sq201-images
50 rm -rf $@-tmp
51 mkdir -p $@-tmp
52 dd if=$(IMAGE_ROOTFS) of=$@-tmp/rd.gz bs=6144k conv=sync
53 dd if=/dev/zero of=$@-tmp/hddapp.tgz bs=6144k count=1
54 cp $(IMAGE_KERNEL) $@-tmp/zImage
55 cp ./ImageInfo-$(1) $@-tmp/ImageInfo
56 (cd $@-tmp; tar --owner=0 --group=0 --numeric-owner --mtime=@$(SOURCE_DATE_EPOCH) \
57 -czf $@ ImageInfo zImage rd.gz hddapp.tgz)
58 rm -rf $@-tmp
59 endef
60
61 # WBD-111 and WBD-222:
62 # work around the bootloader's bug with extra nops
63 # FIXME: is this really needed now that we no longer append the code
64 # to change the machine ID number? Needs testing on Wiliboard.
65 define Build/wbd-nops
66 mv $@ $@.tmp
67 echo -en "\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1" > $@
68 cat $@.tmp >> $@
69 rm -f $@.tmp
70 endef
71
72 # All DTB files are prefixed with "gemini-"
73 define Device/Default
74 DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
75 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
76 KERNEL_NAME := zImage
77 KERNEL := kernel-bin | append-dtb
78 FILESYSTEMS := squashfs
79 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
80 BLOCKSIZE := 128k
81 PAGESIZE := 2048
82 endef
83
84 # A reasonable set of default packages handling the NAS type
85 # of devices out of the box (former NAS42x0 IcyBox defaults)
86 GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \
87 kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-md-raid456 \
88 kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \
89 kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \
90 kmod-nls-utf8 kmod-usb-storage-extras \
91 samba36-server mdadm cfdisk fdisk e2fsprogs badblocks
92
93 define Device/dlink-dir-685
94 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router
95 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \
96 kmod-switch-rtl8366rb swconfig \
97 rt2800-pci
98 IMAGES += dir685-image
99 IMAGE/dir685-image := dir685-images
100 endef
101 TARGET_DEVICES += dlink-dir-685
102
103 define Device/dlink-dns-313
104 DEVICE_TITLE := D-Link DNS-313 1-Bay Network Storage Enclosure
105 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
106 IMAGES += dns313-image
107 IMAGE/dns313-image := dns313-images
108 endef
109 TARGET_DEVICES += dlink-dns-313
110
111 define Device/nas4220b-sq201
112 ARTIFACTS := zImage
113 ARTIFACT/zImage := append-kernel
114 IMAGES += rd.gz sysupgrade.tar.gz
115 IMAGE/rd.gz := append-rootfs | pad-to 6144k
116 IMAGE/sysupgrade.tar.gz := nas4220b-sq201-images $(1)
117 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
118 endef
119
120 define Device/nas4220b
121 $(Device/nas4220b-sq201)
122 DEVICE_TITLE := Raidsonic NAS IB-4220-B
123 endef
124 TARGET_DEVICES += nas4220b
125
126 define Device/rut1xx
127 DEVICE_TITLE := Teltonika RUT1xx
128 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
129 endef
130 TARGET_DEVICES += rut1xx
131
132 define Device/sq201
133 $(Device/nas4220b-sq201)
134 DEVICE_TITLE := ITian Square One SQ201
135 DEVICE_PACKAGES += rt61-pci usb2-pci
136 endef
137 TARGET_DEVICES += sq201
138
139 define Device/wbd111
140 DEVICE_TITLE := Wiliboard WBD-111
141 KERNEL := kernel-bin | append-dtb | wbd-nops
142 endef
143 TARGET_DEVICES += wbd111
144
145 define Device/wbd222
146 DEVICE_TITLE := Wiliboard WBD-222
147 KERNEL := kernel-bin | append-dtb | wbd-nops
148 endef
149 TARGET_DEVICES += wbd222
150
151 $(eval $(call BuildImage))