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