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
13 KERNEL_DEPENDS
= $$(wildcard ..
/dts
/$$(DEVICE_DTS
).dts
)
16 KERNEL_ENTRY
:= 0x00000000
17 KERNEL_LOADADDR
:= 0x00000000
21 $(call Image
/BuildDTB
,..
/dts
/$(DEVICE_DTS
).dts
,$@.dtb
,,--space
$(DTB_SIZE
))
24 ifeq ($(SUBTARGET
),nand
)
27 ( cd
$(TARGET_DIR
); find . | cpio
-o
-H newc | gzip
-9n
>$(KDIR_TMP
)/$(IMG_PREFIX
)-rootfs.cpio.gz
)
30 define Build
/copy-file
34 define Build
/MerakiAdd-dtb
35 $(call Image
/BuildDTB
,..
/dts
/$(DEVICE_DTS
).dts
,$@.dtb
)
37 dd if
=$@.dtb bs
=$(DTB_SIZE
) conv
=sync
; \
38 dd if
=$@ bs
=$(BLOCKSIZE
) conv
=sync
; \
43 define Build
/MerakiAdd-initramfs
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
52 dd if
=$@ bs
=1k conv
=sync
; \
53 dd if
=$(KDIR_TMP
)/$(IMG_PREFIX
)-uramdisk.image.gz bs
=$(BLOCKSIZE
) conv
=sync
; \
58 define Build
/MerakiNAND
59 -$(STAGING_DIR_HOST
)/bin
/mkmerakifw \
60 -B
$(DEVICE_PROFILE
) -s \
67 DEVICE_TITLE
:= Cisco Meraki MR24
68 DEVICE_PACKAGES
:= kmod-spi-gpio kmod-ath9k wpad-mini
69 DEVICE_PROFILE
:= MR24
72 IMAGES
:= sysupgrade.
tar
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
80 TARGET_DEVICES
+= mr24
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)' \
91 define Build
/append-fakerootfs
92 rm -rf
$@.fakerootsquashfs
$@.fakefs
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
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
105 rm -rf
$@.fakerootsquashfs
$@.fakefs
108 define Build
/wndr4700-specialImage
109 rm -rf
$@.fakerd
$@.new
111 dd if
=/dev
/zero of
=$@.fakerd bs
=32 count
=1 conv
=sync
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
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
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.
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
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
152 IMAGES
:= factory.img sysupgrade.
tar
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
162 TARGET_DEVICES
+= WNDR4700
166 ifeq ($(SUBTARGET
),sata
)
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" \
175 define Build
/boot-img
177 mkdir
-p
$@.bootdir
/boot
179 $(CP
) $@.scr
$@.bootdir
/boot
/boot.scr
180 $(CP
) $@.dtb
$@.bootdir
/boot
/$(DEVICE_DTB
)
181 $(CP
) $(word 1,$^
) $@.bootdir
/boot
/uImage
183 genext2fs
--block-size
$(BLOCKSIZE
) --size-in-blocks
$$((1024 * $(BOOT_SIZE
))) --root
$@.bootdir
$@.boot
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
191 .
/mbl_gen_hdd_img.sh
$@
$@.boot
$(word 2,$^
)
192 $(if
$(CONFIG_TARGET_IMAGES_GZIP
),gzip
-9n
-c
$@
> $(BIN_DIR
)/$(notdir $@
).gz
)
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 \
203 define Build
/recovery-tar
204 sh .
/mbl_gen_recovery_tar.sh \
205 --profile
$(DEVICE_PROFILE
) \
207 --dtbname
$(DEVICE_DTB
) \
209 --rootfs
$@.uRamdisk \
213 define Device
/MyBookLiveDefault
217 KERNEL
:= kernel-bin | gzip | uImage gzip
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
225 define Device
/MyBookLiveSingle
226 $(Device
/MyBookLiveDefault
)
227 DEVICE_TITLE
:= Western Digital My Book Live
228 DEVICE_DTS
:= apollo3g
229 DEVICE_PROFILE
:= apollo3g
232 TARGET_DEVICES
+= MyBookLiveSingle
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
242 TARGET_DEVICES
+= MyBookLiveDuo
246 $(eval
$(call BuildImage
))