apm821xx: Add default packages to NAND target
[openwrt/staging/chunkeey.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 include $(INCLUDE_DIR)/host.mk
8
9 DEVICE_VARS += DEVICE_PROFILE IMAGE_SIZE DTB_SIZE
10
11 define Device/Default
12 PROFILES := Default
13 KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
14 DEVICE_PROFILE :=
15 DEVICE_DTS :=
16 KERNEL_ENTRY := 0x00000000
17 KERNEL_LOADADDR := 0x00000000
18 DEVICE_DTS_DIR := ../dts
19 endef
20
21 define Build/dtb
22 $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,$@.dtb,,--space $(DTB_SIZE))
23 endef
24
25 define Build/export-dtb
26 cp $(IMAGE_KERNEL).dtb $@
27 endef
28
29 ifeq ($(SUBTARGET),nand)
30
31 define Image/cpiogz
32 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz )
33 endef
34
35 define Build/copy-file
36 cat "$(1)" > "$@"
37 endef
38
39 define Build/MerakiAdd-dtb
40 $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,$@.dtb)
41 ( \
42 dd if=$@.dtb bs=$(DTB_SIZE) conv=sync; \
43 dd if=$@ bs=$(BLOCKSIZE) conv=sync; \
44 ) > $@.new
45 @mv $@.new $@
46 endef
47
48 define Build/MerakiAdd-initramfs
49 $(call Image/cpiogz)
50
51 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T ramdisk \
52 -C gzip -n "$(PROFILE) rootfs" \
53 -d $(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz \
54 $(KDIR_TMP)/$(IMG_PREFIX)-uramdisk.image.gz
55
56 ( \
57 dd if=$@ bs=1k conv=sync; \
58 dd if=$(KDIR_TMP)/$(IMG_PREFIX)-uramdisk.image.gz bs=$(BLOCKSIZE) conv=sync; \
59 ) > $@.new
60 @mv $@.new $@
61 endef
62
63 define Build/MerakiNAND
64 -$(STAGING_DIR_HOST)/bin/mkmerakifw \
65 -B $(DEVICE_PROFILE) -s \
66 -i $@ \
67 -o $@.new
68 @cp $@.new $@
69 endef
70
71 define Device/mr24
72 DEVICE_TITLE := Cisco Meraki MR24
73 DEVICE_PACKAGES := kmod-spi-gpio
74 DEVICE_PROFILE := MR24
75 DEVICE_DTS := MR24
76 BLOCKSIZE := 63k
77 IMAGES := sysupgrade.tar
78 DTB_SIZE := 64512
79 KERNEL_SIZE := 1984k
80 IMAGE_SIZE := 8191k
81 KERNEL := kernel-bin | lzma | uImage lzma | MerakiAdd-dtb | MerakiNAND
82 KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux | lzma | uImage lzma | \
83 check-size $$(KERNEL_SIZE) | \
84 MerakiAdd-dtb | pad-to 2047k | MerakiAdd-initramfs | \
85 MerakiNAND
86 IMAGE/sysupgrade.tar := sysupgrade-tar
87 UBINIZE_OPTS := -E 5
88 endef
89 TARGET_DEVICES += mr24
90
91 define Device/mx60
92 DEVICE_TITLE := Cisco Meraki MX60
93 DEVICE_PACKAGES := kmod-spi-gpio kmod-usb-ledtrig-usbport kmod-usb-dwc2 \
94 kmod-usb-storage block-mount
95 DEVICE_PROFILE := MX60
96 DEVICE_DTS := MX60
97 BLOCKSIZE := 63k
98 IMAGES := sysupgrade.tar
99 DTB_SIZE := 64512
100 # The kernel size will need to match the offset defined in mkmerakifw.c,
101 # otherwise the final image will fail to boot. This is set within the
102 # MX60 kernel header definition which is found at
103 # ./tools/firmware-utils/src/mkmerakifw.c, line 103~
104 KERNEL_SIZE := 2984k
105 IMAGE_SIZE := 1021m
106 KERNEL := kernel-bin | gzip | uImage gzip | MerakiAdd-dtb | MerakiNAND
107 KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux | gzip | uImage gzip | \
108 check-size $$(KERNEL_SIZE) | \
109 MerakiAdd-dtb | pad-to 2047k | MerakiAdd-initramfs | \
110 MerakiNAND
111 IMAGE/sysupgrade.tar := sysupgrade-tar
112 UBINIZE_OPTS := -E 5
113 endef
114 TARGET_DEVICES += mx60
115
116 define Device/mx60w
117 $(Device/mx60)
118 DEVICE_TITLE := Cisco Meraki MX60W
119 endef
120 TARGET_DEVICES += mx60w
121
122 define Build/create-uImage-dtb
123 # flat_dt target expect FIT image - which WNDR4700's uboot doesn't support
124 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) \
125 -O linux -T kernel -C none \
126 -n '$(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION)' \
127 -d $(IMAGE_KERNEL).dtb $@.new
128 @mv $@.new $@
129 endef
130
131 define Build/append-fakerootfs
132 rm -rf $@.fakerootsquashfs $@.fakefs
133
134 # append a fake/empty rootfs to fool netgear's uboot
135 # CHECK_DNI_FIRMWARE_ROOTFS_INTEGRITY in do_chk_dniimg()
136 dd if=/dev/zero of=$@.fakerd bs=16 count=1 conv=sync
137
138 -$(STAGING_DIR_HOST)/bin/mkimage \
139 -A $(LINUX_KARCH) -O linux -T filesystem -C none \
140 -a 0x00000000 -e 0x00000000 \
141 -n '$(DEVICE_PROFILE) fakerootfs' \
142 -d $@.fakerd $@.fakefs
143
144 cat $@.fakefs >> $@
145 rm -rf $@.fakerootsquashfs $@.fakefs
146 endef
147
148 define Build/wndr4700-specialImage
149 rm -rf $@.fakerd $@.new
150
151 dd if=/dev/zero of=$@.fakerd bs=32 count=1 conv=sync
152
153 # Netgear used an old uboot that doesn't have FIT support.
154 # So we are stuck with either a full ext2/4 fs in a initrd.
155 # ... or we try to make the "multi" image approach to work
156 # for us.
157 #
158 # Sadly, the "multi" image has to consists of three
159 # "fixed" parts in the following "fixed" order:
160 # 1. The kernel which is in $@
161 # 2. The (fake) initrd which is in $@.fakerd
162 # 3. The device tree binary which is in $@.dtb
163 #
164 # Now, given that we use the function for the kernel which
165 # already has a initramfs image inside, we still have to
166 # add a "fake" initrd (which a mkimage header) in the second
167 # part of the legacy multi image. Since we need to put the
168 # device tree stuff into part 3.
169
170 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T multi \
171 -C $(1) -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) \
172 -n '$(DEVICE_PROFILE) initramfs' -d $@:$@.fakerd:$@.dtb $@.new
173 mv $@.new $@
174 rm -rf $@.fakerd
175 endef
176
177 define Device/WNDR4700
178 DEVICE_TITLE := Netgear Centria N900 WNDR4700/WNDR4720
179 DEVICE_PACKAGES := badblocks block-mount e2fsprogs \
180 kmod-dm kmod-fs-ext4 kmod-fs-vfat kmod-usb-ledtrig-usbport \
181 kmod-md-mod kmod-nls-cp437 kmod-nls-iso8859-1 kmod-nls-iso8859-15 \
182 kmod-nls-utf8 kmod-usb3 kmod-usb-dwc2 kmod-usb-storage \
183 partx-utils
184 DEVICE_NAME := wndr4700
185 DEVICE_PROFILE := wndr4700
186 DEVICE_DTS := wndr4700
187 PAGESIZE := 2048
188 SUBPAGESIZE := 512
189 BLOCKSIZE := 128k
190 DTB_SIZE := 131008
191 IMAGE_SIZE := 24960k
192 IMAGES := factory.img sysupgrade.tar kernel.dtb
193 KERNEL_SIZE := 1920k
194 KERNEL := dtb | kernel-bin | lzma | uImage lzma | pad-offset $$(BLOCKSIZE) 64 | append-fakerootfs
195 KERNEL_INITRAMFS := kernel-bin | gzip | dtb | wndr4700-specialImage gzip
196 IMAGE/factory.img := create-uImage-dtb | append-kernel | pad-to 2M | append-ubi | \
197 netgear-dni | check-size $$$$(IMAGE_SIZE)
198 IMAGE/sysupgrade.tar := sysupgrade-tar
199 IMAGE/kernel.dtb := export-dtb | uImage none
200 NETGEAR_BOARD_ID := WNDR4700
201 NETGEAR_HW_ID := 29763875+128+256
202 UBINIZE_OPTS := -E 5
203 endef
204 TARGET_DEVICES += WNDR4700
205
206 endif
207
208 ifeq ($(SUBTARGET),sata)
209
210 ### Image scripts for the WD My Book Live Series ###
211 define Build/boot-script
212 $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T script -C none -n "$(PROFILE) Boot Script" \
213 -d mbl_boot.scr \
214 $@.scr
215 endef
216
217 define Build/boot-img
218 $(RM) -rf $@.bootdir
219 mkdir -p $@.bootdir/boot
220
221 $(CP) $@.scr $@.bootdir/boot/boot.scr
222 $(CP) $(IMAGE_KERNEL).dtb $@.bootdir/boot/$(DEVICE_DTB)
223 $(CP) $(IMAGE_KERNEL) $@.bootdir/boot/uImage
224
225 genext2fs --block-size $(BLOCKSIZE:%k=%Ki) --size-in-blocks $$((1024 * $(BOOT_SIZE))) --root $@.bootdir $@.boot
226
227 # convert it to revision 1 - needed for u-boot ext2load
228 $(STAGING_DIR_HOST)/bin/tune2fs -O filetype $@.boot
229 $(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.boot > /dev/null
230 endef
231
232 define Build/hdd-img
233 ./mbl_gen_hdd_img.sh $@ $@.boot $(IMAGE_ROOTFS)
234 endef
235
236 define Device/MyBookLiveDefault
237 IMAGE_SIZE := 48m
238 BLOCKSIZE := 1k
239 DTB_SIZE := 16384
240 KERNEL := kernel-bin | dtb | gzip | uImage gzip
241 KERNEL_INITRAMFS := kernel-bin | dtb | gzip | uImage gzip
242 BOOT_SIZE := 8
243 IMAGES := rootfs.img kernel.dtb
244 DEVICE_DTB := apollo3g.dtb
245 FILESYSTEMS := ext4
246 IMAGE/kernel.dtb := export-dtb
247 IMAGE/rootfs.img := boot-script | boot-img | hdd-img
248 endef
249
250 define Device/MyBookLiveSingle
251 $(Device/MyBookLiveDefault)
252 DEVICE_TITLE := Western Digital My Book Live
253 DEVICE_DTS := apollo3g
254 DEVICE_PROFILE := apollo3g
255 endef
256
257 TARGET_DEVICES += MyBookLiveSingle
258
259 define Device/MyBookLiveDuo
260 $(Device/MyBookLiveDefault)
261 DEVICE_TITLE := Western Digital My Book Live Duo
262 DEVICE_PACKAGES := kmod-usb-dwc2 kmod-usb-ledtrig-usbport kmod-usb-storage kmod-fs-vfat wpad-mini
263 DEVICE_DTS := apollo3g-duo
264 DEVICE_PROFILE := ap2nc
265 endef
266
267 TARGET_DEVICES += MyBookLiveDuo
268
269 endif
270
271 $(eval $(call BuildImage))