gemini: lazy set IMAGE_NAME
[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 image format with the squashfs
43 # and overlay inside the "rd.gz" file. We pad it out to 6144K
44 # 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-images
50 dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/rd.gz bs=6144k conv=sync
51 dd if=/dev/zero of=$(BIN_DIR)/hddapp.tgz bs=6144k count=1
52 cp $(IMAGE_KERNEL) $(BIN_DIR)/zImage
53 cp ./ImageInfo-ib4220 $(BIN_DIR)/ImageInfo
54 (cd $(BIN_DIR); tar -czf $(IMG_PREFIX)-sysupgrade-ib4220b.tar.gz ImageInfo zImage rd.gz hddapp.tgz)
55 mv $(BIN_DIR)/rd.gz $(BIN_DIR)/$(IMG_PREFIX)-nas4220b-rd.gz
56 rm $(BIN_DIR)/hddapp.tgz
57 mv $(BIN_DIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-nas4220b-zImage
58 rm -f $(BIN_DIR)/ImageInfo
59 endef
60
61 # The Itian Square One SQ201 uses the same method.
62 define Build/sq201-images
63 dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/rd.gz bs=6144k conv=sync
64 dd if=/dev/zero of=$(BIN_DIR)/hddapp.tgz bs=6144k count=1
65 cp $(IMAGE_KERNEL) $(BIN_DIR)/zImage
66 cp ./ImageInfo-sq201 $(BIN_DIR)/ImageInfo
67 sed -i -e "s/DATESTR/`date +%Y%m%d`/g" $(BIN_DIR)/ImageInfo
68 (cd $(BIN_DIR); tar -czf $(IMG_PREFIX)-sysupgrade-sq201.tar.gz ImageInfo zImage rd.gz hddapp.tgz)
69 mv $(BIN_DIR)/rd.gz $(BIN_DIR)/$(IMG_PREFIX)-sq201-rd.gz
70 rm $(BIN_DIR)/hddapp.tgz
71 mv $(BIN_DIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-sq201-zImage
72 rm -f $(BIN_DIR)/ImageInfo
73 endef
74
75
76 # WBD-111 and WBD-222:
77 # work around the bootloader's bug with extra nops
78 # FIXME: is this really needed now that we no longer append the code
79 # to change the machine ID number? Needs testing on Wiliboard.
80 define Build/wbd-nops
81 mv $@ $@.tmp
82 echo -en "\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1" > $@
83 cat $@.tmp >> $@
84 rm -f $@.tmp
85 endef
86
87 # All DTB files are prefixed with "gemini-"
88 define Device/Default
89 DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
90 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
91 KERNEL_NAME := zImage
92 KERNEL := kernel-bin | append-dtb
93 FILESYSTEMS := squashfs
94 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
95 BLOCKSIZE := 128k
96 PAGESIZE := 2048
97 endef
98
99 # A reasonable set of default packages handling the NAS type
100 # of devices out of the box (former NAS42x0 IcyBox defaults)
101 GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \
102 kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-md-raid456 \
103 kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \
104 kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \
105 kmod-nls-utf8 kmod-usb-storage-extras \
106 samba36-server mdadm cfdisk fdisk e2fsprogs badblocks
107
108 define Device/dlink-dir-685
109 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router
110 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \
111 kmod-switch-rtl8366rb swconfig \
112 rt2800-pci
113 IMAGES += dir685-image
114 IMAGE/dir685-image := dir685-images
115 endef
116 TARGET_DEVICES += dlink-dir-685
117
118 define Device/dlink-dns-313
119 DEVICE_TITLE := D-Link DNS-313 1-Bay Network Storage Enclosure
120 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
121 IMAGES += dns313-image
122 IMAGE/dns313-image := dns313-images
123 endef
124 TARGET_DEVICES += dlink-dns-313
125
126 define Device/nas4220b
127 DEVICE_TITLE := Raidsonic NAS IB-4220-B
128 IMAGES += nas4220b-image
129 IMAGE/nas4220b-image := nas4220b-images
130 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
131 endef
132 TARGET_DEVICES += nas4220b
133
134 define Device/rut1xx
135 DEVICE_TITLE := Teltonika RUT1xx
136 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
137 endef
138 TARGET_DEVICES += rut1xx
139
140 define Device/sq201
141 DEVICE_TITLE := ITian Square One SQ201
142 IMAGES += sq201-image
143 IMAGE/sq201-image := sq201-images
144 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) rt61-pci usb2-pci
145 endef
146 TARGET_DEVICES += sq201
147
148 define Device/wbd111
149 DEVICE_TITLE := Wiliboard WBD-111
150 KERNEL := kernel-bin | append-dtb | wbd-nops
151 endef
152 TARGET_DEVICES += wbd111
153
154 define Device/wbd222
155 DEVICE_TITLE := Wiliboard WBD-222
156 KERNEL := kernel-bin | append-dtb | wbd-nops
157 endef
158 TARGET_DEVICES += wbd222
159
160 $(eval $(call BuildImage))