gemini: create zImage for DIR-685
[oweals/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 # Just copy the zImage for D-Link DIR-685
11 define Build/dir685-images
12         cp $(IMAGE_KERNEL) $(BIN_DIR)/$(IMG_PREFIX)-dir685-zImage
13 endef
14
15 # Build D-Link DNS-313 images using the special header tool.
16 # rootfs.tgz and rd.tgz contains nothing, we only need them
17 # to satisfy the boot loader on the device. The zImage is
18 # the only real content.
19 define Build/dns313-images
20         if [ -d $(BIN_DIR)/.boot ] ; then rm -rf $(BIN_DIR)/.boot ; fi
21         mkdir -p $(BIN_DIR)/.boot
22         echo "dummy" > $(BIN_DIR)/.boot/dummyfile
23         dns313-header $(BIN_DIR)/.boot/dummyfile \
24                 $(BIN_DIR)/.boot/rootfs.tgz
25         dns313-header $(BIN_DIR)/.boot/dummyfile \
26                 $(BIN_DIR)/.boot/rd.gz
27         dns313-header $(IMAGE_KERNEL) \
28                 $(BIN_DIR)/.boot/zImage
29         rm -f $(BIN_DIR)/.boot/dummyfile
30         (cd $(BIN_DIR); tar -czf $(IMG_PREFIX)-dns313-bootpart.tar.gz .boot)
31         if [ -d $(BIN_DIR)/.boot ] ; then rm -rf $(BIN_DIR)/.boot ; fi
32 endef
33
34 # Create the special NAS4220B image format with the squashfs
35 # split across two "partitions" named rd.gz and hddapp.tgz but
36 # essentially just being used by OpenWRT as one big partition
37 define Build/nas4220b-images
38         dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/rd.gz bs=6144k conv=sync
39         dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/hddapp.tgz bs=6144k count=1 seek=1
40         cp $(IMAGE_KERNEL) $(BIN_DIR)/zImage
41         cp ./ImageInfo-ib4220 $(BIN_DIR)/ImageInfo
42         (cd $(BIN_DIR); tar -czf $(IMG_PREFIX)-sysupgrade-ib4220b.tar.gz ImageInfo zImage rd.gz hddapp.tgz)
43         mv $(BIN_DIR)/rd.gz $(BIN_DIR)/$(IMG_PREFIX)-nas4220b-rd.gz
44         mv $(BIN_DIR)/hddapp.tgz $(BIN_DIR)/$(IMG_PREFIX)-nas4220b-hddapp.tgz
45         mv $(BIN_DIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-nas4220b-zImage
46         rm -f $(BIN_DIR)/ImageInfo
47 endef
48
49 # WBD-111 and WBD-222:
50 # work around the bootloader's bug with extra nops
51 # FIXME: is this really needed now that we no longer append the code
52 # to change the machine ID number? Needs testing on Wiliboard.
53 define Build/wbd-nops
54         mv $@ $@.tmp
55         echo -en "\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1\x00\x00\xa0\xe1" > $@
56         cat $@.tmp >> $@
57         rm -f $@.tmp
58 endef
59
60 # All DTB files are prefixed with "gemini-"
61 define Device/Default
62         DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
63         KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
64         KERNEL_NAME := zImage
65         KERNEL := kernel-bin | append-dtb
66         FILESYSTEMS := squashfs
67         IMAGE_NAME := $$(IMAGE_PREFIX)-$$(1).$$(2)
68         BLOCKSIZE := 128k
69         PAGESIZE := 2048
70 endef
71
72 # A reasonable set of default packages handling the NAS type
73 # of devices out of the box (former NAS42x0 IcyBox defaults)
74 GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \
75                 kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-md-raid456 \
76                 kmod-fs-btrfs kmod-fs-cifs kmod-fs-nfs \
77                 kmod-fs-nfsd kmod-fs-ntfs kmod-fs-reiserfs kmod-fs-vfat \
78                 kmod-nls-utf8 kmod-usb-storage-extras \
79                 samba36-server mdadm cfdisk fdisk e2fsprogs badblocks
80
81 define Device/dlink-dir-685
82         DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router
83         DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \
84                         kmod-switch-rtl8366rb swconfig
85         IMAGES += dir685-image
86         IMAGE/dir685-image := dir685-images
87 endef
88 TARGET_DEVICES += dlink-dir-685
89
90 define Device/dlink-dns-313
91         DEVICE_TITLE := D-Link DNS-313 1-Bay Network Storage Enclosure
92         DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
93         IMAGES += dns313-image
94         IMAGE/dns313-image := dns313-images
95 endef
96 TARGET_DEVICES += dlink-dns-313
97
98 define Device/nas4220b
99         DEVICE_TITLE := Raidsonic NAS IB-4220-B
100         IMAGES += nas4220b-image
101         IMAGE/nas4220b-image := nas4220b-images
102         DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
103 endef
104 TARGET_DEVICES += nas4220b
105
106 define Device/rut1xx
107         DEVICE_TITLE := Teltonika RUT1xx
108         DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES)
109 endef
110 TARGET_DEVICES += rut1xx
111
112 define Device/sq201
113         DEVICE_TITLE := ITian Square One SQ201
114         DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) rt61-pci-firmware
115 endef
116 TARGET_DEVICES += sq201
117
118 define Device/wbd111
119         DEVICE_TITLE := Wiliboard WBD-111
120         KERNEL := kernel-bin | append-dtb | wbd-nops
121 endef
122 TARGET_DEVICES += wbd111
123
124 define Device/wbd222
125         DEVICE_TITLE := Wiliboard WBD-222
126         KERNEL := kernel-bin | append-dtb | wbd-nops
127 endef
128 TARGET_DEVICES += wbd222
129
130 $(eval $(call BuildImage))