[PATCH V2] cmd: mem: fix to display wrong memory information
Jaehoon Chung
jh80.chung at samsung.com
Fri Jan 29 05:24:52 CET 2021
On 1/28/21 6:33 PM, Stefan Roese wrote:
> On 28.01.21 03:35, Jaehoon Chung wrote:
>> 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
>>
>> Signed-off-by: Jaehoon Chung <jh80.chung at samsung.com>
>> ---
>> 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(-)
>>
>> diff --git a/cmd/mem.c b/cmd/mem.c
>> index 1d4f2bab2f9a..86f48a6e121a 100644
>> --- a/cmd/mem.c
>> +++ b/cmd/mem.c
>> @@ -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
>
> 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.
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
>
> Here on my 4GiB Octeon MIPS board:
>
> ...
> DRAM: 256 MiB (4 GiB total)
> ...
> => meminfo
> DRAM: 4 GiB
> => bdinfo
> boot_params = 0x0000000000000000
> DRAM bank = 0x0000000000000000
> -> start = 0xffffffff80000000
> -> size = 0x0000000010000000
> ...
>
> HTH.
>
> Thanks,
> Stefan
>
More information about the U-Boot
mailing list