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_PROFILE IMAGE_SIZE DTB_SIZE
13 KERNEL_DEPENDS
= $$(wildcard ..
/dts
/$$(DEVICE_DTS
).dts
)
16 KERNEL_ENTRY
:= 0x00000000
17 KERNEL_LOADADDR
:= 0x00000000
18 DEVICE_DTS_DIR
:= ..
/dts
22 $(call Image
/BuildDTB
,..
/dts
/$(DEVICE_DTS
).dts
,$@.dtb
,,--space
$(DTB_SIZE
))
25 ifeq ($(SUBTARGET
),nand
)
28 ( cd
$(TARGET_DIR
); find . | cpio
-o
-H newc | gzip
-9n
>$(KDIR_TMP
)/$(IMG_PREFIX
)-rootfs.cpio.gz
)
31 define Build
/copy-file
35 define Build
/MerakiAdd-dtb
36 $(call Image
/BuildDTB
,..
/dts
/$(DEVICE_DTS
).dts
,$@.dtb
)
38 dd if
=$@.dtb bs
=$(DTB_SIZE
) conv
=sync
; \
39 dd if
=$@ bs
=$(BLOCKSIZE
) conv
=sync
; \
44 define Build
/MerakiAdd-initramfs
47 -$(STAGING_DIR_HOST
)/bin
/mkimage
-A
$(LINUX_KARCH
) -O linux
-T ramdisk \
48 -C gzip
-n
"$(PROFILE) rootfs" \
49 -d
$(KDIR_TMP
)/$(IMG_PREFIX
)-rootfs.cpio.gz \
50 $(KDIR_TMP
)/$(IMG_PREFIX
)-uramdisk.image.gz
53 dd if
=$@ bs
=1k conv
=sync
; \
54 dd if
=$(KDIR_TMP
)/$(IMG_PREFIX
)-uramdisk.image.gz bs
=$(BLOCKSIZE
) conv
=sync
; \
59 define Build
/MerakiNAND
60 -$(STAGING_DIR_HOST
)/bin
/mkmerakifw \
61 -B
$(DEVICE_PROFILE
) -s \
68 DEVICE_TITLE
:= Cisco Meraki MR24
69 DEVICE_PACKAGES
:= kmod-spi-gpio kmod-ath9k wpad-mini
70 DEVICE_PROFILE
:= MR24
73 IMAGES
:= sysupgrade.
tar
77 KERNEL
:= kernel-bin | lzma | uImage lzma | MerakiAdd-dtb | MerakiNAND
78 KERNEL_INITRAMFS
:= copy-file
$(KDIR
)/vmlinux | gzip | uImage gzip | MerakiAdd-dtb | pad-to
2047k | MerakiAdd-initramfs | MerakiNAND
79 IMAGE
/sysupgrade.
tar := sysupgrade-tar
81 TARGET_DEVICES
+= mr24
83 define Build
/create-uImage-dtb
84 # flat_dt target expect FIT image - which WNDR4700's uboot doesn't support
85 -$(STAGING_DIR_HOST
)/bin
/mkimage
-A
$(LINUX_KARCH
) \
86 -O linux
-T kernel
-C none \
87 -n
'$(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION)' \
92 define Build
/append-fakerootfs
93 rm -rf
$@.fakerootsquashfs
$@.fakefs
95 # append a fake/empty rootfs to fool netgear's uboot
96 # CHECK_DNI_FIRMWARE_ROOTFS_INTEGRITY in do_chk_dniimg()
97 dd if
=/dev
/zero of
=$@.fakerd bs
=16 count
=1 conv
=sync
99 -$(STAGING_DIR_HOST
)/bin
/mkimage \
100 -A
$(LINUX_KARCH
) -O linux
-T filesystem
-C none \
101 -a
0x00000000 -e
0x00000000 \
102 -n
'$(DEVICE_PROFILE) fakerootfs' \
103 -d
$@.fakerd
$@.fakefs
106 rm -rf
$@.fakerootsquashfs
$@.fakefs
109 define Build
/wndr4700-specialImage
110 rm -rf
$@.fakerd
$@.new
112 dd if
=/dev
/zero of
=$@.fakerd bs
=32 count
=1 conv
=sync
114 # Netgear used an old uboot that doesn't have FIT support.
115 # So we are stuck with either a full ext2/4 fs in a initrd.
116 # ... or we try to make the "multi" image approach to work
119 # Sadly, the "multi" image has to consists of three
120 # "fixed" parts in the following "fixed" order:
121 # 1. The kernel which is in $@
122 # 2. The (fake) initrd which is in $@.fakerd
123 # 3. The device tree binary which is in $@.dtb
125 # Now, given that we use the function for the kernel which
126 # already has a initramfs image inside, we still have to
127 # add a "fake" initrd (which a mkimage header) in the second
128 # part of the legacy multi image. Since we need to put the
129 # device tree stuff into part 3.
131 -$(STAGING_DIR_HOST
)/bin
/mkimage
-A
$(LINUX_KARCH
) -O linux
-T multi \
132 -C
$(1) -a
$(KERNEL_LOADADDR
) -e
$(KERNEL_ENTRY
) \
133 -n
'$(DEVICE_PROFILE) initramfs' -d
$@
:$@.fakerd
:$@.dtb
$@.new
138 define Device
/WNDR4700
139 DEVICE_TITLE
:= Netgear Centria N900 WNDR4700
/WNDR4720
140 DEVICE_PACKAGES
:= badblocks block-mount e2fsprogs \
141 kmod-ath9k kmod-dm kmod-fs-ext4 kmod-fs-vfat kmod-ledtrig-usbdev \
142 kmod-md-mod kmod-nls-cp437 kmod-nls-iso8859-1 kmod-nls-iso8859-15 \
143 kmod-nls-utf8 kmod-usb3 kmod-usb-dwc2 kmod-usb-storage \
144 partx-utils swconfig wpad-mini
145 DEVICE_NAME
:= wndr4700
146 DEVICE_PROFILE
:= wndr4700
147 DEVICE_DTS
:= wndr4700
153 IMAGES
:= factory.img sysupgrade.
tar
155 KERNEL
:= kernel-bin | lzma | uImage lzma | pad-offset
$$(BLOCKSIZE
) 64 | append-fakerootfs
156 KERNEL_INITRAMFS
:= kernel-bin | gzip | dtb | wndr4700-specialImage gzip
157 IMAGE
/factory.img
:= dtb | create-uImage-dtb | append-kernel | pad-to
2M | append-ubi | \
158 netgear-dni | check-size
$$$$(IMAGE_SIZE
)
159 IMAGE
/sysupgrade.
tar := sysupgrade-tar
160 NETGEAR_BOARD_ID
:= WNDR4700
161 NETGEAR_HW_ID
:= 29763875+128+256
163 TARGET_DEVICES
+= WNDR4700
167 ifeq ($(SUBTARGET
),sata
)
169 ### Image scripts for the WD My Book Live Series ###
170 define Build
/boot-script
171 $(STAGING_DIR_HOST
)/bin
/mkimage
-A powerpc
-T script
-C none
-n
"$(PROFILE) Boot Script" \
176 define Build
/boot-img
178 mkdir
-p
$@.bootdir
/boot
180 $(CP
) $@.scr
$@.bootdir
/boot
/boot.scr
181 $(CP
) $@.dtb
$@.bootdir
/boot
/$(DEVICE_DTB
)
182 $(CP
) $(IMAGE_KERNEL
) $@.bootdir
/boot
/uImage
184 genext2fs
--block-size
$(BLOCKSIZE
) --size-in-blocks
$$((1024 * $(BOOT_SIZE
))) --root
$@.bootdir
$@.boot
186 # convert it to revision 1 - needed for u-boot ext2load
187 $(STAGING_DIR_HOST
)/bin
/tune2fs
-O filetype
$@.boot
188 $(STAGING_DIR_HOST
)/bin
/e2fsck
-pDf
$@.boot
> /dev
/null
192 .
/mbl_gen_hdd_img.sh
$@
$@.boot
$(IMAGE_ROOTFS
)
193 $(if
$(CONFIG_TARGET_IMAGES_GZIP
),gzip
-9n
-c
$@
> $(BIN_DIR
)/$(notdir $@
).gz
)
196 define Build
/uRamdisk
197 $(STAGING_DIR_HOST
)/bin
/mkimage \
198 -A powerpc
-T ramdisk
-C gzip \
199 -n
"$(DEVICE_NAME) rootfs" \
204 define Build
/recovery-tar
205 sh .
/mbl_gen_recovery_tar.sh \
206 --profile
$(DEVICE_PROFILE
) \
207 --dtb
$(IMAGE_KERNEL
).dtb \
208 --dtbname
$(DEVICE_DTB
) \
209 --kernel
$(IMAGE_KERNEL
) \
214 define Device
/MyBookLiveDefault
218 KERNEL
:= kernel-bin | dtb | gzip | uImage gzip
220 IMAGES
:= rootfs.img recovery.
tar kernel.dtb
221 DEVICE_DTB
:= apollo3g.dtb
223 IMAGE
/kernel.dtb
:= append-dtb
224 IMAGE
/rootfs.img
:= boot-script | dtb | boot-img | hdd-img
225 IMAGE
/recovery.
tar := append-rootfs | gzip | uRamdisk | recovery-tar
228 define Device
/MyBookLiveSingle
229 $(Device
/MyBookLiveDefault
)
230 DEVICE_TITLE
:= Western Digital My Book Live
231 DEVICE_DTS
:= apollo3g
232 DEVICE_PROFILE
:= apollo3g
235 TARGET_DEVICES
+= MyBookLiveSingle
237 define Device
/MyBookLiveDuo
238 $(Device
/MyBookLiveDefault
)
239 DEVICE_TITLE
:= Western Digital My Book Live Duo
240 DEVICE_PACKAGES
:= kmod-usb-dwc2 kmod-ledtrig-usbdev kmod-usb-storage kmod-fs-vfat wpad-mini
241 DEVICE_DTS
:= apollo3g-duo
242 DEVICE_PROFILE
:= ap2nc
245 TARGET_DEVICES
+= MyBookLiveDuo
249 $(eval
$(call BuildImage
))