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