[PATCH] mtdsplit_uimage: Split also after offsetted uImage

Paul D newtwen at gmail.com
Thu Jan 25 15:21:23 PST 2024


The simple past tense of offset is... offset :)

Suggested: Split also after offset uImage



BTW: was this what I tested in your factory and sysimages for the XG6846?

If so can you roll a fresh one with this patch? Then I can give you a 
more recent Tested-By:


On 2024-01-23 23:17, Linus Walleij wrote:
> The uImage splitter recognizes a rootfs either:
> 
> 1. Right after the uImage if it comes first in the
>     partition or
> 2. Before the uImage if it is located at an offset
>     inside the partition.
> 
> Add a third case:
> 
> 3. After the uImage also at an offset inside the
>     partition, if and only if 1 and 2 fails.
> 
> The reason why this is needed is because on the
> BCM6328-based Inteno XG6846 we need to put a small
> U-Boot binary first in the partition, then the uImage,
> then the rootfs.

Suggest rewording to:

This is necessary because the BCM6328-based Inteno XG6846 won't boot an 
image without a small U-Boot binary first in the partition followed by 
the uImage, then the rootfs.


Then it doesn't depend on our needs :)

> 
> The U-Boot binary that comes first cannot be split off
> into its own partition in this case because it needs
> to be part of the bigger "firmware" partition. Which
> we use for installation and upgrades.
> 
> Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
> ---
>   .../files/drivers/mtd/mtdsplit/mtdsplit_uimage.c      | 19 +++++++++++++++----
>   1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
> index a3e55fb1fe38..de043fb9f702 100644
> --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
> +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
> @@ -217,11 +217,22 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
>   		if (ret) {
>   			pr_debug("no rootfs before uImage in \"%s\"\n",
>   				 master->name);
> -			goto err_free_buf;
> -		}
>   
> -		rootfs_offset = 0;
> -		rootfs_size = uimage_offset;
> +			/* Try after the uImage */
> +			ret = mtd_find_rootfs_from(master, uimage_offset + uimage_size,
> +						   master->size, &rootfs_offset, &type);
> +			if (ret) {
> +				pr_debug("no rootfs after uImage either in \"%s\"\n",
> +					 master->name);
> +				goto err_free_buf;
> +			}
> +
> +			rootfs_size = master->size - rootfs_offset;
> +			uimage_size = rootfs_offset - uimage_offset;
> +		} else {
> +			rootfs_offset = 0;
> +			rootfs_size = uimage_offset;
> +		}
>   	}
>   
>   	if (rootfs_size == 0) {
> 
> ---
> base-commit: 1b7e62b20b1735fcdc498a35e005afcd775abcf4
> change-id: 20240123-offsetted-uimage-splitter-f5b65f0df2ed
> 
> Best regards,




More information about the openwrt-devel mailing list