From 7fbf66b1a4c2e6fd9e8b8cecc1c6338f39045731 Mon Sep 17 00:00:00 2001 From: Michal Sieron Date: Mon, 9 Jan 2023 16:29:01 +0100 Subject: [PATCH] bios/main: pretty print memory sizes Always print MAIN-RAM and optionally print SDRAM. This is caused by the fact, that SDRAM size can be bigger than RAM declared in the memory map. Signed-off-by: Michal Sieron --- litex/soc/software/bios/main.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index bdb9a926d..130e72fb1 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -131,18 +132,28 @@ __attribute__((__used__)) int main(int i, char **c) (1 << (CONFIG_BUS_ADDRESS_WIDTH - 30))); printf("\e[1mCSR\e[0m:\t\t%d-bit data\n", CONFIG_CSR_DATA_WIDTH); - printf("\e[1mROM\e[0m:\t\t%dKiB\n", ROM_SIZE/1024); - printf("\e[1mSRAM\e[0m:\t\t%dKiB\n", SRAM_SIZE/1024); + printf("\e[1mROM\e[0m:\t\t"); + print_size(ROM_SIZE); + printf("\n"); + printf("\e[1mSRAM\e[0m:\t\t"); + print_size(SRAM_SIZE); + printf("\n"); #ifdef CONFIG_L2_SIZE - printf("\e[1mL2\e[0m:\t\t%dKiB\n", CONFIG_L2_SIZE/1024); + printf("\e[1mL2\e[0m:\t\t"); + print_size(CONFIG_L2_SIZE); + printf("\n"); #endif #ifdef CSR_SPIFLASH_CORE_BASE - printf("\e[1mFLASH\e[0m:\t\t%dKiB\n", SPIFLASH_MODULE_TOTAL_SIZE/1024); + printf("\e[1mFLASH\e[0m:\t\t"); + print_size(SPIFLASH_MODULE_TOTAL_SIZE); + printf("\n"); #endif #ifdef MAIN_RAM_SIZE #ifdef CSR_SDRAM_BASE - printf("\e[1mSDRAM\e[0m:\t\t%dKiB %d-bit @ %dMT/s ", - MAIN_RAM_SIZE/1024, + uint64_t supported_memory = sdram_get_supported_memory(); + printf("\e[1mSDRAM\e[0m:\t\t"); + print_size(supported_memory); + printf(" %d-bit @ %dMT/s ", sdram_get_databits(), sdram_get_freq()/1000000); printf("(CL-%d", @@ -150,9 +161,10 @@ __attribute__((__used__)) int main(int i, char **c) if (sdram_get_cwl() != -1) printf(" CWL-%d", sdram_get_cwl()); printf(")\n"); -#else - printf("\e[1mMAIN-RAM\e[0m:\t%dKiB \n", MAIN_RAM_SIZE/1024); #endif + printf("\e[1mMAIN-RAM\e[0m:\t"); + print_size(MAIN_RAM_SIZE); + printf("\n"); #endif printf("\n"); #endif