Skip to contentSkip to conversation

cmd: set filesize variable in ubi read

PATCH New Holger Dengler 2 participants 7 messages Aug 30, 2017 – Sep 15, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: set filesize variable in ubi read

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}

---
 cmd/ubi.c | 5 +++++
 1 file changed, 5 insertions(+)
cmd/ubi.c +5 -0
index 222be5a357..c49c7f94df 100644
@@ -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;
 }
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/1 cmd: set filesize variable in ubi read

Hello Holger,

Am 30.08.2017 um 18:38 schrieb Holger Dengler:

Quoted 12 lines

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}
Quoted 4 lines
---
  cmd/ubi.c | 5 +++++
  1 file changed, 5 insertions(+)

Thanks!

As new release is near, I pickup this patch when the next merge window opens.

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#2 lore raw

PATCH 1/1 cmd: set filesize variable in ubi read

Hello Holger,

Am 31.08.2017 um 09:25 schrieb Heiko Schocher:

Quoted 20 lines

Hello Holger,

Am 30.08.2017 um 18:38 schrieb Holger Dengler:

Quoted 12 lines

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}
Quoted 4 lines
---
  cmd/ubi.c | 5 +++++
  1 file changed, 5 insertions(+)
Quoted 6 lines

Thanks!

As new release is near, I pickup this patch when the next merge window opens.

Just tried a travis build, and it breaks a lot of boards, see

https://travis-ci.org/hsdenx/u-boot-ubi/builds/274457374

Do you have time to look into?

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#3 lore raw

PATCH 1/1 cmd: set filesize variable in ubi read

Hi Heiko,

sorry, my fault. I missed, that the function has been renamed. I'll resend the patch.

Quoted 38 lines · Heiko Schocher

Hello Holger,

Am 31.08.2017 um 09:25 schrieb Heiko Schocher:

Quoted 20 lines

Hello Holger,

Am 30.08.2017 um 18:38 schrieb Holger Dengler:

Quoted 12 lines

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}

Quoted 4 lines

---
  cmd/ubi.c | 5 +++++

  1 file changed, 5 insertions(+)
Quoted 6 lines

Thanks!

As new release is near, I pickup this patch when the next merge window opens.

Just tried a travis build, and it breaks a lot of boards, see

https://travis-ci.org/hsdenx/u-boot-ubi/builds/274457374

Do you have time to look into?

bye,
Heiko

Signature · 12 lines
Gruß,
Holger Dengler
--
phone: +49 7556 25 999 14; fax: +49 7556 25 999 99

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170912/f0d272ef/attachment.sig>
#4 lore raw

PATCH 1/1 cmd: set filesize variable in ubi read

In reply to Holger Dengler

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}

---
 cmd/ubi.c | 5 +++++
 1 file changed, 5 insertions(+)
cmd/ubi.c +5 -0
index 222be5a357..ac9a582437 100644
@@ -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)
+		env_set_hex("filesize", len_read);
+
 	free(tbuf);
 	return err;
 }
Signature · 1 line
2.14.1
#5 lore raw

PATCH 1/1 cmd: set filesize variable in ubi read

Hello Holger,

thanks for the fast fix! Hm... some nitpick:

This is v2 not v1 ... seems patchwork has a problem, as your patch does not popup at:
http://patchwork.ozlabs.org/project/uboot/list/?page=1

(or patchwork does work slowly today ...)

Am 12.09.2017 um 09:58 schrieb Holger Dengler:

Quoted 6 lines

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.

Quoted 8 lines

Example:

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

---

add here please a summary, what has changed since v1. You may use patman ... see u-boot:tools/patman/README

Thanks!

Nevertheless, I started a new travis build with this patch, see:
https://travis-ci.org/hsdenx/u-boot-ubi/builds/274502903

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#6 lore raw

PATCH 1/1 cmd: set filesize variable in ubi read

In reply to Holger Dengler

Hello Holger,

Am 12.09.2017 um 09:58 schrieb Holger Dengler:

Quoted 12 lines

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}
Quoted 4 lines
---
  cmd/ubi.c | 5 +++++
  1 file changed, 5 insertions(+)

Applied to u-boot-ubi.git

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de