[PATCH] bcm47xx: relocate LZMA loader

Hauke Mehrtens hauke at hauke-m.de
Sun Nov 7 04:38:04 PST 2021


On 11/7/21 10:37 AM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal at milecki.pl>
> 
> This allows loader to handle kernel 5.10 that grew bigger than 5.4.
> 
> Variations tested on BCM4706:
> 
> BAD:
> BZ_TEXT_START  := 0x80600000
> BZ_STACK_START := 0x80700000
> 
> GOOD:
> BZ_TEXT_START	:= 0x80700000
> BZ_STACK_START	:= 0x80700000
> 
> BAD:
> BZ_TEXT_START	:= 0x80600000
> BZ_STACK_START	:= 0x80800000
> 
> GOOD:
> BZ_TEXT_START	:= 0x80700000
> BZ_STACK_START	:= 0x80800000

I did some changes to these values 4 years ago here and explained the 
boot process a little bit:
https://git.openwrt.org/2909a4b78e2bce5f6b9c35361866d5e9477a1bdc
https://git.openwrt.org/d5cf4a5aa4a3211012967748569d9a631ee19466

> 
> Cc: Hauke Mehrtens <hauke at hauke-m.de>
> Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
> ---
>   target/linux/bcm47xx/image/lzma-loader/src/Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/linux/bcm47xx/image/lzma-loader/src/Makefile b/target/linux/bcm47xx/image/lzma-loader/src/Makefile
> index a08fc05b9f..94b78254b8 100644
> --- a/target/linux/bcm47xx/image/lzma-loader/src/Makefile
> +++ b/target/linux/bcm47xx/image/lzma-loader/src/Makefile
> @@ -18,7 +18,7 @@
>   #
>   
>   TEXT_START	:= 0x80001000
> -BZ_TEXT_START	:= 0x80600000
> +BZ_TEXT_START	:= 0x80700000
>   BZ_STACK_START	:= 0x80700000

We should also increase BZ_STACK_START.

The code sets the stack pointer to BZ_STACK_START and then relocates 
itself to BZ_TEXT_START. If they are pointing to the same address the 
relocation process would overwrite the stack. We store the fw boot 
arguments on the stack and probably also use it for the LZMA code.

All devices have at least 16MB RAM and we should be able to access this 
RAM from this code, we can also use this all for the decompression.

Hauke



More information about the openwrt-devel mailing list