[OpenWrt-Devel] [RFC, PATCH] ramips: mt7621: use OKLI lzma-loader for D-Link DIR-860L B1

Szabolcs Hubai szab.hu at gmail.com
Sun May 3 21:25:55 EDT 2020


In commit ce1957100411b0a751d6431d36def9c28048b4dc this device started
using lzma-loader to enable booting bigger kernels from flash.

Chuanhong Guo noted [0], if the kernel can be put at a fixed offset
in flash, we could compress lzma loader separately and let u-boot
decompress only the loader.

This patch use this OKLI method for sysupgrade and factory images.

[0]
http://lists.infradead.org/pipermail/openwrt-devel/2020-April/022926.html

Signed-off-by: Szabolcs Hubai <szab.hu at gmail.com>
---
 target/linux/ramips/image/Makefile            | 20 +++++++++++++++++++
 .../ramips/image/lzma-loader/src/loader.c     |  2 +-
 target/linux/ramips/image/mt7621.mk           |  9 ++++++++-
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile
index f93ea8ab2a..76568d7c6c 100644
--- a/target/linux/ramips/image/Makefile
+++ b/target/linux/ramips/image/Makefile
@@ -88,6 +88,26 @@ define Build/loader-kernel
 	$(call Build/loader-common,LOADER_DATA="$@")
 endef
 
+define Build/loader-okli-compile
+	$(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0)
+endef
+
+# Arguments: <output name> <kernel offset> <loader type>
+define Build/loader-okli-with-type
+	dd if=$(KDIR)/loader-$(word 1,$(1)).$(word 3,$(1)) bs=$(word 2,$(1)) conv=sync of="$@.new"
+	cat "$@" >> "$@.new"
+	mv "$@.new" "$@"
+endef
+
+# Arguments: <output name> <kernel offset>
+define Build/loader-okli
+	$(call Build/loader-okli-with-type,$(word 1,$(1)) $(word 2,$(1)) $(LOADER_TYPE))
+endef
+
+define Build/append-loader-okli
+	cat "$(KDIR)/loader-$(word 1,$(1)).$(LOADER_TYPE)" >> "$@"
+endef
+
 define Build/relocate-kernel
 	rm -rf $@.relocate
 	$(CP) ../../generic/image/relocate $@.relocate
diff --git a/target/linux/ramips/image/lzma-loader/src/loader.c b/target/linux/ramips/image/lzma-loader/src/loader.c
index c73b60b351..8b7756b931 100644
--- a/target/linux/ramips/image/lzma-loader/src/loader.c
+++ b/target/linux/ramips/image/lzma-loader/src/loader.c
@@ -28,7 +28,7 @@
 #include "printf.h"
 #include "LzmaDecode.h"
 
-#define AR71XX_FLASH_START	0x1f000000
+#define AR71XX_FLASH_START	0x10000000
 #define AR71XX_FLASH_END	0x1fe00000
 
 #define KSEG0			0x80000000
diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
index 88db43cb65..9438e5c09e 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -221,7 +221,14 @@ define Device/dlink_dir-860l-b1
   BLOCKSIZE := 64k
   SEAMA_SIGNATURE := wrgac13_dlink.2013gui_dir860lb
   LOADER_TYPE := bin
-  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | \
+  LOADER_FLASH_OFFS := 0x501040
+  COMPILE := loader-$(1).bin loader-$(1).lzma
+  COMPILE/loader-$(1).bin := loader-okli-compile
+  COMPILE/loader-$(1).lzma := append-loader-okli $(1) | pad-to 32k | \
+	relocate-kernel | lzma
+  KERNEL := kernel-bin | append-dtb | lzma | uImage lzma -M 0x4f4b4c49 | \
+	loader-okli-with-type $(1) 4096 lzma
+  KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \
 	relocate-kernel | lzma -a0 | uImage lzma
   IMAGE_SIZE := 16064k
   DEVICE_VENDOR := D-Link
-- 
2.17.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list