Skip to contentSkip to conversation

image: fix getenv_bootm_size() function

PATCH In review Masahiro Yamada 5 participants 9 messages Dec 18, 2015 – Feb 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 image: fix getenv_bootm_size() function

Currently, this function returns wrong size if "bootm_low" is defined, but "bootm_size" is not.

---

 common/image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/image.c +2 -2
index d63d9e0..f4a1dc8 100644
@@ -472,9 +472,9 @@ phys_size_t getenv_bootm_size(void)
 
 
 #if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
-	return gd->bd->bi_dram[0].size - tmp;
+	return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);
 #else
-	return gd->bd->bi_memsize - tmp;
+	return gd->bd->bi_memsize - (tmp - gd->bd->bi_memstart);
 #endif
 }
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 image: fix getenv_bootm_size() function

Hi Masahiro,

Quoted 26 lines · Masahiro Yamada

Currently, this function returns wrong size if "bootm_low" is defined, but "bootm_size" is not.

---

 common/image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/image.c +2 -3
index d63d9e0..f4a1dc8 100644
@@ -472,9 +472,9 @@ phys_size_t getenv_bootm_size(void)
 
 
 #if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
-       return gd->bd->bi_dram[0].size - tmp;
+       return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);
 #else
-       return gd->bd->bi_memsize - tmp;
+       return gd->bd->bi_memsize - (tmp - gd->bd->bi_memstart);
 #endif
 }
 
--
Quoted 2 lines

1.9.1

But can you please add a comment to the image.h header file as to what this function is supposed to do?

Regards,
Simon

#2 lore raw

PATCH 1/1 image: fix getenv_bootm_size() function

Hi Simon,

2016-01-08 12:33 GMT+09:00 Simon Glass <[email protected]>:

Quoted 29 lines

Hi Masahiro,

Quoted 25 lines · Masahiro Yamada

Currently, this function returns wrong size if "bootm_low" is defined, but "bootm_size" is not.

---

 common/image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/image.c +2 -2
index d63d9e0..f4a1dc8 100644
@@ -472,9 +472,9 @@ phys_size_t getenv_bootm_size(void)
 
 
 #if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
-       return gd->bd->bi_dram[0].size - tmp;
+       return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);
 #else
-       return gd->bd->bi_memsize - tmp;
+       return gd->bd->bi_memsize - (tmp - gd->bd->bi_memstart);
 #endif
 }
 
Quoted 8 lines
Quoted 3 lines

--
1.9.1

But can you please add a comment to the image.h header file as to what this function is supposed to do?

This patch is a bug-fix and self-contained.

I assume you suggested the additional comment be a separate work.

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw

PATCH 1/1 image: fix getenv_bootm_size() function

Hi Masahiro,

Quoted 39 lines · Masahiro Yamada

Hi Simon,

2016-01-08 12:33 GMT+09:00 Simon Glass <[email protected]>:

Quoted 35 lines

Hi Masahiro,

Quoted 26 lines · Masahiro Yamada

Currently, this function returns wrong size if "bootm_low" is defined, but "bootm_size" is not.

---

 common/image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/image.c +2 -3
index d63d9e0..f4a1dc8 100644
@@ -472,9 +472,9 @@ phys_size_t getenv_bootm_size(void)
 
 
 #if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
-       return gd->bd->bi_dram[0].size - tmp;
+       return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);
 #else
-       return gd->bd->bi_memsize - tmp;
+       return gd->bd->bi_memsize - (tmp - gd->bd->bi_memstart);
 #endif
 }
 
--
Quoted 2 lines

1.9.1

Quoted 8 lines
Quoted 2 lines

But can you please add a comment to the image.h header file as to what this function is supposed to do?

This patch is a bug-fix and self-contained.

I assume you suggested the additional comment be a separate work.

That's OK with me. It takes ages to understand what the function does so a comment would really help.

Regards,
Simon

#4 lore raw

PATCH 1/1 image: fix getenv_bootm_size() function

Tom,

This patch is a bug-fix
and still keeping me from using bootm_low on my boards.

Please apply!

Signature · 2 lines
Best Regards
Masahiro Yamada
#5 lore raw
In reply to Masahiro Yamada
Quoted 5 lines · Masahiro Yamada

Currently, this function returns wrong size if "bootm_low" is defined, but "bootm_size" is not.

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: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160119/8c919c5a/attachment.sig>
#6 lore raw

PATCH 1/1 image: fix getenv_bootm_size() function

In reply to Masahiro Yamada
Quoted 14 lines · Masahiro Yamada

Currently, this function returns wrong size if "bootm_low" is defined, but "bootm_size" is not.

---

  common/image.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
common/image.c +0 -0
index d63d9e0..f4a1dc8 100644

common/image.c phys_size_t getenv_bootm_size(void) · line 479

Quoted 10 lines
common/image.c +2 -2
@@ -472,9 +472,9 @@ phys_size_t getenv_bootm_size(void)
 
 
  #if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
-	return gd->bd->bi_dram[0].size - tmp;
+	return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);
  #else
-	return gd->bd->bi_memsize - tmp;
+	return gd->bd->bi_memsize - (tmp - gd->bd->bi_memstart);
  #endif
  }

Hi Masahiro,

your commit has been merged on 19.1. this year.
Today i ran a test on my tseries board with most current u-boot/master.

I ran into trouble booting my linux kernel:

---
Kernel image @ 0x80200000 [ 0x000000 - 0x222720 ] ## Loading init Ramdisk from Legacy Image at 80a00000 ...

    Image Name:
    Image Type:   ARM Linux RAMDisk Image (uncompressed)
    Data Size:    12452646 Bytes = 11.9 MiB
    Load Address: 00000000
    Entry Point:  00000000
## Flattened Device Tree blob at 80100000
    Booting using the fdt blob at 0x80100000

ERROR: Failed to allocate 0xbe0326 bytes below 0x10000000. ramdisk - allocation error
FDT creation failed! hanging...### ERROR ### Please RESET the board ###
---

I debugged bit am came to the conclusio, that the line

+ return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);

brings me into trouble.

On my board DRAM is configured as follows:
U-Boot (BuR V2.0)# bdinfo
arch_number = 0xFFFFFFFF
boot_params = 0x80000100
DRAM bank = 0x00000000
*-> start = 0x80000000**
**-> size = 0x10000000**
*
so size minus start would give a negative number.
I tried local revert of this commit and everything works as before.

more correct would be

+ return gd->bd->bi_dram[0].start - (tmp - gd->bd->bi_dram[0].size);

whats your thinking about?

best regards,
Hannes

#7 lore raw

PATCH 1/1 image: fix getenv_bootm_size() function

Hi Hannes

I had the same problem. http://patchwork.ozlabs.org/patch/579391/ fixed it.

Regards,
Matthias

2016-02-08 15:01 GMT+01:00 Hannes Schmelzer <[email protected]>:

Quoted 80 lines · Masahiro Yamada
Quoted 15 lines

Currently, this function returns wrong size if "bootm_low" is defined, but "bootm_size" is not.

---

  common/image.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
common/image.c +0 -0
index d63d9e0..f4a1dc8 100644

common/image.c phys_size_t getenv_bootm_size(void) · line 477

Quoted 8 lines
common/image.c +2 -2
@@ -472,9 +472,9 @@ phys_size_t getenv_bootm_size(void)
      #if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
-       return gd->bd->bi_dram[0].size - tmp;
+       return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);
  #else
-       return gd->bd->bi_memsize - tmp;
+       return gd->bd->bi_memsize - (tmp - gd->bd->bi_memstart);
  #endif
  }

Hi Masahiro,

your commit has been merged on 19.1. this year.
Today i ran a test on my tseries board with most current u-boot/master.

I ran into trouble booting my linux kernel:

---
Kernel image @ 0x80200000 [ 0x000000 - 0x222720 ] ## Loading init Ramdisk from Legacy Image at 80a00000 ...
Image Name:

   Image Type:   ARM Linux RAMDisk Image (uncompressed)
   Data Size:    12452646 Bytes = 11.9 MiB
   Load Address: 00000000
   Entry Point:  00000000

## Flattened Device Tree blob at 80100000
Booting using the fdt blob at 0x80100000
ERROR: Failed to allocate 0xbe0326 bytes below 0x10000000. ramdisk - allocation error
FDT creation failed! hanging...### ERROR ### Please RESET the board ###
---

I debugged bit am came to the conclusio, that the line

+ return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);

brings me into trouble.

On my board DRAM is configured as follows:
U-Boot (BuR V2.0)# bdinfo
arch_number = 0xFFFFFFFF
boot_params = 0x80000100
DRAM bank = 0x00000000
*-> start = 0x80000000**
**-> size = 0x10000000**
*
so size minus start would give a negative number.
I tried local revert of this commit and everything works as before.

more correct would be

+ return gd->bd->bi_dram[0].start - (tmp - gd->bd->bi_dram[0].size);

whats your thinking about?

best regards,
Hannes

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#8 lore raw

PATCH 1/1 image: fix getenv_bootm_size() function

Quoted 86 lines · Matthias Wei?er

Hi Hannes

I had the same problem. http://patchwork.ozlabs.org/patch/579391/ fixed it.

Regards,
Matthias

2016-02-08 15:01 GMT+01:00 Hannes Schmelzer <[email protected]>:

Quoted 77 lines · Masahiro Yamada
Quoted 14 lines

Currently, this function returns wrong size if "bootm_low" is defined, but "bootm_size" is not.

---

   common/image.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
common/image.c +0 -0
index d63d9e0..f4a1dc8 100644

common/image.c phys_size_t getenv_bootm_size(void) · line 477

Quoted 8 lines
common/image.c +2 -2
@@ -472,9 +472,9 @@ phys_size_t getenv_bootm_size(void)
       #if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
-       return gd->bd->bi_dram[0].size - tmp;
+       return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);
   #else
-       return gd->bd->bi_memsize - tmp;
+       return gd->bd->bi_memsize - (tmp - gd->bd->bi_memstart);
   #endif
   }

Hi Masahiro,

your commit has been merged on 19.1. this year.
Today i ran a test on my tseries board with most current u-boot/master.

I ran into trouble booting my linux kernel:

---
Kernel image @ 0x80200000 [ 0x000000 - 0x222720 ] ## Loading init Ramdisk from Legacy Image at 80a00000 ...

    Image Name:
    Image Type:   ARM Linux RAMDisk Image (uncompressed)
    Data Size:    12452646 Bytes = 11.9 MiB
    Load Address: 00000000
    Entry Point:  00000000
## Flattened Device Tree blob at 80100000
    Booting using the fdt blob at 0x80100000

ERROR: Failed to allocate 0xbe0326 bytes below 0x10000000. ramdisk - allocation error
FDT creation failed! hanging...### ERROR ### Please RESET the board ###
---

I debugged bit am came to the conclusio, that the line

+ return gd->bd->bi_dram[0].size - (tmp - gd->bd->bi_dram[0].start);

brings me into trouble.

On my board DRAM is configured as follows:
U-Boot (BuR V2.0)# bdinfo
arch_number = 0xFFFFFFFF
boot_params = 0x80000100
DRAM bank = 0x00000000
*-> start = 0x80000000**
**-> size = 0x10000000**
*
so size minus start would give a negative number.
I tried local revert of this commit and everything works as before.

more correct would be

+ return gd->bd->bi_dram[0].start - (tmp - gd->bd->bi_dram[0].size);

whats your thinking about?

best regards,
Hannes

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Hi Matthias,

this also fixes my problem.

many thanks!

best regards,
Hannes