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