public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cmd: set filesize variable in ubi read
@ 2017-08-30 16:38 Holger Dengler
  2017-08-31  7:25 ` Heiko Schocher
  2017-09-12  7:58 ` [U-Boot] [PATCH v1] " Holger Dengler
  0 siblings, 2 replies; 7+ messages in thread
From: Holger Dengler @ 2017-08-30 16:38 UTC (permalink / raw)
  To: u-boot

After a successful read of a UBI volume, the variable filesize is set
to the number of read bytes. To boot linux with a raw initramfs/initrd,
you must specify the exact size of the initramfs/initrd image in boot
command. If the initramfs/inird is read from UBI volume, $filesize is
required to access the number of read bytes.

Example:
  ubi read ${loadaddr} kernelvol
  ubi read ${fdtaddr} dtbvol
  ubi read ${initrd_addr} initrdvol
  bootz ${loadaddr} ${initrd_addr}:${filesize} ${fdt_addr}

Signed-off-by: Holger Dengler <dengler@linutronix.de>
---
 cmd/ubi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index 222be5a357..c49c7f94df 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -334,6 +334,7 @@ int ubi_volume_read(char *volume, char *buf, size_t size)
 	unsigned long long tmp;
 	struct ubi_volume *vol;
 	loff_t offp = 0;
+	size_t len_read;
 
 	vol = ubi_find_volume(volume);
 	if (vol == NULL)
@@ -373,6 +374,7 @@ int ubi_volume_read(char *volume, char *buf, size_t size)
 	tmp = offp;
 	off = do_div(tmp, vol->usable_leb_size);
 	lnum = tmp;
+	len_read = size;
 	do {
 		if (off + len >= vol->usable_leb_size)
 			len = vol->usable_leb_size - off;
@@ -398,6 +400,9 @@ int ubi_volume_read(char *volume, char *buf, size_t size)
 		len = size > tbuf_size ? tbuf_size : size;
 	} while (size);
 
+	if (!size)
+		setenv_hex("filesize", len_read);
+
 	free(tbuf);
 	return err;
 }
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-09-15  5:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-30 16:38 [U-Boot] [PATCH] cmd: set filesize variable in ubi read Holger Dengler
2017-08-31  7:25 ` Heiko Schocher
2017-09-12  7:35   ` Heiko Schocher
2017-09-12  7:45     ` Holger Dengler
2017-09-12  7:58 ` [U-Boot] [PATCH v1] " Holger Dengler
2017-09-12  8:21   ` Heiko Schocher
2017-09-15  5:49   ` Heiko Schocher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox