This patch adds support for building factory and sysupgrade images
for the Netgear EX2700 that don't require modification of u-boot
environment variables.

Signed-off-by: Joseph C. Lehner <joseph.c.leh...@gmail.com>

---

diff --git a/target/linux/ramips/image/Makefile 
b/target/linux/ramips/image/Makefile
index 8bdd76a..68580ad 100644
--- a/target/linux/ramips/image/Makefile
+++ b/target/linux/ramips/image/Makefile
@@ -912,8 +912,65 @@ endif
 # MT7620A Profiles
 #
 
+# $(1): (ignored)
+# $(2): Board name (small caps)
+# $(3): DTS file name without extension
+# $(4): Erase block size
+# $(5): DNI hardware id
+# $(6): Maximum image size
+define BuildFirmware/Netgear/squashfs
+       $(call PatchKernelLzmaDtb,$(2),$(3))
+       $(eval kernelsize=$(shell wc -c < $(KDIR)/vmlinux-$(2).bin.lzma))
+       # Round (kernelsize + 2*64) to erase blocks, avoiding parens
+       $(eval kernelsize=$(shell expr 2 \* 64 + $(kernelsize)))
+       $(eval kernelsize=$(shell expr 1 + $(kernelsize) / $(4)))
+       $(eval kernelsize=$(shell expr $(4) \* $(kernelsize)))
+       dd if=$(KDIR)/vmlinux-$(2).bin.lzma \
+               of=$(KDIR)/vmlinux-$(2).bin.lzma.tmp \
+               bs=$$$$(($(kernelsize)-2*64)) count=1 conv=sync
+       $(call 
MkImage,lzma,$(KDIR)/vmlinux-$(2).bin.lzma.tmp,$(KDIR)/vmlinux-$(2).uImage)
+
+       # Manually create the header of a 0 byte uImage. We can't use
+       # mkimage because it wont let us use an empty source file.
+       $(eval fakeroot=$(KDIR)/fakeroot-$(2).uImage)
+
+       # ih_magic:
+       echo -ne '\x27\x05\x19\x56' > $(fakeroot)
+       # ih_hcrc:
+       echo -ne '\x22\x6e\x07\xc1' >> $(fakeroot)
+       # ih_time:
+       echo -ne '\x00\x00\x00\x00' >> $(fakeroot)
+       # ih_size:
+       echo -ne '\x00\x00\x00\x00' >> $(fakeroot)
+       # ih_load:
+       echo -ne '\x00\x00\x00\x00' >> $(fakeroot)
+       # ih_ep:
+       echo -ne '\x00\x00\x00\x00' >> $(fakeroot)
+       # ih_dcrc:
+       echo -ne '\x00\x00\x00\x00' >> $(fakeroot)
+       # ih_os, ih_arch, ih_type, ih_comp:
+       echo -ne '\x05\x05\x07\x00' >> $(fakeroot)
+       # ih_name:
+       echo -n 'OpenWrt fakeroot' >> $(fakeroot)
+       # padding:
+       echo -ne '\x00\x00\x00\x00' >> $(fakeroot)
+       echo -ne '\x00\x00\x00\x00' >> $(fakeroot)
+       echo -ne '\x00\x00\x00\x00' >> $(fakeroot)
+       echo -ne '\x00\x00\x00\x00' >> $(fakeroot)
+
+       cat $(fakeroot) >> $(KDIR)/vmlinux-$(2).uImage
+
+       $(call MkImageSysupgrade/squashfs,squashfs,$(2),$(6))
+
+       $(STAGING_DIR_HOST)/bin/mkdniimg \
+               -B $(3) -H $(5) -v OpenWrt \
+               -i $(call imgname,squashfs,$(2))-sysupgrade.bin \
+               -o $(call imgname,squashfs,$(2))-factory.bin
+endef
+
 Image/Build/Profile/E1700=$(call 
BuildFirmware/UMedia/$(1),$(1),e1700,E1700,0x013326)
-Image/Build/Profile/EX2700=$(call 
BuildFirmware/Default4M/$(1),$(1),ex2700,EX2700)
+ex2700_mtd_size=3604480
+Image/Build/Profile/EX2700=$(call 
BuildFirmware/Netgear/$(1),$(1),ex2700,EX2700,65536,29764623+4+0+32+2x2+0,$(ex2700_mtd_size))
 Image/Build/Profile/MT7620a=$(call 
BuildFirmware/Default8M/$(1),$(1),mt7620a,MT7620a)
 Image/Build/Profile/MT7620a_MT7610e=$(call 
BuildFirmware/Default8M/$(1),$(1),mt7620a_mt7610e,MT7620a_MT7610e)
 Image/Build/Profile/MT7620a_MT7530=$(call 
BuildFirmware/Default8M/$(1),$(1),mt7620a_mt7530,MT7620a_MT7530)
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to