[OpenWrt-Devel] [RFC, PATCH] ramips: mt7621: use OKLI lzma-loader for D-Link DIR-860L B1 (was: Re: [PATCH 2/2] ramips: mt7621: use lzma-loader for D-Link DIR-860L)
Szabolcs Hubai
szab.hu at gmail.com
Sun May 3 21:25:54 EDT 2020
Hi!
Chuanhong Guo <gch981213 at gmail.com> ezt írta (időpont: 2020. ápr. 19., V, 17:42):
>
> Hi!
>
> <snip>
>
> My original thought on this device is to use a different loader. The first
> 4MB of SPI-NOR flash on mt7621 is mapped to 0x1fc00000 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 0x1fc00000 for this method to work.
>
I managed to make the loader-okli recipes work on this DIR-860L router.
It's ugly:
target/linux/ramips/image/Makefile | 20 ++++++++++++++++++++
target/linux/ramips/image/lzma-loader/src/loader.c | 2 +-
target/linux/ramips/image/mt7621.mk | 9 ++++++++-
3 files changed, 29 insertions(+), 2 deletions(-)
... compared to the my original change:
target/linux/ramips/image/mt7621.mk | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
And it's fragile!
LOADER_FLASH_OFFS consists of:
- the address of the firmware partition (0x500000)
- loader-okli recipe's "kernel offset" argument (and the compressed size of the loader)
- the 64 byte length header from the Device/seama recipe
- and the AR71XX_FLASH_START value in loader.c
And there is a "pad to 32k" step while building the loader separately
and I don't know why it's needed to be 32k - sure it doesn't work with 24k, 16k and below.
About the AR71XX_FLASH_START= 0x10000000 in loader.c:
This is now 100% DIR-860L specific value. As you can see in the serial log
that the loader finds the kernel at 0xb0501040 which consits of the following components:
- 0x00000040: SEAMA header and metadata (see Device/seama)
- 0x00001000: the 4096 "kernel offset" argument of loader-okli
- 0x00500000: start adress of "firmware" partition
- 0xa0000000: KSEG1 address
The rest (0x10000000) is AR71XX_FLASH_START and other unknown (at lest to me) parts.
So I chose AR71XX_FLASH_START= 0x10000000.
Sure there is a room to improvement. At least move AR71XX_FLASH_START to the board file, and rename! ;)
The 4096 byte "kernel offset" is a freely chosen value: it's little bigger than the compressed lzma loader and it is padded to 4k. ;)
Anyway! It works! And it works nicely! :D
Check the timestamped serial logs below!
The double compressed lzma-loader method needs
- 1.9s for u-boot ("Uncompressing SEAMA linux.lzma ... OK")
- 1.1s for the kernel loader ("Decompressing kernel... done!")
The OKLI method needs:
- no time (0.05s) for u-boot
- 1.4s for the kernel loader
Serial log without this patch:
----
2020-05-03 20:09:55.367155157: 3: System Boot system code via Flash.
2020-05-03 20:09:55.373933177: ## Booting image at bfc50000 ...
2020-05-03 20:09:57.300117502: addr:80500000
2020-05-03 20:09:57.308441445: We have SEAMA, Image Size = 2490304
2020-05-03 20:09:57.315410096: Verifying Checksum ...
2020-05-03 20:09:59.205312048: Uncompressing SEAMA linux.lzma ... OK
2020-05-03 20:09:59.216341009: ## Transferring control to Linux (at address 00000000) ...
2020-05-03 20:09:59.222500408: ## Giving linux memsize in MB, 128
2020-05-03 20:09:59.224349797:
2020-05-03 20:09:59.226204307: Starting kernel ...
2020-05-03 20:09:59.227824058:
2020-05-03 20:09:59.289356732:
2020-05-03 20:09:59.290995300:
2020-05-03 20:09:59.297258876: OpenWrt kernel loader for MIPS based SoC
2020-05-03 20:09:59.306245212: Copyright (C) 2011 Gabor Juhos <juhosg at openwrt.org>
2020-05-03 20:10:00.417134281: Decompressing kernel... done!
2020-05-03 20:10:00.425918694: Starting kernel at 80001000...
2020-05-03 20:10:00.432489649:
2020-05-03 20:10:00.453684838: [ 0.000000] Linux version 5.4.35 (builder at buildhost) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r13108-87c909e969)) #0 SMP Mon Apr 27 23:10:48 2020
2020-05-03 20:10:00.462322280: [ 0.000000] SoC Type: MediaTek MT7621 ver:1 eco:3
2020-05-03 20:10:00.471916788: [ 0.000000] printk: bootconsole [early0] enabled
2020-05-03 20:10:00.480939230: [ 0.000000] CPU0 revision is: 0001992f (MIPS 1004Kc)
2020-05-03 20:10:00.491938368: [ 0.000000] MIPS: machine is D-Link DIR-860L B1
2020-05-03 20:10:00.503935082: [ 0.000000] Initrd not found or empty - disabling initrd
Serial log with OKLI:
----
2020-05-03 22:36:18.360052605: 3: System Boot system code via Flash.
2020-05-03 22:36:18.365448792: ## Booting image at bfc50000 ...
2020-05-03 22:36:20.299329593: addr:80500000
2020-05-03 22:36:20.320272229: We have SEAMA, Image Size = 2490304
2020-05-03 22:36:20.333914984: Verifying Checksum ...
2020-05-03 22:36:20.381790212: Uncompressing SEAMA linux.lzma ... OK
2020-05-03 22:36:20.397034839: ## Transferring control to Linux (at address 00000000) ...
2020-05-03 22:36:20.413734125: ## Giving linux memsize in MB, 128
2020-05-03 22:36:20.426230940:
2020-05-03 22:36:20.429622961: Starting kernel ...
2020-05-03 22:36:20.437932564:
2020-05-03 22:36:20.440335376:
2020-05-03 22:36:20.444103378:
2020-05-03 22:36:20.451227117: OpenWrt kernel loader for MIPS based SoC
2020-05-03 22:36:20.453709985: Copyright (C) 2011 Gabor Juhos <juhosg at openwrt.org>
2020-05-03 22:36:20.491573227: Looking for OpenWrt image... found at 0xb0501040
2020-05-03 22:36:21.845561224: Decompressing kernel... done!
2020-05-03 22:36:21.854485577: Starting kernel at 80001000...
2020-05-03 22:36:21.866553455:
2020-05-03 22:36:21.895973592: [ 0.000000] Linux version 5.4.36 (xabolcs at ut1804) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r13060-471b8bf8c1)) #0 SMP Sat May 2 23:19:08 2020
2020-05-03 22:36:21.902983786: [ 0.000000] SoC Type: MediaTek MT7621 ver:1 eco:3
2020-05-03 22:36:21.907483498: [ 0.000000] printk: bootconsole [early0] enabled
2020-05-03 22:36:21.912569091: [ 0.000000] CPU0 revision is: 0001992f (MIPS 1004Kc)
2020-05-03 22:36:21.920921080: [ 0.000000] MIPS: machine is D-Link DIR-860L B1
2020-05-03 22:36:21.931420797: [ 0.000000] Initrd not found or empty - disabling initrd
I'm glad, that I had success with this OKLI method, but does it really worth it?
Cheers,
Szabolcs
>
> <snip>
>
> --
> Regards,
> Chuanhong Guo
_______________________________________________
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