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
7 include $(INCLUDE_DIR)/host.mk
9 DEVICE_VARS += DEVICE_DTS DEVICE_PROFILE IMAGE_SIZE DTB_SIZE
12 KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
15 KERNEL_ENTRY := 0x00000000
16 KERNEL_LOADADDR := 0x00000000
20 $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,$@.dtb,,--space $(DTB_SIZE))
23 ifeq ($(SUBTARGET),nand)
26 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz )
29 define Build/copy-file
33 define Build/MerakiAdd-dtb
34 $(call Image/BuildDTB,../dts/$(DEVICE_DTS).dts,$@.dtb)
36 dd if=$@.dtb bs=$(DTB_SIZE) conv=sync; \
37 dd if=$@ bs=$(BLOCKSIZE) conv=sync; \
42 define Build/MerakiAdd-initramfs
45 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T ramdisk \
46 -C gzip -n "$(PROFILE) rootfs" \
47 -d $(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz \
48 $(KDIR_TMP)/$(IMG_PREFIX)-uramdisk.image.gz
51 dd if=$@ bs=1k conv=sync; \
52 dd if=$(KDIR_TMP)/$(IMG_PREFIX)-uramdisk.image.gz bs=$(BLOCKSIZE) conv=sync; \
57 define Build/MerakiNAND
58 -$(STAGING_DIR_HOST)/bin/mkmerakifw \
59 -B $(DEVICE_PROFILE) -s \
66 DEVICE_TITLE := Cisco Meraki MR24
67 DEVICE_PACKAGES := kmod-spi-gpio kmod-ath9k wpad-mini
68 DEVICE_PROFILE := MR24
71 IMAGES := sysupgrade.tar
75 KERNEL := kernel-bin | lzma | uImage lzma | MerakiAdd-dtb | MerakiNAND
76 KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux | lzma | uImage lzma | MerakiAdd-dtb | pad-to 2047k | MerakiAdd-initramfs | MerakiNAND
77 IMAGE/sysupgrade.tar := sysupgrade-nand
79 TARGET_DEVICES += mr24
81 define Build/create-uImage-dtb
82 # flat_dt target expect FIT image - which WNDR4700's uboot doesn't support
83 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) \
84 -O linux -T kernel -C none \
85 -n '$(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION)' \
90 define Build/append-fakerootfs
91 rm -rf $@.fakerootsquashfs $@.fakefs
93 # append a fake/empty rootfs to fool netgear's uboot
94 # CHECK_DNI_FIRMWARE_ROOTFS_INTEGRITY in do_chk_dniimg()
95 dd if=/dev/zero of=$@.fakerd bs=16 count=1 conv=sync
97 -$(STAGING_DIR_HOST)/bin/mkimage \
98 -A $(LINUX_KARCH) -O linux -T filesystem -C none \
99 -a 0x00000000 -e 0x00000000 \
100 -n '$(DEVICE_PROFILE) fakerootfs' \
101 -d $@.fakerd $@.fakefs
104 rm -rf $@.fakerootsquashfs $@.fakefs
107 define Build/wndr4700-specialImage
108 rm -rf $@.fakerd $@.new
110 dd if=/dev/zero of=$@.fakerd bs=32 count=1 conv=sync
112 # Netgear used an old uboot that doesn't have FIT support.
113 # So we are stuck with either a full ext2/4 fs in a initrd.
114 # ... or we try to make the "multi" image approach to work
117 # Sadly, the "multi" image has to consists of three
118 # "fixed" parts in the following "fixed" order:
119 # 1. The kernel which is in $@
120 # 2. The (fake) initrd which is in $@.fakerd
121 # 3. The device tree binary which is in $@.dtb
123 # Now, given that we use the function for the kernel which
124 # already has a initramfs image inside, we still have to
125 # add a "fake" initrd (which a mkimage header) in the second
126 # part of the legacy multi image. Since we need to put the
127 # device tree stuff into part 3.
129 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T multi \
130 -C $(1) -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) \
131 -n '$(DEVICE_PROFILE) initramfs' -d $@:$@.fakerd:$@.dtb $@.new
136 define Device/WNDR4700
137 DEVICE_TITLE := Netgear Centria N900 WNDR4700/WNDR4720
138 DEVICE_PACKAGES := badblocks block-mount e2fsprogs \
139 kmod-ath9k kmod-dm kmod-fs-ext4 kmod-fs-vfat kmod-ledtrig-usbdev \
140 kmod-md-mod kmod-nls-cp437 kmod-nls-iso8859-1 kmod-nls-iso8859-15 \
141 kmod-nls-utf8 kmod-usb3 kmod-usb-dwc2 kmod-usb-storage \
142 partx-utils swconfig wpad-mini
143 DEVICE_NAME := wndr4700
144 DEVICE_PROFILE := wndr4700
145 DEVICE_DTS := wndr4700
151 IMAGES := factory.img sysupgrade.tar
153 KERNEL := kernel-bin | lzma | uImage lzma | pad-offset $$(BLOCKSIZE) 64 | append-fakerootfs
154 KERNEL_INITRAMFS := kernel-bin | gzip | dtb | wndr4700-specialImage gzip
155 IMAGE/factory.img := dtb | create-uImage-dtb | append-kernel | pad-to 2M | append-ubi | \
156 netgear-dni | check-size $$$$(IMAGE_SIZE)
157 IMAGE/sysupgrade.tar := sysupgrade-nand
158 NETGEAR_BOARD_ID := WNDR4700
159 NETGEAR_HW_ID := 29763875+128+256
161 TARGET_DEVICES += WNDR4700
165 ifeq ($(SUBTARGET),sata)
167 ### Image scripts for the WD My Book Live Series ###
168 define Build/boot-script
169 $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T script -C none -n "$(PROFILE) Boot Script" \
174 define Build/boot-img
176 mkdir -p $@.bootdir/boot
178 $(CP) $@.scr $@.bootdir/boot/boot.scr
179 $(CP) $@.dtb $@.bootdir/boot/$(DEVICE_DTB)
180 $(CP) $(word 1,$^) $@.bootdir/boot/uImage
182 genext2fs --block-size $(BLOCKSIZE) --size-in-blocks $$((1024 * $(BOOT_SIZE))) --root $@.bootdir $@.boot
184 # convert it to revision 1 - needed for u-boot ext2load
185 $(STAGING_DIR_HOST)/bin/tune2fs -O filetype $@.boot
186 $(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.boot > /dev/null
190 ./mbl_gen_hdd_img.sh $@ $@.boot $(word 2,$^)
191 $(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $@ > $(BIN_DIR)/$(notdir $@).gz)
194 define Build/uRamdisk
195 $(call Image/mkfs/ext4)
196 gzip -9n -c $(KDIR)/root.ext4 > $(KDIR)/root.ext4.gz
197 $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T ramdisk -C gzip -n "$(PROFILE) rootfs" \
198 -d $(KDIR)/root.ext4.gz \
202 define Build/recovery-tar
203 sh ./mbl_gen_recovery_tar.sh \
204 --profile $(DEVICE_PROFILE) \
206 --dtbname $(DEVICE_DTB) \
208 --rootfs $@.uRamdisk \
212 define Device/MyBookLiveDefault
216 KERNEL := kernel-bin | gzip | uImage gzip
218 IMAGES := rootfs.img recovery.tar
219 DEVICE_DTB := apollo3g.dtb
220 IMAGE/rootfs.img := boot-script | dtb | boot-img | hdd-img
221 IMAGE/recovery.tar := kernel-bin | dtb | uRamdisk | recovery-tar
224 define Device/MyBookLiveSingle
225 $(Device/MyBookLiveDefault)
226 DEVICE_TITLE := Western Digital My Book Live
227 DEVICE_DTS := apollo3g
228 DEVICE_PROFILE := apollo3g
231 TARGET_DEVICES += MyBookLiveSingle
233 define Device/MyBookLiveDuo
234 $(Device/MyBookLiveDefault)
235 DEVICE_TITLE := Western Digital My Book Live Duo
236 DEVICE_PACKAGES := kmod-usb-dwc2 kmod-ledtrig-usbdev kmod-usb-storage kmod-fs-vfat wpad-mini
237 DEVICE_DTS := apollo3g-duo
238 DEVICE_PROFILE := ap2nc
241 TARGET_DEVICES += MyBookLiveDuo
245 $(eval $(call BuildImage))