gemini: Cook a WRGG firmware image
[openwrt/staging/wigyori.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 # WBD-111 and WBD-222:
58 # work around the bootloader's bug with extra nops
59 # FIXME: is this really needed now that we no longer append the code
60 # to change the machine ID number? Needs testing on Wiliboard.
61 define Build/wbd-nops
62 mv $@ $@.tmp
63 echo -en "\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1" > $@
64 cat $@.tmp >> $@
65 rm -f $@.tmp
66 endef
67
68 # All DTB files are prefixed with "gemini-"
69 define Device/Default
70 DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
71 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
72 KERNEL_NAME := zImage
73 KERNEL := kernel-bin | append-dtb
74 FILESYSTEMS := squashfs
75 IMAGE_NAME := $$(IMAGE_PREFIX)-$$(1).$$(2)
76 BLOCKSIZE := 128k
77 PAGESIZE := 2048
78 endef
79
80 # A reasonable set of default packages handling the NAS type
81 # of devices out of the box (former NAS42x0 IcyBox defaults)
82 GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \
83 kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-md-raid456 \
84 kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \
85 kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \
86 kmod-nls-utf8 kmod-usb-storage-extras \
87 samba36-server mdadm cfdisk fdisk e2fsprogs badblocks
88
89 define Device/dlink-dir-685
90 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router
91 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \
92 kmod-switch-rtl8366rb swconfig
93 IMAGES += dir685-image
94 IMAGE/dir685-image := dir685-images
95 endef
96 TARGET_DEVICES += dlink-dir-685
97
98 define Device/dlink-dns-313
99 DEVICE_TITLE := D-Link DNS-313 1-Bay Network Storage Enclosure
100 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
101 IMAGES += dns313-image
102 IMAGE/dns313-image := dns313-images
103 endef
104 TARGET_DEVICES += dlink-dns-313
105
106 define Device/nas4220b
107 DEVICE_TITLE := Raidsonic NAS IB-4220-B
108 IMAGES += nas4220b-image
109 IMAGE/nas4220b-image := nas4220b-images
110 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
111 endef
112 TARGET_DEVICES += nas4220b
113
114 define Device/rut1xx
115 DEVICE_TITLE := Teltonika RUT1xx
116 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
117 endef
118 TARGET_DEVICES += rut1xx
119
120 define Device/sq201
121 DEVICE_TITLE := ITian Square One SQ201
122 DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) rt61-pci-firmware
123 endef
124 TARGET_DEVICES += sq201
125
126 define Device/wbd111
127 DEVICE_TITLE := Wiliboard WBD-111
128 KERNEL := kernel-bin | append-dtb | wbd-nops
129 endef
130 TARGET_DEVICES += wbd111
131
132 define Device/wbd222
133 DEVICE_TITLE := Wiliboard WBD-222
134 KERNEL := kernel-bin | append-dtb | wbd-nops
135 endef
136 TARGET_DEVICES += wbd222
137
138 $(eval $(call BuildImage))