ramips: mt7620: use OKLI loader with Jboot devices
authorPawel Dembicki <paweldembicki@gmail.com>
Thu, 10 Jun 2021 15:17:23 +0000 (17:17 +0200)
committerPaul Spooren <mail@aparcar.org>
Mon, 13 Dec 2021 18:36:10 +0000 (19:36 +0100)
Jboot devices have problem with >2MB kernelsize. The only way to avoid
this problem is use small loader.

This patch switch all mt7620 Jboot devices to lzma OKLI loader.

Suggested-by: Szabolcs Hubai <szab.hu@gmail.com>
Co-authored-by: Michael Pratt <mcpratt@pm.me>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts
target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts
target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts
target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts
target/linux/ramips/dts/mt7620n_dlink_dwr-116-a1.dts
target/linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts
target/linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts
target/linux/ramips/image/Makefile
target/linux/ramips/image/mt7620.mk

index 2b8ad2759c4c81338f7afe68a68c917cd16d96b4..1d29bed6f0650cb4eb7de10b0db1479891aa5a18 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "dlink,dir-510l", "ralink,mt7620a-soc";
@@ -85,7 +86,9 @@
                        };
 
                        partition@210000 {
-                               compatible = "amit,jimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
+                               openwrt,offset = <0x10000>;
                                label = "firmware";
                                reg = <0x210000 0xde0000>;
                        };
index c63a85dd88435eeb7f6b68ff1cf2eedba8dbc97f..8ae566d448b999e6f37ec23e85f8c57c3d99f45a 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "dlink,dwr-118-a1", "ralink,mt7620a-soc";
                        };
 
                        partition@10000 {
-                               compatible = "amit,jimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
+                               openwrt,offset = <0x10000>;
                                label = "firmware";
                                reg = <0x10000 0xfe0000>;
                        };
index 711f9f7c9a322fcb17b282016fc7f943af70a5a8..42f5c861609b8a10e975d4589c3fa732124dc833 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "dlink,dwr-118-a2", "ralink,mt7620a-soc";
                        };
 
                        partition@10000 {
-                               compatible = "amit,jimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
+                               openwrt,offset = <0x10000>;
                                label = "firmware";
                                reg = <0x10000 0xfe0000>;
                        };
index e80719a4e78d73dac1ed8d16205632eccf85d39f..77b94a1190aa3ac4df7a472f93a14ea8664d65f2 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "dlink,dwr-960", "ralink,mt7620a-soc";
                        };
 
                        partition@10000 {
-                               compatible = "amit,jimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
+                               openwrt,offset = <0x10000>;
                                label = "firmware";
                                reg = <0x10000 0xfe0000>;
                        };
index 2c2e485f430db2879e3074008db969768236e46e..07355a05a5ad3f7acd472f2ad1676bee9eecd65c 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "lava,lr-25g001", "ralink,mt7620a-soc";
@@ -83,7 +84,9 @@
                        };
 
                        partition@10000 {
-                               compatible = "amit,jimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
+                               openwrt,offset = <0x10000>;
                                label = "firmware";
                                reg = <0x10000 0xfe0000>;
                        };
index d659262b0ec6c8fa405af1ab23e9a4e57c718abc..1c1a700630db4e0237ce8002ea015f6cff101acd 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "dlink,dwr-116-a1", "ralink,mt7620n-soc";
@@ -69,7 +70,9 @@
                        };
 
                        partition@10000 {
-                               compatible = "amit,jimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
+                               openwrt,offset = <0x10000>;
                                label = "firmware";
                                reg = <0x10000 0x7e0000>;
                        };
index d37bdb40131d25e3762900870d27323ac78f5418..95a93ea4deb0c3cd22a55740d84779944ae1a26b 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "dlink,dwr-921-c1", "ralink,mt7620n-soc";
                        };
 
                        partition@10000 {
-                               compatible = "amit,jimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
+                               openwrt,offset = <0x10000>;
                                label = "firmware";
                                reg = <0x10000 0xfe0000>;
                        };
index d3ca0dd53f181292a8b3a28dac85a889bff4a0a4..22bff2c948a94d7d918b793f4e7129a65c007c53 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/mtd/partitions/uimage.h>
 
 / {
        compatible = "dlink,dwr-922-e2", "ralink,mt7620n-soc";
                        };
 
                        partition@10000 {
-                               compatible = "amit,jimage";
+                               compatible = "openwrt,uimage", "denx,uimage";
+                               openwrt,ih-magic = <IH_MAGIC_OKLI>;
+                               openwrt,offset = <0x10000>;
                                label = "firmware";
                                reg = <0x10000 0xfe0000>;
                        };
index d523a62e0bc718d5922214db05a8aabb59ef4b30..ac256cf1ae0e88140a8b834e11152362ada9ece8 100644 (file)
@@ -89,6 +89,16 @@ define Build/mkdlinkfw-factory
        mv $@.new $@
 endef
 
+define Build/mkdlinkfw-loader
+       -$(STAGING_DIR_HOST)/bin/mkdlinkfw \
+               -k $(KDIR)/loader-$(DEVICE_NAME).bin \
+               -r $@ \
+               -o $@.new \
+               $(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \
+               -s $(DLINK_FIRMWARE_SIZE)
+       mv $@.new $@
+endef
+
 define Build/netis-tail
        echo -n $(1) >> $@
        echo -n $(UIMAGE_NAME)-yun | $(MKHASH) md5 | \
index 17a536e69f0a48b9c674f4b9e53f49963886c06f..fbf37144b995b3eefd750aeb127bb53c755253df 100644 (file)
@@ -61,13 +61,18 @@ TARGET_DEVICES += alfa-network_tube-e4g
 
 define Device/amit_jboot
   DLINK_IMAGE_OFFSET := 0x10000
-  KERNEL := $(KERNEL_DTB)
-  KERNEL_SIZE := 2048k
+  KERNEL := $(KERNEL_DTB) | uImage lzma -M 0x4f4b4c49
+  LOADER_FLASH_OFFS := 0x20000
+  LOADER_TYPE := bin
+  COMPILE := loader-$(1).bin
+  COMPILE/loader-$(1).bin := loader-okli-compile | pad-to 64k | lzma | \
+       pad-to 65480
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := mkdlinkfw | pad-rootfs | append-metadata
-  IMAGE/factory.bin := mkdlinkfw | pad-rootfs | mkdlinkfw-factory
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | mkdlinkfw-loader | \
+       pad-rootfs | append-metadata
+  IMAGE/factory.bin := append-kernel | append-rootfs | mkdlinkfw-loader | \
+       pad-rootfs | mkdlinkfw-factory
   DEVICE_PACKAGES := jboot-tools kmod-usb2 kmod-usb-ohci
-  DEFAULT := n
 endef
 
 define Device/asus_rp-n53
@@ -194,6 +199,7 @@ define Device/dlink_dir-510l
   $(Device/amit_jboot)
   SOC := mt7620a
   IMAGE_SIZE := 14208k
+  LOADER_FLASH_OFFS := 0x220000
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DIR-510L
   DEVICE_PACKAGES += kmod-mt76x0e