Add factory image generation using UBI/UBIFS. The rootfile is mounted rw, no overlay support yet.
Just in front of the rootfs (still on the kernel partition), a fake header needs to be in place to make stock U-Boot happy. This fake header tells the system rootfs is 4 bytes long. The first for bytes of the rootfs is an UBI magic (ASCII UBI#). Signed-off-by: Stefan Agner <ste...@agner.ch> --- target/linux/ar71xx/image/Makefile | 64 +++++++++++++++++++++++++++++++-- target/linux/ar71xx/nand/config-default | 2 +- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index ea97a29..f9912f0 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -710,7 +710,67 @@ define Image/Build/Netgear/initramfs $(5) endef -Image/Build/NetgearNAND/initramfs=$(call Image/Build/Netgear/initramfs,$(1),$(2),$(3),$(4),$(5)) + +# $1: squashfs-64k +# $2: Board name (small caps) +# $3: Kernel board specific cmdline +# $4: Kernel mtdparts definition +# $5: U-Boot magic +# $6: Board name (upper caps) +# $7: +# $8: DNI Hardware version +define Image/Build/NetgearNAND + # Append UBI image to rootfs and generate DNI image + ( \ + cat vmlinux-$(2).uImage.fakehdrforubi; \ + cat $(KDIR)/root.ubi \ + ) > $(call imgname,ubifs,$(2))-uboot.img + $(STAGING_DIR_HOST)/bin/mkdniimg \ + -B $(6) -v OpenWrt.$(REVISION) -r "$$$$r" $(8) \ + -i $(call imgname,ubifs,$(2))-uboot.img \ + -o $(call imgname,ubifs,$(2))-factory.img +endef + +# $1: (empty?) +# $2: Board name (small caps) +# $3: Kernel board specific cmdline +# $4: Kernel mtdparts definition +# $5: U-Boot magic +define Image/Build/NetgearNAND/buildkernel + $(eval kernelsize=$(call mtdpartsize,kernel,$(4))) + echo == NetgearNAND buildkernel == + $(call MkuImageLzma,$(2),$(3) $(4),-d20) + -rm -rf $(KDIR_TMP)/$(2) + mkdir -p $(KDIR_TMP)/$(2)/image + $(STAGING_DIR_HOST)/bin/wndr3700 \ + $(KDIR_TMP)/vmlinux-$(2).uImage \ + $(KDIR_TMP)/vmlinux-$(2).uImage.tmp \ + $(5) + # Create fake header using UBI EC Header magic (UBI_EC_HDR_MAGIC) + echo -n "UBI#" > $(KDIR_TMP)/ubihdr + mkimage -A mips -O linux -T filesystem -C none \ + -a 0xbf070000 -e 0xbf070000 \ + -n 'MIPS OpenWrt rootfs' \ + -d $(KDIR_TMP)/ubihdr \ + $(KDIR_TMP)/ubihdr.uImage + $(STAGING_DIR_HOST)/bin/wndr3700 \ + $(KDIR_TMP)/ubihdr.uImage \ + $(KDIR_TMP)/ubihdr-$(2).uImage \ + $(5) + # Calculate size between kernel and header of root filesystem + # (this will be filled with zeros) + paddingsize=$$$$(($(kernelsize) - `stat -c%s $(KDIR_TMP)/vmlinux-$(2).uImage.tmp` - 64)); \ + ( \ + cat $(KDIR_TMP)/vmlinux-$(2).uImage.tmp; \ + dd if=/dev/zero bs=1 count=$$$${paddingsize}; \ + head -c 64 $(KDIR_TMP)/ubihdr-$(2).uImage \ + ) > vmlinux-$(2).uImage.fakehdrforubi +endef + + +define Image/Build/NetgearNAND/initramfs + $(call Image/Build/Netgear,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8)) +endef ifdef CONFIG_PACKAGE_uboot-ar71xx-nbg460n_550n_550nh Image/Build/ZyXEL/buildkernel=$(call MkuImageLzma,$(2),$(3)) @@ -866,7 +926,7 @@ $(eval $(call SingleProfile,Netgear,64kraw,WNDR3800,wndr3800,WNDR3700,ttyS0,1152 $(eval $(call SingleProfile,Netgear,64kraw,WNDRMAC,wndrmac,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),3701,WNDRMAC,"",-H 29763654+16+64)) $(eval $(call SingleProfile,Netgear,64kraw,WNDRMACV2,wndrmacv2,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),3701,WNDRMACv2,"",-H 29763654+16+128)) -$(eval $(call SingleProfile,NetgearNAND,64k,WNDR4300,wndr4300,WNDR4300,ttyS0,115200,$$(wndr4300_mtdlayout),3703,WNDR4300,"",-H 29763948+0+128+128+2x2+3x3)) +$(eval $(call SingleProfile,NetgearNAND,128k,WNDR4300,wndr4300,WNDR4300,ttyS0,115200,$$(wndr4300_mtdlayout),3703,WNDR4300,"",-H 29763948+0+128+128+2x2+3x3)) $(eval $(call SingleProfile,OpenMesh,squashfs-only,OM2P,om2p,,,,OM2P)) $(eval $(call SingleProfile,OpenMesh,squashfs-only,MR600,mr600,,,,MR600)) diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default index 6b9170e..b1be7c9 100644 --- a/target/linux/ar71xx/nand/config-default +++ b/target/linux/ar71xx/nand/config-default @@ -1,7 +1,7 @@ CONFIG_ATH79_MACH_WNDR4300=y CONFIG_ATH79_DEV_NFC # CONFIG_ATH79_ROUTERBOOT is not set -CONFIG_CMDLINE="console=ttyS0,115200 rootfstype=squashfs,jffs2 noinitrd" +CONFIG_CMDLINE="ubi.mtd=8 root=ubi0:rootfs rootfstype=ubifs,squashfs noinitrd" CONFIG_JFFS2_FS=y CONFIG_LZO_COMPRESS=y CONFIG_LZO_DECOMPRESS=y -- 1.8.4 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel