diff --git a/litex/soc/software/bios/cmds/cmd_mem.c b/litex/soc/software/bios/cmds/cmd_mem.c index d8e165ab3..2da97e9d9 100644 --- a/litex/soc/software/bios/cmds/cmd_mem.c +++ b/litex/soc/software/bios/cmds/cmd_mem.c @@ -202,10 +202,10 @@ static void mem_speed_handler(int nb_params, char **params) unsigned int *addr; unsigned long size; bool read_only = false; - bool random_access = false; + bool random = false; if (nb_params < 1) { - printf("mem_speed [] []"); + printf("mem_speed [] []"); return; } @@ -230,13 +230,13 @@ static void mem_speed_handler(int nb_params, char **params) } if (nb_params >= 4) { - random_access = (bool) strtoul(params[3], &c, 0); + random = (bool) strtoul(params[3], &c, 0); if (*c != 0) { - printf("Incorrect random_access value"); + printf("Incorrect random value"); return; } } - memspeed(addr, size, read_only, random_access); + memspeed(addr, size, read_only, random); } define_command(mem_speed, mem_speed_handler, "Test memory speed", MEM_CMDS); diff --git a/litex/soc/software/include/base/memtest.h b/litex/soc/software/include/base/memtest.h index 30f0693c4..c0541f2f2 100644 --- a/litex/soc/software/include/base/memtest.h +++ b/litex/soc/software/include/base/memtest.h @@ -20,7 +20,7 @@ int memtest_bus(unsigned int *addr, unsigned long size); int memtest_addr(unsigned int *addr, unsigned long size, int random); int memtest_data(unsigned int *addr, unsigned long size, int random, struct memtest_config *config); -void memspeed(unsigned int *addr, unsigned long size, bool read_only, bool random_access); +void memspeed(unsigned int *addr, unsigned long size, bool read_only, bool random); int memtest(unsigned int *addr, unsigned long maxsize); #endif /* __MEMTEST_H */ diff --git a/litex/soc/software/libbase/memtest.c b/litex/soc/software/libbase/memtest.c index 34e4d830a..b728b18d2 100644 --- a/litex/soc/software/libbase/memtest.c +++ b/litex/soc/software/libbase/memtest.c @@ -252,11 +252,11 @@ int memtest_data(unsigned int *addr, unsigned long size, int random, struct memt return errors; } -void memspeed(unsigned int *addr, unsigned long size, bool read_only, bool random_access) +void memspeed(unsigned int *addr, unsigned long size, bool read_only, bool random) { volatile unsigned long *array = (unsigned long *)addr; int i; - unsigned int seed_32; + unsigned int seed_32 = 0; uint32_t start, end; unsigned long write_speed = 0; unsigned long read_speed; @@ -264,6 +264,10 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only, bool rando const unsigned int sz = sizeof(unsigned long); printf("Memspeed at %p (", addr); + if (random) + printf("Random, "); + else + printf("Sequential, "); print_size(size); printf(")...\n"); @@ -301,7 +305,7 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only, bool rando int num = size/sz; - if (random_access) { + if (random) { for (i = 0; i < size/sz; i++) { seed_32 = seed_to_data_32(seed_32, i); data = array[seed_32 % num]; diff --git a/litex/soc/software/liblitedram/sdram.c b/litex/soc/software/liblitedram/sdram.c index 1e65d9601..5fe71880b 100644 --- a/litex/soc/software/liblitedram/sdram.c +++ b/litex/soc/software/liblitedram/sdram.c @@ -1254,7 +1254,7 @@ int sdram_init(void) #endif return 0; } - memspeed((unsigned int *) MAIN_RAM_BASE, MEMTEST_DATA_SIZE, false); + memspeed((unsigned int *) MAIN_RAM_BASE, MEMTEST_DATA_SIZE, false, 0); #endif #ifdef CSR_DDRCTRL_BASE ddrctrl_init_done_write(1); diff --git a/litex/soc/software/liblitespi/spiflash.c b/litex/soc/software/liblitespi/spiflash.c index 51191c7bb..fef9f7462 100644 --- a/litex/soc/software/liblitespi/spiflash.c +++ b/litex/soc/software/liblitespi/spiflash.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -84,7 +85,7 @@ static void spiflash_master_write(uint32_t val, size_t len, size_t width, uint32 void spiflash_init(void) { - printf("Initializing %s SPI Flash...\n", SPIFLASH_MODULE_NAME); + printf("\nInitializing %s SPI Flash @0x%08lx...\n", SPIFLASH_MODULE_NAME, SPIFLASH_BASE); #ifdef SPIFLASH_MODULE_DUMMY_BITS spiflash_dummy_bits_setup(SPIFLASH_MODULE_DUMMY_BITS); @@ -107,18 +108,15 @@ void spiflash_init(void) #endif - /* Clk frequency auto-calibration. */ #ifndef SPIFLASH_SKIP_FREQ_INIT /* Clk frequency auto-calibration. */ spiflash_freq_init(); - printf("Warning: SPI Flash frequency auto-calibration skipped, using the default divisor of %d", spiflash_phy_clk_divisor_read()); +#else + printf("Warning: SPI Flash frequency auto-calibration skipped, using the default divisor of %d\n", spiflash_phy_clk_divisor_read()); #endif - printf("SPI Flash bandwidth benchmarks\n"); - printf("Sequential accesses:"); - memspeed(SPIFLASH_BASE, SPIFLASH_SIZE, 1, 0); - printf("Random accesses:"); - memspeed(SPIFLASH_BASE, SPIFLASH_SIZE, 1, 1); + memspeed((unsigned int *) SPIFLASH_BASE, SPIFLASH_SIZE/16, 1, 0); + memspeed((unsigned int *) SPIFLASH_BASE, SPIFLASH_SIZE/16, 1, 1); } #endif