]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fwu: mtd: Fix dfu_alt_info generation for 2 images per bank
authorMichal Simek <michal.simek@amd.com>
Thu, 13 Jul 2023 14:36:27 +0000 (16:36 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 25 Jul 2023 16:44:46 +0000 (12:44 -0400)
Code rewrites the last char of size with adding &. It is visible from
dfu_alt_info print before this patch:

Make dfu_alt_info: 'mtd nor0=bank0 raw 2320000 80000;bank1 raw 27a0000
8000&mtd nor0=bank0 raw 23a0000 4000000;bank1 raw 2820000 4000000'

And after it:
Make dfu_alt_info: 'mtd nor0=bank0 raw 2320000 80000;bank1 raw 27a0000
80000&mtd nor0=bank0 raw 23a0000 4000000;bank1 raw 2820000 4000000'

Size for bank0 and bank1 must be the same because it is the same image.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Acked-by: Jassi Brar <jaswinder.singh@linaro.org>
lib/fwu_updates/fwu_mtd.c

index b73111ae24da7a64557d5208af869ed54c411552..69cd3d7001f98becedb20378a92475735bb973ab 100644 (file)
@@ -175,8 +175,10 @@ int fwu_gen_alt_info_from_mtd(char *buf, size_t len, struct mtd_info *mtd)
 
                l = strlen(buf);
                /* Replace the last ';' with '&' if there is another image. */
-               if (i != CONFIG_FWU_NUM_IMAGES_PER_BANK - 1 && l)
-                       buf[l - 1] = '&';
+               if (i != CONFIG_FWU_NUM_IMAGES_PER_BANK - 1 && l) {
+                       buf[l] = '&';
+                       buf++;
+               }
                len -= l;
                buf += l;
        }