Skip to contentSkip to conversation

cmd: fsfitxtract: Extract a part of a FIT multi-image stored on a filesystem

PATCH New Alexey Ignatov 2 participants 2 messages May 21, 2017 – Jun 5, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cmd: fsfitxtract: Extract a part of a FIT multi-image stored on a filesystem

Sometimes we interested only in one single small subimage from big multipart FIT. This command tries to avoid reading out the whole FIT because of memory or time considerations.
Since we don't have mmap() in U-Boot, this is done by reading the file in small chunks and trying to parse FIT, skipping reading the payload data of all images before the requested one, while preserving FIT structure.

Changelog:

v2:
* Skip unneeded subimages data instead of reading it out
* Read whole data in one operation
* Lot of refactoring
* Faster, more versatile and robust
* Improved code readability

v1:
* First submission to maillist

---
 cmd/Kconfig |   7 ++
 cmd/ximg.c  | 356 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 363 insertions(+)
cmd/Kconfig +7 -0
index d9f7151bac..ff8ade96b4 100644
@@ -265,6 +265,13 @@ config CMD_XIMG
 	help
 	  Extract a part of a multi-image.
 
+config CMD_FSFITXIMG
+	bool "fsfitxtract"
+	default y
+	depends on FIT
+	help
+	  Extract a part of a FIT multi-image stored on a filesystem
+
 config CMD_POWEROFF
 	bool
 
cmd/ximg.c +356 -0

365 lines not on this page · raw message

Signature · 1 line
2.12.2
#1 lore raw

PATCH v2 1/1 cmd: fsfitxtract: Extract a part of a FIT multi-image stored on a filesystem

Quoted 16 lines · Alexey Ignatov

Sometimes we interested only in one single small subimage from big multipart FIT. This command tries to avoid reading out the whole FIT because of memory or time considerations.
Since we don't have mmap() in U-Boot, this is done by reading the file in small chunks and trying to parse FIT, skipping reading the payload data of all images before the requested one, while preserving FIT structure.

Changelog:

v2:
* Skip unneeded subimages data instead of reading it out
* Read whole data in one operation
* Lot of refactoring
* Faster, more versatile and robust
* Improved code readability

Quoted 2 lines

v1:
* First submission to maillist

The changelog needs to go below the '---' so that git will drop it when applyng.

[snip]

cmd/ximg.c U_BOOT_CMD( · line 565

Quoted 1 line
cmd/ximg.c +1 -0
+	debug("data at %p, len %lu\n", data, len);

This should be %zu not %lu.

[snip]

Quoted 4 lines
cmd/ximg.c +4 -0
+	if (fit_image_get_comp(ctx.fdt, noffset, &comp)) {
+		puts("Could not find FIT subimage compression type\n");
+		return 1;
+	}

[snip]

cmd/ximg.c U_BOOT_CMD( · line 624

Quoted 2 lines
cmd/ximg.c +2 -0
+	if (!decompress_data(ctx.dest, (ulong)data, (ulong)len, comp, 0))
+		return 1;

There is no decompress_data function. And I suspect what you should do here is the switch logic from common/bootm.c::bootm_decomp_image() without the print (so re-factor that function a bit more).

Finally, you're adding some whitespace issues (empty lines with just spaces), please run checkpatch.pl against it before submission next time. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170605/c93eebf0/attachment.sig>