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