apm821xx: use bin file extension for sysupgrade-tar images
[openwrt/openwrt.git] / target / linux / apm821xx / image / Makefile
1 #
2 # This is free software, licensed under the GNU General Public License v2.
3 # See /LICENSE for more information.
4 #
5 include $(TOPDIR)/rules.mk
6 include $(INCLUDE_DIR)/image.mk
7
8 DEVICE_VARS += IMAGE_SIZE DTB_SIZE
9
10 define Build/boot-img
11 $(RM) -rf $@.bootdir
12 mkdir -p $@.bootdir/boot
13
14 $(CP) $@.scr $@.bootdir/boot/boot.scr
15 $(CP) $(IMAGE_KERNEL).dtb $@.bootdir/boot/$(DEVICE_DTB)
16 $(CP) $(IMAGE_KERNEL) $@.bootdir/boot/uImage
17
18 genext2fs --block-size $(BLOCKSIZE:%k=%Ki) --size-in-blocks $$((1024 * $(BOOT_SIZE))) --root $@.bootdir $@.boot
19
20 # convert it to revision 1 - needed for u-boot ext2load
21 $(STAGING_DIR_HOST)/bin/tune2fs -O filetype $@.boot
22 $(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.boot > /dev/null
23 endef
24
25 define Build/boot-script
26 $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T script -C none -n "$(PROFILE) Boot Script" \
27 -d mbl_boot.scr \
28 $@.scr
29 endef
30
31 define Build/copy-file
32 cat "$(1)" > "$@"
33 endef
34
35 define Build/create-uImage-dtb
36 # flat_dt target expect FIT image - which WNDR4700's uboot doesn't support
37 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) \
38 -O linux -T kernel -C none \
39 -n '$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)' \
40 -d "$@.dtb" "$@.dtb.uimage"
41 endef
42
43 define Build/dtb
44 $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,$@.dtb,,--space $(DTB_SIZE))
45 endef
46
47 define Build/export-dtb
48 cp $(IMAGE_KERNEL).dtb $@
49 endef
50
51 define Build/hdd-img
52 ./mbl_gen_hdd_img.sh $@ $@.boot $(IMAGE_ROOTFS) $(BOOT_SIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
53 endef
54
55 define Build/MerakiAdd-dtb
56 $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,$@.dtb)
57 ( \
58 dd if=$@.dtb bs=$(DTB_SIZE) conv=sync; \
59 dd if=$@ bs=$(BLOCKSIZE) conv=sync; \
60 ) > $@.new
61 @mv $@.new $@
62 endef
63
64 define Build/MerakiNAND
65 -$(STAGING_DIR_HOST)/bin/mkmerakifw \
66 -B $(BOARD_NAME) -s \
67 -i $@ \
68 -o $@.new
69 @cp $@.new $@
70 endef
71
72 define Build/MuImage-initramfs
73 rm -rf $@.fakerd $@.new
74
75 dd if=/dev/zero of=$@.fakerd bs=32 count=1 conv=sync
76
77 # Netgear used an old uboot that doesn't have FIT support.
78 # So we are stuck with either a full ext2/4 fs in a initrd.
79 # ... or we try to make the "multi" image approach to work
80 # for us.
81 #
82 # Sadly, the "multi" image has to consists of three
83 # "fixed" parts in the following "fixed" order:
84 # 1. The kernel which is in $@
85 # 2. The (fake) initrd which is in $@.fakerd
86 # 3. The device tree binary which is in $@.dtb
87 #
88 # Now, given that we use the function for the kernel which
89 # already has a initramfs image inside, we still have to
90 # add a "fake" initrd (which a mkimage header) in the second
91 # part of the legacy multi image. Since we need to put the
92 # device tree stuff into part 3.
93
94 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T multi \
95 -C $(1) -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) \
96 -n '$(BOARD_NAME) initramfs' -d $@:$@.fakerd:$@.dtb $@.new
97 mv $@.new $@
98 rm -rf $@.fakerd
99 endef
100
101 define Build/prepend-dtb
102 cat "$@.dtb.uimage" "$@" > "$@.new"
103 mv "$@.new" "$@"
104 endef
105
106 define Image/cpiogz
107 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz )
108 endef
109
110 define Device/Default
111 PROFILES := Default
112 KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
113 DEVICE_DTS :=
114 KERNEL_ENTRY := 0x00000000
115 KERNEL_LOADADDR := 0x00000000
116 DEVICE_DTS_DIR := ../dts
117 SUPPORTED_DEVICES = $(subst _,$(comma),$(1))
118 endef
119
120 ifeq ($(SUBTARGET),nand)
121
122 define Device/meraki_mr24
123 DEVICE_TITLE := Cisco Meraki MR24
124 DEVICE_PACKAGES := kmod-spi-gpio -swconfig
125 BOARD_NAME := mr24
126 DEVICE_DTS := meraki-mr24
127 BLOCKSIZE := 63k
128 IMAGES := sysupgrade.bin
129 DTB_SIZE := 64512
130 IMAGE_SIZE := 8191k
131 KERNEL := kernel-bin | lzma | uImage lzma | MerakiAdd-dtb | MerakiNAND
132 KERNEL_INITRAMFS := kernel-bin | lzma | dtb | MuImage-initramfs lzma
133 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
134 UBINIZE_OPTS := -E 5
135 SUPPORTED_DEVICES += mr24
136 endef
137 TARGET_DEVICES += meraki_mr24
138
139 define Device/meraki_mx60
140 DEVICE_TITLE := Cisco Meraki MX60/MX60W
141 DEVICE_PACKAGES := kmod-spi-gpio kmod-usb-ledtrig-usbport kmod-usb-dwc2 \
142 kmod-usb-storage block-mount
143 BOARD_NAME := mx60
144 DEVICE_DTS := meraki-mx60
145 BLOCKSIZE := 63k
146 IMAGES := sysupgrade.bin
147 DTB_SIZE := 64512
148 IMAGE_SIZE := 1021m
149 KERNEL_SIZE := 4031k
150 KERNEL := kernel-bin | gzip | uImage gzip | MerakiAdd-dtb | MerakiNAND
151 KERNEL_INITRAMFS := kernel-bin | gzip | dtb | MuImage-initramfs gzip
152 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
153 UBINIZE_OPTS := -E 5
154 SUPPORTED_DEVICES += mx60
155 endef
156 TARGET_DEVICES += meraki_mx60
157
158 define Device/netgear_wndap6x0
159 DEVICE_PACKAGES := kmod-eeprom-at24
160 SUBPAGESIZE := 256
161 PAGESIZE := 512
162 BLOCKSIZE := 16k
163 DTB_SIZE := 32768
164 IMAGE_SIZE := 27392k
165 IMAGES := sysupgrade.bin factory.img
166 KERNEL_SIZE := 4032k
167 KERNEL := dtb | kernel-bin | gzip | MuImage-initramfs gzip
168 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
169 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi
170 UBINIZE_OPTS := -E 5
171 endef
172
173 define Device/netgear_wndap620
174 $(Device/netgear_wndap6x0)
175 DEVICE_TITLE := Netgear WNDAP620 - Premium Wireless-N
176 DEVICE_DTS := netgear-wndap620
177 endef
178 TARGET_DEVICES += netgear_wndap620
179
180 define Device/netgear_wndap660
181 $(Device/netgear_wndap6x0)
182 DEVICE_TITLE := Netgear WNDAP660 - Dual Radio Dual Band Wireless-N
183 DEVICE_DTS := netgear-wndap660
184 endef
185 TARGET_DEVICES += netgear_wndap660
186
187 define Device/netgear_wndr4700
188 DEVICE_TITLE := Netgear Centria N900 WNDR4700/WNDR4720
189 DEVICE_PACKAGES := badblocks block-mount e2fsprogs \
190 kmod-dm kmod-fs-ext4 kmod-fs-vfat kmod-usb-ledtrig-usbport \
191 kmod-md-mod kmod-nls-cp437 kmod-nls-iso8859-1 kmod-nls-iso8859-15 \
192 kmod-nls-utf8 kmod-usb3 kmod-usb-dwc2 kmod-usb-storage \
193 partx-utils
194 BOARD_NAME := wndr4700
195 DEVICE_DTS := netgear-wndr4700
196 PAGESIZE := 2048
197 SUBPAGESIZE := 512
198 BLOCKSIZE := 128k
199 DTB_SIZE := 131008
200 IMAGE_SIZE := 24960k
201 IMAGES := factory.img sysupgrade.bin
202 ARTIFACTS := device-tree.dtb
203 KERNEL_SIZE := 3584k
204 # append a fake/empty rootfs to fool netgear's uboot
205 # CHECK_DNI_FIRMWARE_ROOTFS_INTEGRITY in do_chk_dniimg()
206 KERNEL := kernel-bin | lzma | uImage lzma | pad-offset $$(BLOCKSIZE) 64 | \
207 append-uImage-fakehdr filesystem | dtb | create-uImage-dtb | prepend-dtb
208 KERNEL_INITRAMFS := kernel-bin | gzip | dtb | MuImage-initramfs gzip
209 IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | \
210 netgear-dni | check-size $$$$(IMAGE_SIZE)
211 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
212 ARTIFACT/device-tree.dtb := export-dtb | uImage none
213 NETGEAR_BOARD_ID := WNDR4700
214 NETGEAR_HW_ID := 29763875+128+256
215 UBINIZE_OPTS := -E 5
216 SUPPORTED_DEVICES += wndr4700
217 endef
218 TARGET_DEVICES += netgear_wndr4700
219
220 endif
221
222 ifeq ($(SUBTARGET),sata)
223
224 define Device/wd_mybooklive
225 DEVICE_TITLE := Western Digital My Book Live Series (Single + Duo)
226 DEVICE_PACKAGES := kmod-usb-dwc2 kmod-usb-ledtrig-usbport kmod-usb-storage kmod-fs-vfat wpad-basic
227 DEVICE_DTS := wd-mybooklive
228 SUPPORTED_DEVICES += mbl wd,mybooklive-duo
229 BLOCKSIZE := 1k
230 DTB_SIZE := 16384
231 KERNEL := kernel-bin | dtb | gzip | uImage gzip
232 KERNEL_INITRAMFS := kernel-bin | gzip | dtb | MuImage-initramfs gzip
233 BOOT_SIZE := 8
234 IMAGES := factory.img.gz kernel.dtb sysupgrade.img.gz
235 ARTIFACTS := kernel.dtb
236 DEVICE_DTB := apollo3g.dtb
237 FILESYSTEMS := ext4 squashfs
238 IMAGE/factory.img.gz := boot-script | boot-img | hdd-img | gzip
239 IMAGE/sysupgrade.img.gz := boot-script | boot-img | hdd-img | gzip | append-metadata
240 ARTIFACT/apollo3g.dtb := export-dtb
241 endef
242
243 TARGET_DEVICES += wd_mybooklive
244
245 endif
246
247 $(eval $(call BuildImage))