Hello Linus,

This is just a question: doesn't it work with "openwrt,offset" property of mtdsplit_uimage parser instead of modifying that parser?

I'm thinking like the following:

- dts:

partition@10000 {
    compatible = "openwrt,uimage", "denx,uimage";
    reg = <0x010000 0xfe0000>;
    openwrt,offset = <0x20000>;
    label = "firmware";
};

- image/Makefile:

IMAGE/sysupgrade.bin := cfe-bin-uboot | pad-to 128k | \
    append-kernel | pad-to $$$$$$$$(($$(BLOCKSIZE))) | \
    append-rootfs | append-metadata


Thanks,

Hiroshi

On 2024/01/24 7: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.

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.wall...@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,

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

Reply via email to