From ac5f431ad13ad167f4a5f0814dfa69ab0438ea1a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 11 Mar 2019 19:16:43 +0100 Subject: gemini: Generate padded kernel+rootfs images for DIR-685 We currently generate a kernel that boots from the harddrive in the DIR-685. That's not how we usually do things, so let's augment it to boot from flash and mount the rootfs using squashfs and JFFS2 like everyone else. Partition splitting only work when the partitions are inside of a "partitions" node which is why we have a patch like this (submitted upstream). Another patch drops the rootfs arguments and renames the firmware partition while adding the compatible "wrg" to it so the WRGG parser will kick in. Factory image was tested by bravely reflashing the DIR-685 from stock firmware using the web UI and the serial console boot loader. Signed-off-by: Linus Walleij --- target/linux/gemini/image/Makefile | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'target/linux/gemini/image/Makefile') diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile index 7fcac8051f..9dd37ab702 100644 --- a/target/linux/gemini/image/Makefile +++ b/target/linux/gemini/image/Makefile @@ -10,8 +10,8 @@ include $(INCLUDE_DIR)/image.mk # Cook a "WRGG" image, this board is apparently one in the D-Link # WRGG family and uses the exact same firmware format as other # D-Link devices. -define Build/dir685-images - mkwrggimg -i $(IMAGE_KERNEL) \ +define Build/dir685-image + mkwrggimg -i $@ \ -o $@.new \ -d /dev/mtdblock/1 \ -s wrgns01_dlwbr_dir685RBWW \ @@ -22,6 +22,12 @@ define Build/dir685-images mv $@.new $@ endef +# Padding added after the rootfs to an even 128k boundary +# as this is 128k eraseblocks flash. +define Build/dir685-pad-rootfs + $(STAGING_DIR_HOST)/bin/padjffs2 $(IMAGE_ROOTFS) -c 128 >>$@ +endef + # Build D-Link DNS-313 images using the special header tool. # rootfs.tgz and rd.tgz contains nothing, we only need them # to satisfy the boot loader on the device. The zImage is @@ -121,6 +127,16 @@ GEMINI_NAS_PACKAGES:=kmod-md-mod kmod-md-linear kmod-md-multipath \ samba36-server mdadm cfdisk fdisk e2fsprogs badblocks \ partx-utils +# The DIR-685 flash layout is kernel in WRGG format, padded and followed +# by the appended rootfs followed by some reasonable JFFS padding, the +# remainder will be used by JFFS2 through overlayfs. +# +# - For the factory image, the WRGG image includes the rootfs so that the +# default firmware will flash it properly as all it knows is WRGG format. +# - For the sysupgrade, we do not include the rootfs in the kernel image +# so it is not needelessly tossed into the RAM by the boot loader. +# This will be flashed from OpenWrt userland anyways so we only need +# the minimum to make the boot loader happy. define Device/dlink_dir-685 DEVICE_TITLE := D-Link DIR-685 Xtreme N Storage Router DEVICE_DTS := gemini-dlink-dir-685 @@ -128,7 +144,8 @@ define Device/dlink_dir-685 kmod-switch-rtl8366rb swconfig \ kmod-rt2800-pci IMAGES := factory.bin - IMAGE/factory.bin := dir685-images + # Pad to 128k erase blocks with 160 bytes WRGG header + IMAGE/factory.bin := append-kernel | pad-offset 128k 160 | append-rootfs | dir685-pad-rootfs | dir685-image endef TARGET_DEVICES += dlink_dir-685 -- cgit v1.2.3