cmd: mem: fix to display wrong memory information
A message that is not in the archive (sent off-list or not yet received): CGME20210128023504epcas1p3cba0cba08a8d5baf7f72baba0ced197f@epcas1p3.samsung.com
PATCH v2 1/1 cmd: mem: fix to display wrong memory information
When run meminfo command, it's displayed wrong memory information. Because some boards are that gd->ram_size is reassigned to other value in board file.
Additionally, display a memory bank information.
On 4G RPI4 target
- Before
U-Boot> meminfo
DRAM: 948MiB
- After
U-Boot> meminfo
Bank #0: 0 948 MiB
Bank #1: 40000000 2.9 GiB
Bank #2: 0 0 Bytes
Bank #3: 0 0 Bytes
DRAM: 3.9GiB
---
Changes in v2:
- Change patch subject prefix from "common: board_f" to "cmd: mem"
- Update commit-msg
- Revert common/board_f.c modification. Instead, add codes in mem.c
--- cmd/mem.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
cmd/mem.c +15 -1
@@ -1387,8 +1387,22 @@ U_BOOT_CMD(static int do_mem_info (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { +unsigned long long size; + +#ifdef CONFIG_NR_DRAM_BANKS +int i; + +for (i = size =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { + size += gd->bd->bi_dram[i].size; +printf ("Bank #%d: %llx " , i, + (unsigned long long )(gd->bd->bi_dram[i].start)); +print_size (gd->bd->bi_dram[i].size,"\n" ); + } +#else + size = gd->ram_size; +#endif puts ("DRAM: " ); -print_size (gd->ram_size,"\n" ); +print_size (size,"\n" );return 0 ; }
Signature · 1 line
2.29.0
PATCH v2 1/1 cmd: mem: fix to display wrong memory information
Quoted 39 lines · Jaehoon Chung
When run meminfo command, it's displayed wrong memory information. Because some boards are that
gd->ram_sizeis reassigned to other value in board file.
Additionally, display a memory bank information.On 4G RPI4 target
- BeforeU-Boot> meminfo DRAM: 948MiB - After U-Boot> meminfo Bank #0: 0 948 MiB Bank #1: 40000000 2.9 GiB Bank #2: 0 0 Bytes Bank #3: 0 0 Bytes DRAM: 3.9GiBSigned-off-by Jaehoon Chung <[email protected]>---
Changes in v2:
- Change patch subject prefix from "common:board_f" to "cmd: mem"
- Update commit-msg
- Revertcommon/board_f.cmodification. Instead, add codes inmem.c--- cmd/mem.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)cmd/mem.c +4
-0@@ -1387,8 +1387,22 @@ U_BOOT_CMD(static int do_mem_info (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { +unsigned long long size; + +#ifdef CONFIG_NR_DRAM_BANKS +int i;
cmd/mem.c U_BOOT_CMD( · line 1403
Quoted 10 lines
cmd/mem.c +10
-0+ +for (i = size =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { + size += gd->bd->bi_dram[i].size; +printf ("Bank #%d: %llx " , i, + (unsigned long long )(gd->bd->bi_dram[i].start)); +print_size (gd->bd->bi_dram[i].size,"\n" ); + } +#else + size = gd->ram_size; +#endif
CONFIG_NR_DRAM_BANKS is always defined! There has been some work to all #ifdef's in this area, as it's not needed. So please don't add new #ifdef's here, as they are not needed. Please search for:
Remove CONFIG_NR_DRAM_BANKS option and bi_memstart/memsize from bd_info
If your board does not display the correct size, then you most likely have some issues in your local dram_init_banksize() or dram_init() implementation. If the total RAM cannot be used by U-Boot (which is a common issue) then please use something like board_get_usable_ram_top() and/or get_effective_memsize() for this.
Here on my 4GiB Octeon MIPS board:
...
DRAM: 256 MiB (4 GiB total)
...
=> meminfo
DRAM: 4 GiB
=> bdinfoboot_params = 0x0000000000000000
DRAM bank = 0x0000000000000000 -> start = 0xffffffff80000000 -> size = 0x0000000010000000
...
HTH.
Thanks,
Stefan
PATCH v2 1/1 cmd: mem: fix to display wrong memory information
Quoted 55 lines · Stefan Roese
Quoted 39 lines · Jaehoon Chung
When run meminfo command, it's displayed wrong memory information. Because some boards are that
gd->ram_sizeis reassigned to other value in board file.
Additionally, display a memory bank information.On 4G RPI4 target
- Before
??? U-Boot> meminfo
??? DRAM: 948MiB
- After
??? U-Boot> meminfo
??? Bank #0: 0 948 MiB
??? Bank #1: 40000000 2.9 GiB
??? Bank #2: 0 0 Bytes
??? Bank #3: 0 0 Bytes
??? DRAM: 3.9GiBSigned-off-by Jaehoon Chung <[email protected]>---
Changes in v2:
- Change patch subject prefix from "common:board_f" to "cmd: mem"
- Update commit-msg
- Revertcommon/board_f.cmodification. Instead, add codes inmem.c
---
?cmd/mem.c| 16 +++++++++++++++-
? 1 file changed, 15 insertions(+), 1 deletion(-)cmd/mem.c +4
-0@@ -1387,8 +1387,22 @@ U_BOOT_CMD( ? static int do_mem_info(struct cmd_tbl *cmdtp, int flag, int argc, ???????????????? char *const argv[]) ? { +??? unsigned long long size; + +#ifdef CONFIG_NR_DRAM_BANKS +??? int i;cmd/mem.c U_BOOT_CMD( · line 1403
Quoted 10 lines
cmd/mem.c +10
-0+ +??? for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) { +??????? size += gd->bd->bi_dram[i].size; +??????? printf("Bank #%d: %llx ", i, +????????????? (unsigned long long)(gd->bd->bi_dram[i].start)); +??????????? print_size(gd->bd->bi_dram[i].size, "\n"); +??? } +#else +??? size = gd->ram_size; +#endif
CONFIG_NR_DRAM_BANKSis always defined! There has been some work to all #ifdef's in this area, as it's not needed. So please don't add new #ifdef's here, as they are not needed. Please search for:
Quoted 7 lines
Remove
CONFIG_NR_DRAM_BANKSoption and bi_memstart/memsize frombd_infoIf your board does not display the correct size, then you most likely have some issues in your local
dram_init_banksize()ordram_init()implementation. If the total RAM cannot be used by U-Boot (which is a common issue) then please use something likeboard_get_usable_ram_top()and/orget_effective_memsize()for this.
I understood what you said. Frankly, i had tried to use memory information into my bootscript. So i have checked mmcinfo command.
Right, there is included information not to use by U-boot side.
I thought a issue what not display Total Ram information with meminfo. (Because there isn't any description about meminfo.)
But if it's displayed memory that can be used by U-boot, this patch doesn't need.
I have tested on my own targets. (RPI4 2G/4G/8G, meson target - VIM3(4G), Odroid-N2(4G))
- Those boards were displayed almost under 1G.
Thanks for comment and checking!
Best Regards,
Jaehoon Chung
Quoted 20 lines
Here on my 4GiB Octeon MIPS board:
...
DRAM:? 256 MiB (4 GiB total)
...
=> meminfo
DRAM:? 4 GiB
=> bdinfoboot_params=0x0000000000000000
DRAM bank?? =0x0000000000000000
-> start??? =0xffffffff80000000
-> size???? =0x0000000010000000
...HTH.
Thanks,
Stefan