Skip to contentSkip to conversation

sandbox: Add instructions about building on 32-bit machines

PATCH New Simon Glass 2 participants 15 messages Jul 22, 2016 – Jul 26, 2016 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 sandbox: Add instructions about building on 32-bit machines

Sandbox is built with 64-bit ints by default. This doesn't work properly on 32-bit machines.

---

 board/sandbox/README.sandbox | 3 +++
 include/configs/sandbox.h    | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
board/sandbox/README.sandbox +3 -0
index 9fe3bf1..ed820d3 100644
@@ -44,6 +44,9 @@ Note:
       make sandbox_defconfig all NO_SDL=1
       ./u-boot
 
+   If you are building on a 32-bit machine you may get errors from __ffs.h
+   about shifting more than the machine word size. Edit the config file
+   include/configs/sandbox.h and change CONFIG_SANDBOX_BITS_PER_LONG to 32.
 
 U-Boot will start on your computer, showing a sandbox emulation of the serial
 console:
include/configs/sandbox.h +4 -1
index 4de89f8..197d8bb 100644
@@ -27,7 +27,10 @@
 
 #define CONFIG_SYS_STDIO_DEREGISTER
 
-/* Number of bits in a C 'long' on this architecture */
+/*
+ * Number of bits in a C 'long' on this architecture. Set this to 32 when
+ * building on a 32-bit machine.
+ */
 #define CONFIG_SANDBOX_BITS_PER_LONG	64
 
 #define CONFIG_LMB
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH 2/5 lzmadec: Use the same type as the lzma call

With sandbox on 32-bit the size_t type can be a little inconsistent. Use the same type as the caller expects to avoid a compiler warning.

---

 cmd/lzmadec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
cmd/lzmadec.c +3 -2
index 1ad9ed6..c78df82 100644
@@ -20,7 +20,7 @@
 static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
 	unsigned long src, dst;
-	unsigned long src_len = ~0UL, dst_len = ~0UL;
+	SizeT src_len = ~0UL, dst_len = ~0UL;
 	int ret;
 
 	switch (argc) {
@@ -40,7 +40,8 @@ static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 
 	if (ret != SZ_OK)
 		return 1;
-	printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
+	printf("Uncompressed size: %ld = %#lX\n", (ulong)src_len,
+	       (ulong)src_len);
 	setenv_hex("filesize", src_len);
 
 	return 0;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#2 lore raw

PATCH 2/5 lzmadec: Use the same type as the lzma call

Quoted 4 lines · Simon Glass

With sandbox on 32-bit the size_t type can be a little inconsistent. Use the same type as the caller expects to avoid a compiler warning.

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/20160722/8bad12e0/attachment.sig>
#3 lore raw

PATCH 2/5 lzmadec: Use the same type as the lzma call

In reply to Simon Glass
Quoted 5 lines · Simon Glass

With sandbox on 32-bit the size_t type can be a little inconsistent. Use the same type as the caller expects to avoid a compiler warning.

Applied to u-boot/master, 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/20160725/4ba51b37/attachment.sig>
#4 lore raw

PATCH 3/5 part_efi: Fix compiler warning on 32-bit sandbox

In reply to Simon Glass

This fixes a mismatch between the %zu format and the type used on sandbox.

---

 disk/part_efi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
disk/part_efi.c +5 -5
index 0af1e92..01f71be 100644
@@ -886,9 +886,10 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
 	count = le32_to_cpu(pgpt_head->num_partition_entries) *
 		le32_to_cpu(pgpt_head->sizeof_partition_entry);
 
-	debug("%s: count = %u * %u = %zu\n", __func__,
+	debug("%s: count = %u * %u = %lu\n", __func__,
 	      (u32) le32_to_cpu(pgpt_head->num_partition_entries),
-	      (u32) le32_to_cpu(pgpt_head->sizeof_partition_entry), count);
+	      (u32) le32_to_cpu(pgpt_head->sizeof_partition_entry),
+	      (ulong)count);
 
 	/* Allocate memory for PTE, remember to FREE */
 	if (count != 0) {
@@ -897,9 +898,8 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
 	}
 
 	if (count == 0 || pte == NULL) {
-		printf("%s: ERROR: Can't allocate 0x%zX "
-		       "bytes for GPT Entries\n",
-			__func__, count);
+		printf("%s: ERROR: Can't allocate %#lX bytes for GPT Entries\n",
+		       __func__, (ulong)count);
 		return NULL;
 	}
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#5 lore raw

PATCH 3/5 part_efi: Fix compiler warning on 32-bit sandbox

Quoted 3 lines · Simon Glass

This fixes a mismatch between the %zu format and the type used on sandbox.

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/20160722/937f7415/attachment.sig>
#6 lore raw

PATCH 3/5 part_efi: Fix compiler warning on 32-bit sandbox

In reply to Simon Glass
Quoted 4 lines · Simon Glass

This fixes a mismatch between the %zu format and the type used on sandbox.

Applied to u-boot/master, 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/20160725/78f9e95b/attachment.sig>
#7 lore raw

PATCH 4/5 hashtable: Fix compiler warning on 32-bit sandbox

In reply to Simon Glass

This fixes a mismatch between the %zu format and the type used on sandbox.

---

 lib/hashtable.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/hashtable.c +5 -5
index 435e2a6..4e52b36 100644
@@ -602,8 +602,8 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag,
 		return (-1);
 	}
 
-	debug("EXPORT  table = %p, htab.size = %d, htab.filled = %d, "
-		"size = %zu\n", htab, htab->size, htab->filled, size);
+	debug("EXPORT  table = %p, htab.size = %d, htab.filled = %d, size = %lu\n",
+	      htab, htab->size, htab->filled, (ulong)size);
 	/*
 	 * Pass 1:
 	 * search used entries,
@@ -657,8 +657,8 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag,
 	/* Check if the user supplied buffer size is sufficient */
 	if (size) {
 		if (size < totlen + 1) {	/* provided buffer too small */
-			printf("Env export buffer too small: %zu, "
-				"but need %zu\n", size, totlen + 1);
+			printf("Env export buffer too small: %lu, but need %lu\n",
+			       (ulong)size, (ulong)totlen + 1);
 			__set_errno(ENOMEM);
 			return (-1);
 		}
@@ -790,7 +790,7 @@ int himport_r(struct hsearch_data *htab,
 
 	/* we allocate new space to make sure we can write to the array */
 	if ((data = malloc(size + 1)) == NULL) {
-		debug("himport_r: can't malloc %zu bytes\n", size + 1);
+		debug("himport_r: can't malloc %lu bytes\n", (ulong)size + 1);
 		__set_errno(ENOMEM);
 		return 0;
 	}
Signature · 1 line
2.8.0.rc3.226.g39d4020
#8 lore raw

PATCH 4/5 hashtable: Fix compiler warning on 32-bit sandbox

Quoted 3 lines · Simon Glass

This fixes a mismatch between the %zu format and the type used on sandbox.

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/20160722/6718e941/attachment.sig>
#9 lore raw

PATCH 4/5 hashtable: Fix compiler warning on 32-bit sandbox

In reply to Simon Glass
Quoted 4 lines · Simon Glass

This fixes a mismatch between the %zu format and the type used on sandbox.

Applied to u-boot/master, 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/20160725/454f3ca2/attachment.sig>
#10 lore raw

PATCH 5/5 dtoc: Correct the type widening code in fdt_fallback

In reply to Simon Glass

This code does not match the fdt version in fdt.py. When dtoc is unable to use the Python libfdt library, it uses the fallback version, which does not widen arrays correctly.

Fix this to avoid a warning 'excess elements in array initialize' in dt-platdata.c which happens on some platforms.

---

 tools/dtoc/fdt_fallback.py | 6 ++++++
 1 file changed, 6 insertions(+)
tools/dtoc/fdt_fallback.py +6 -0
index 14decf3..9ed11e4 100644
@@ -71,6 +71,12 @@ class Prop:
         if type(newprop.value) == list and type(self.value) != list:
             self.value = newprop.value
 
+        if type(self.value) == list and len(newprop.value) > len(self.value):
+            val = fdt_util.GetEmpty(self.type)
+            while len(self.value) < len(newprop.value):
+                self.value.append(val)
+
+
 class Node:
     """A device tree node
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#11 lore raw

PATCH 5/5 dtoc: Correct the type widening code in fdt_fallback

Quoted 9 lines · Simon Glass

This code does not match the fdt version in fdt.py. When dtoc is unable to use the Python libfdt library, it uses the fallback version, which does not widen arrays correctly.

Fix this to avoid a warning 'excess elements in array initialize' in dt-platdata.c which happens on some platforms.

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/20160722/3719ea98/attachment.sig>
#12 lore raw

PATCH 5/5 dtoc: Correct the type widening code in fdt_fallback

In reply to Simon Glass
Quoted 10 lines · Simon Glass

This code does not match the fdt version in fdt.py. When dtoc is unable to use the Python libfdt library, it uses the fallback version, which does not widen arrays correctly.

Fix this to avoid a warning 'excess elements in array initialize' in dt-platdata.c which happens on some platforms.

Applied to u-boot/master, 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/20160725/9e6bf2d4/attachment.sig>
#13 lore raw

PATCH 1/5 sandbox: Add instructions about building on 32-bit machines

In reply to Simon Glass
Quoted 4 lines · Simon Glass

Sandbox is built with 64-bit ints by default. This doesn't work properly on 32-bit machines.

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/20160722/308812c3/attachment.sig>
#14 lore raw

PATCH 1/5 sandbox: Add instructions about building on 32-bit machines

In reply to Simon Glass
Quoted 5 lines · Simon Glass

Sandbox is built with 64-bit ints by default. This doesn't work properly on 32-bit machines.

Applied to u-boot/master, 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/20160725/6b8c7d40/attachment.sig>