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