2 # This is free software, licensed under the GNU General Public License v2.
3 # See /LICENSE for more information.
5 include $(TOPDIR)/rules.mk
6 include $(INCLUDE_DIR)/image.mk
8 DEVICE_VARS += DEVICE_PROFILE IMAGE_SIZE DTB_SIZE
12 KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
15 KERNEL_ENTRY := 0x00000000
16 KERNEL_LOADADDR := 0x00000000
17 DEVICE_DTS_DIR := ../dts
21 $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,$@.dtb,,--space $(DTB_SIZE))
24 define Build/export-dtb
25 cp $(IMAGE_KERNEL).dtb $@
28 ifeq ($(SUBTARGET),nand)
31 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz )
34 define Build/copy-file
38 define Build/MerakiAdd-dtb
39 $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,$@.dtb)
41 dd if=$@.dtb bs=$(DTB_SIZE) conv=sync; \
42 dd if=$@ bs=$(BLOCKSIZE) conv=sync; \
47 define Build/MerakiAdd-initramfs
50 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T ramdisk \
51 -C gzip -n "$(PROFILE) rootfs" \
52 -d $(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz \
53 $(KDIR_TMP)/$(IMG_PREFIX)-uramdisk.image.gz
56 dd if=$@ bs=1k conv=sync; \
57 dd if=$(KDIR_TMP)/$(IMG_PREFIX)-uramdisk.image.gz bs=$(BLOCKSIZE) conv=sync; \
62 define Build/MerakiNAND
63 -$(STAGING_DIR_HOST)/bin/mkmerakifw \
64 -B $(DEVICE_PROFILE) -s \
71 DEVICE_TITLE := Cisco Meraki MR24
72 DEVICE_PACKAGES := kmod-spi-gpio kmod-ath9k wpad-mini
73 DEVICE_PROFILE := MR24
76 IMAGES := sysupgrade.tar
80 KERNEL := kernel-bin | lzma | uImage lzma | MerakiAdd-dtb | MerakiNAND
81 KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux | lzma | uImage lzma | \
82 check-size $$(KERNEL_SIZE) | \
83 MerakiAdd-dtb | pad-to 2047k | MerakiAdd-initramfs | \
85 IMAGE/sysupgrade.tar := sysupgrade-tar
88 TARGET_DEVICES += mr24
91 DEVICE_TITLE := Cisco Meraki MX60
92 DEVICE_PACKAGES := kmod-spi-gpio swconfig kmod-usb-ledtrig-usbport \
93 kmod-usb-dwc2 kmod-usb-storage block-mount
94 DEVICE_PROFILE := MX60
97 IMAGES := sysupgrade.tar
99 # The kernel size will need to match the offset defined in mkmerakifw.c,
100 # otherwise the final image will fail to boot. This is set within the
101 # MX60 kernel header definition which is found at
102 # ./tools/firmware-utils/src/mkmerakifw.c, line 103~
105 KERNEL := kernel-bin | gzip | uImage gzip | MerakiAdd-dtb | MerakiNAND
106 KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux | gzip | uImage gzip | \
107 check-size $$(KERNEL_SIZE) | \
108 MerakiAdd-dtb | pad-to 2047k | MerakiAdd-initramfs | \
110 IMAGE/sysupgrade.tar := sysupgrade-tar
113 TARGET_DEVICES += mx60
117 DEVICE_TITLE := Cisco Meraki MX60W
118 DEVICE_PACKAGES += kmod-ath9k wpad-mini
120 TARGET_DEVICES += mx60w
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
131 define Build/wndr4700-specialImage
132 rm -rf $@.fakerd $@.new
134 dd if=/dev/zero of=$@.fakerd bs=32 count=1 conv=sync
136 # Netgear used an old uboot that doesn't have FIT support.
137 # So we are stuck with either a full ext2/4 fs in a initrd.
138 # ... or we try to make the "multi" image approach to work
141 # Sadly, the "multi" image has to consists of three
142 # "fixed" parts in the following "fixed" order:
143 # 1. The kernel which is in $@
144 # 2. The (fake) initrd which is in $@.fakerd
145 # 3. The device tree binary which is in $@.dtb
147 # Now, given that we use the function for the kernel which
148 # already has a initramfs image inside, we still have to
149 # add a "fake" initrd (which a mkimage header) in the second
150 # part of the legacy multi image. Since we need to put the
151 # device tree stuff into part 3.
153 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T multi \
154 -C $(1) -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) \
155 -n '$(DEVICE_PROFILE) initramfs' -d $@:$@.fakerd:$@.dtb $@.new
160 define Device/WNDR4700
161 DEVICE_TITLE := Netgear Centria N900 WNDR4700/WNDR4720
162 DEVICE_PACKAGES := badblocks block-mount e2fsprogs \
163 kmod-ath9k kmod-dm kmod-fs-ext4 kmod-fs-vfat kmod-usb-ledtrig-usbport \
164 kmod-md-mod kmod-nls-cp437 kmod-nls-iso8859-1 kmod-nls-iso8859-15 \
165 kmod-nls-utf8 kmod-usb3 kmod-usb-dwc2 kmod-usb-storage \
166 partx-utils swconfig wpad-mini
167 DEVICE_NAME := wndr4700
168 DEVICE_PROFILE := wndr4700
169 DEVICE_DTS := wndr4700
175 IMAGES := factory.img sysupgrade.tar kernel.dtb
177 KERNEL := dtb | kernel-bin | lzma | uImage lzma | pad-offset $$(BLOCKSIZE) 64 | \
178 append-uImage-fakeroot-hdr
179 KERNEL_INITRAMFS := kernel-bin | gzip | dtb | wndr4700-specialImage gzip
180 IMAGE/factory.img := create-uImage-dtb | append-kernel | pad-to 2M | append-ubi | \
181 netgear-dni | check-size $$$$(IMAGE_SIZE)
182 IMAGE/sysupgrade.tar := sysupgrade-tar
183 IMAGE/kernel.dtb := export-dtb | uImage none
184 NETGEAR_BOARD_ID := WNDR4700
185 NETGEAR_HW_ID := 29763875+128+256
188 TARGET_DEVICES += WNDR4700
192 ifeq ($(SUBTARGET),sata)
194 ### Image scripts for the WD My Book Live Series ###
195 define Build/boot-script
196 $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T script -C none -n "$(PROFILE) Boot Script" \
201 define Build/boot-img
203 mkdir -p $@.bootdir/boot
205 $(CP) $@.scr $@.bootdir/boot/boot.scr
206 $(CP) $(IMAGE_KERNEL).dtb $@.bootdir/boot/$(DEVICE_DTB)
207 $(CP) $(IMAGE_KERNEL) $@.bootdir/boot/uImage
209 genext2fs --block-size $(BLOCKSIZE:%k=%Ki) --size-in-blocks $$((1024 * $(BOOT_SIZE))) --root $@.bootdir $@.boot
211 # convert it to revision 1 - needed for u-boot ext2load
212 $(STAGING_DIR_HOST)/bin/tune2fs -O filetype $@.boot
213 $(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.boot > /dev/null
217 ./mbl_gen_hdd_img.sh $@ $@.boot $(IMAGE_ROOTFS)
220 define Device/MyBookLiveDefault
224 KERNEL := kernel-bin | dtb | gzip | uImage gzip
225 KERNEL_INITRAMFS := kernel-bin | dtb | gzip | uImage gzip
227 IMAGES := rootfs.img kernel.dtb
228 DEVICE_DTB := apollo3g.dtb
230 IMAGE/kernel.dtb := export-dtb
231 IMAGE/rootfs.img := boot-script | boot-img | hdd-img
234 define Device/MyBookLiveSingle
235 $(Device/MyBookLiveDefault)
236 DEVICE_TITLE := Western Digital My Book Live
237 DEVICE_DTS := apollo3g
238 DEVICE_PROFILE := apollo3g
241 TARGET_DEVICES += MyBookLiveSingle
243 define Device/MyBookLiveDuo
244 $(Device/MyBookLiveDefault)
245 DEVICE_TITLE := Western Digital My Book Live Duo
246 DEVICE_PACKAGES := kmod-usb-dwc2 kmod-usb-ledtrig-usbport kmod-usb-storage kmod-fs-vfat wpad-mini
247 DEVICE_DTS := apollo3g-duo
248 DEVICE_PROFILE := ap2nc
251 TARGET_DEVICES += MyBookLiveDuo
255 $(eval $(call BuildImage))