Re: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L

2020-04-19 Thread Szabolcs Hubai
Hello!

Chuanhong Guo  ezt írta (időpont: 2020. ápr. 19.,
V, 17:42):
>
> Hi!
>
> On Sun, Apr 19, 2020 at 8:38 AM Szabolcs Hubai  wrote:
> >
> > This device has trouble extracting big kernel from flash,
> > and supports LZMA compressed kernels only.
> >
> > Using OpenWrt kernel loader saves us 64 KB compared to the dictionary
> > size limiting workaround.
> >
> > Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
> > - original ("-d23", default): 4784188 bytes, LZMA ERROR 1
> > - with "-d19": 4915260, LZMA ERROR 1
> > - with "-d18": 4915260, diff to original: +128 KB
> > - with "-d17": 4980796, diff to original: +192 KB
> > - with this patch: 4849724, diff to original: +64 KB
> >
> > To save some CPU cycle, use minimal compression ("-a0") for the LZMA
> > compressed uImage.
>
> My original thought on this device is to use a different loader. The first
> 4MB of SPI-NOR flash on mt7621 is mapped to 0x1fc0 and lzma
> loader can read compressed kernel directly from flash. 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.
> You could take a look at the tp-link-nolzma recipe in:
> target/linux/ath79/image/common-tp-link.mk
> and see if you could implement a similar solution for mt7621.
> Note: You need to fix AR71XX_FLASH_START defined in:
> target/linux/ramips/image/lzma-loader/src/loader.c
> to 0x1fc0 for this method to work.
>

Yes, that new loader would be best solution.
I'm a DevOps guy and my C-fu is just Googling and copy-pasting. :D

I'm interested in the implementation, so I would play with the source code
as a homework, but those patches wouldn't be ready for the 20.xx release. ;)

> If you can't implement it, I'm fine with your current solution too.
> but I prefer to drop patch 1/2 and write the complete kernel
> recipe for dir-860l only. It's a bit confusing to use "KERNEL +="
>

I'm going to go this way. Thank you both for the comments.


--
BR,
Szabolcs



> --
> Regards,
> Chuanhong Guo

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L

2020-04-19 Thread Chuanhong Guo
Hi!

On Sun, Apr 19, 2020 at 8:38 AM Szabolcs Hubai  wrote:
>
> This device has trouble extracting big kernel from flash,
> and supports LZMA compressed kernels only.
>
> Using OpenWrt kernel loader saves us 64 KB compared to the dictionary
> size limiting workaround.
>
> Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
> - original ("-d23", default): 4784188 bytes, LZMA ERROR 1
> - with "-d19": 4915260, LZMA ERROR 1
> - with "-d18": 4915260, diff to original: +128 KB
> - with "-d17": 4980796, diff to original: +192 KB
> - with this patch: 4849724, diff to original: +64 KB
>
> To save some CPU cycle, use minimal compression ("-a0") for the LZMA
> compressed uImage.

My original thought on this device is to use a different loader. The first
4MB of SPI-NOR flash on mt7621 is mapped to 0x1fc0 and lzma
loader can read compressed kernel directly from flash. 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.
You could take a look at the tp-link-nolzma recipe in:
target/linux/ath79/image/common-tp-link.mk
and see if you could implement a similar solution for mt7621.
Note: You need to fix AR71XX_FLASH_START defined in:
target/linux/ramips/image/lzma-loader/src/loader.c
to 0x1fc0 for this method to work.

If you can't implement it, I'm fine with your current solution too.
but I prefer to drop patch 1/2 and write the complete kernel
recipe for dir-860l only. It's a bit confusing to use "KERNEL +="

-- 
Regards,
Chuanhong Guo

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L

2020-04-19 Thread Szabolcs Hubai
 ezt írta (időpont: 2020. ápr. 19., V, 14:40):
>
> Hi,
>
> > -Original Message-
> > From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org]
> > On Behalf Of Szabolcs Hubai
> > Sent: Sonntag, 19. April 2020 02:37
> > To: openwrt-devel@lists.openwrt.org
> > Cc: Szabolcs Hubai 
> > Subject: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for
> > D-Link DIR-860L
> >
> > This device has trouble extracting big kernel from flash, and supports LZMA
> > compressed kernels only.
> >
> > Using OpenWrt kernel loader saves us 64 KB compared to the dictionary size
> > limiting workaround.
> >
> > Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
> > - original ("-d23", default): 4784188 bytes, LZMA ERROR 1
> > - with "-d19": 4915260, LZMA ERROR 1
> > - with "-d18": 4915260, diff to original: +128 KB
> > - with "-d17": 4980796, diff to original: +192 KB
> > - with this patch: 4849724, diff to original: +64 KB
> >
> > To save some CPU cycle, use minimal compression ("-a0") for the LZMA
> > compressed uImage.
> >
> > Signed-off-by: Szabolcs Hubai 
> > ---
> >  target/linux/ramips/image/mt7621.mk | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/target/linux/ramips/image/mt7621.mk
> > b/target/linux/ramips/image/mt7621.mk
> > index aa6836d50a..28d2637bd3 100644
> > --- a/target/linux/ramips/image/mt7621.mk
> > +++ b/target/linux/ramips/image/mt7621.mk
> > @@ -216,9 +216,10 @@ TARGET_DEVICES += buffalo_wsr-600dhp
> >
> >  define Device/dlink_dir-860l-b1
> >$(Device/seama)
> > +  $(Device/lzma-loader)
>
> I do not really see the benefit of having this definition if you have to 
> modify it below anyway.
> Having seen this, I'd prefer to drop patch 1/2 entirely and just add the 
> necessary adjustments directly to this particular device:
>
> LOADER_TYPE := bin
> KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | relocate-kernel | 
> lzma -a0 | uImage lzma
> (properly wrapped of course)
>
> If we have five devices like this at some point, I'll be happy to discuss how 
> we can create a shared recipe.
>
> Best
>
> Adrian
>

As a newcomer it took me days to leave the "KERNEL_DTB += -d21" line
alone while debugging this LZMA ERROR on this device.
With the new recipe I wanted to emphasize that D-Link DIR-860L also
uses the kernel loader method, but it needs more magic to complete the
workaround.

Sure, that one properly wrapped line should also fix the snapshot images,
but I think creating and reusing that new recipe has the added value.


I like the new recipe better, but I'm OK with the one-liner, if you
think that the new recipe is overkill for this fix.

--
Szabolcs



> >BLOCKSIZE := 64k
> >SEAMA_SIGNATURE := wrgac13_dlink.2013gui_dir860lb
> > -  KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma | uImage lzma
> > +  KERNEL += | relocate-kernel | lzma -a0 | uImage lzma
> >IMAGE_SIZE := 16064k
> >DEVICE_VENDOR := D-Link
> >DEVICE_MODEL := DIR-860L
> > --
> > 2.17.1
> >
> >
> > ___
> > openwrt-devel mailing list
> > openwrt-devel@lists.openwrt.org
> > https://lists.openwrt.org/mailman/listinfo/openwrt-devel

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L

2020-04-19 Thread mail
Hi,

> -Original Message-
> From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org]
> On Behalf Of Szabolcs Hubai
> Sent: Sonntag, 19. April 2020 02:37
> To: openwrt-devel@lists.openwrt.org
> Cc: Szabolcs Hubai 
> Subject: [OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for
> D-Link DIR-860L
> 
> This device has trouble extracting big kernel from flash, and supports LZMA
> compressed kernels only.
> 
> Using OpenWrt kernel loader saves us 64 KB compared to the dictionary size
> limiting workaround.
> 
> Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
> - original ("-d23", default): 4784188 bytes, LZMA ERROR 1
> - with "-d19": 4915260, LZMA ERROR 1
> - with "-d18": 4915260, diff to original: +128 KB
> - with "-d17": 4980796, diff to original: +192 KB
> - with this patch: 4849724, diff to original: +64 KB
> 
> To save some CPU cycle, use minimal compression ("-a0") for the LZMA
> compressed uImage.
> 
> Signed-off-by: Szabolcs Hubai 
> ---
>  target/linux/ramips/image/mt7621.mk | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/target/linux/ramips/image/mt7621.mk
> b/target/linux/ramips/image/mt7621.mk
> index aa6836d50a..28d2637bd3 100644
> --- a/target/linux/ramips/image/mt7621.mk
> +++ b/target/linux/ramips/image/mt7621.mk
> @@ -216,9 +216,10 @@ TARGET_DEVICES += buffalo_wsr-600dhp
> 
>  define Device/dlink_dir-860l-b1
>$(Device/seama)
> +  $(Device/lzma-loader)

I do not really see the benefit of having this definition if you have to modify 
it below anyway.
Having seen this, I'd prefer to drop patch 1/2 entirely and just add the 
necessary adjustments directly to this particular device:

LOADER_TYPE := bin
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | relocate-kernel | 
lzma -a0 | uImage lzma
(properly wrapped of course)

If we have five devices like this at some point, I'll be happy to discuss how 
we can create a shared recipe.

Best

Adrian

>BLOCKSIZE := 64k
>SEAMA_SIGNATURE := wrgac13_dlink.2013gui_dir860lb
> -  KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma | uImage lzma
> +  KERNEL += | relocate-kernel | lzma -a0 | uImage lzma
>IMAGE_SIZE := 16064k
>DEVICE_VENDOR := D-Link
>DEVICE_MODEL := DIR-860L
> --
> 2.17.1
> 
> 
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L

2020-04-18 Thread Szabolcs Hubai
This device has trouble extracting big kernel from flash,
and supports LZMA compressed kernels only.

Using OpenWrt kernel loader saves us 64 KB compared to the dictionary
size limiting workaround.

Factory image sizes (commit: 5f126c541a74) with "CONFIG_ALL_KMODS=y":
- original ("-d23", default): 4784188 bytes, LZMA ERROR 1
- with "-d19": 4915260, LZMA ERROR 1
- with "-d18": 4915260, diff to original: +128 KB
- with "-d17": 4980796, diff to original: +192 KB
- with this patch: 4849724, diff to original: +64 KB

To save some CPU cycle, use minimal compression ("-a0") for the LZMA
compressed uImage.

Signed-off-by: Szabolcs Hubai 
---
 target/linux/ramips/image/mt7621.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target/linux/ramips/image/mt7621.mk 
b/target/linux/ramips/image/mt7621.mk
index aa6836d50a..28d2637bd3 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -216,9 +216,10 @@ TARGET_DEVICES += buffalo_wsr-600dhp
 
 define Device/dlink_dir-860l-b1
   $(Device/seama)
+  $(Device/lzma-loader)
   BLOCKSIZE := 64k
   SEAMA_SIGNATURE := wrgac13_dlink.2013gui_dir860lb
-  KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma | uImage lzma
+  KERNEL += | relocate-kernel | lzma -a0 | uImage lzma
   IMAGE_SIZE := 16064k
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DIR-860L
-- 
2.17.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel