From: Florent Kermarrec Date: Thu, 25 Jun 2020 07:57:29 +0000 (+0200) Subject: software/libase/memtest: improve printfs and add progress bar on data test. X-Git-Tag: 24jan2021_ls180~143 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=55e019370178b51b809d79269e70698531bcbe3d;p=litex.git software/libase/memtest: improve printfs and add progress bar on data test. --- diff --git a/litex/soc/software/libbase/memtest.c b/litex/soc/software/libbase/memtest.c index 4ab7f48f..80f5cf46 100644 --- a/litex/soc/software/libbase/memtest.c +++ b/litex/soc/software/libbase/memtest.c @@ -2,8 +2,9 @@ #include #include - #include +#include + #include #include @@ -127,16 +128,22 @@ int memtest_data(unsigned int *addr, unsigned long size, int random) errors = 0; seed_32 = 1; + init_progression_bar(size/4); for(i = 0; i < size/4; i++) { seed_32 = seed_to_data_32(seed_32, random); array[i] = seed_32; + if (i%0x8000 == 0) + show_progress(i); } + show_progress(i); + printf("\n"); seed_32 = 1; flush_cpu_dcache(); #ifdef CONFIG_L2_SIZE flush_l2_cache(); #endif + init_progression_bar(size/4); for(i = 0; i < size/4; i++) { seed_32 = seed_to_data_32(seed_32, random); rdata = array[i]; @@ -146,7 +153,11 @@ int memtest_data(unsigned int *addr, unsigned long size, int random) printf("[data 0x%0x]: 0x%08x vs 0x%08x\n", i, rdata, seed_32); #endif } + if (i%0x8000 == 0) + show_progress(i); } + show_progress(i); + printf("\n"); return errors; } @@ -161,6 +172,8 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only) __attribute__((unused)) unsigned long data; const unsigned int sz = sizeof(unsigned long); + printf("Memspeed at 0x%08x...\n", addr); + /* init timer */ timer0_en_write(0); timer0_reload_write(0); @@ -178,6 +191,7 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only) end = timer0_value_read(); write_speed = (8*size*(CONFIG_CLOCK_FREQUENCY/1000000))/(start - end); } + printf("Writes: %ld Mbps\n", write_speed); /* flush CPU and L2 caches */ flush_cpu_dcache(); @@ -195,8 +209,9 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only) timer0_update_value_write(1); end = timer0_value_read(); read_speed = (8*size*(CONFIG_CLOCK_FREQUENCY/1000000))/(start - end); + printf("Reads: %ld Mbps\n", read_speed); + - printf("Memspeed Writes: %ldMbps Reads: %ldMbps\n", write_speed, read_speed); } int memtest(unsigned int *addr, unsigned long maxsize) @@ -206,20 +221,19 @@ int memtest(unsigned int *addr, unsigned long maxsize) unsigned long addr_size = MEMTEST_ADDR_SIZE < maxsize ? MEMTEST_ADDR_SIZE : maxsize; unsigned long data_size = MEMTEST_DATA_SIZE < maxsize ? MEMTEST_DATA_SIZE : maxsize; - bus_errors = memtest_bus(addr, bus_size); - if(bus_errors != 0) - printf("Memtest bus failed: %d/%d errors\n", bus_errors, bus_size/4); + printf("Memtest at 0x%08x...\n", addr); + bus_errors = memtest_bus(addr, bus_size); addr_errors = memtest_addr(addr, addr_size, MEMTEST_ADDR_RANDOM); - if(addr_errors != 0) - printf("Memtest addr failed: %d/%d errors\n", addr_errors, addr_size/4); - data_errors = memtest_data(addr, data_size, MEMTEST_DATA_RANDOM); - if(data_errors != 0) - printf("Memtest data failed: %d/%d errors\n", data_errors, data_size/4); - if(bus_errors + addr_errors + data_errors != 0) + if(bus_errors + addr_errors + data_errors != 0) { + printf("- bus errors: %d/%d\n", bus_errors, bus_size/4); + printf("- addr errors: %d/%d\n", addr_errors, addr_size/4); + printf("- data errors: %d/%d\n", data_errors, data_size/4); + printf("Memtest KO\n"); return 0; + } else { printf("Memtest OK\n"); memspeed(addr, data_size, false); diff --git a/litex/soc/software/liblitedram/sdram.c b/litex/soc/software/liblitedram/sdram.c index 933c71a4..0970a4c9 100644 --- a/litex/soc/software/liblitedram/sdram.c +++ b/litex/soc/software/liblitedram/sdram.c @@ -9,6 +9,7 @@ // License: BSD #include +#include #include #include @@ -787,7 +788,7 @@ int sdrlevel(void) int sdrinit(void) { - printf("Initializing SDRAM...\n"); + printf("Initializing DRAM @0x%08x...\n", MAIN_RAM_BASE); #ifdef CSR_DDRCTRL_BASE ddrctrl_init_done_write(0);