From 1d63d66a093883a6cbccc83bf5da49c25fdee5d0 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 14 Sep 2020 11:50:54 +0200 Subject: [PATCH] software/libbase/memtest: improve memtest_data progress. Add base/current tested address and current/total tested size. ex: Memtest at 0x40000000... Write: 0x40000000-0x40200000 (2/2MiB) Read: 0x40000000-0x40200000 (2/2MiB) --- litex/soc/software/libbase/memtest.c | 33 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/litex/soc/software/libbase/memtest.c b/litex/soc/software/libbase/memtest.c index 2067d5e43..60b493733 100644 --- a/litex/soc/software/libbase/memtest.c +++ b/litex/soc/software/libbase/memtest.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include @@ -12,6 +11,10 @@ // #define MEMTEST_DATA_DEBUG // #define MEMTEST_ADDR_DEBUG +#define KIB 1024 +#define MIB (KIB*1024) +#define GIB (MIB*1024) + #define ONEZERO 0xAAAAAAAA #define ZEROONE 0x55555555 @@ -118,6 +121,18 @@ int memtest_addr(unsigned int *addr, unsigned long size, int random) return errors; } +static void memtest_data_progress(const char * header, unsigned int offset, unsigned int addr, unsigned int size) +{ + if (size < KIB) + printf( "%s 0x%x-0x%x (%d/%dB)\r", header, offset, offset + addr, addr, size); + else if (size < MIB) + printf( "%s 0x%x-0x%x (%d/%dKiB)\r", header, offset, offset + addr, addr/KIB, size/KIB); + else if (size < GIB) + printf( "%s 0x%x-0x%x (%d/%dMiB)\r", header, offset, offset + addr, addr/MIB, size/MIB); + else + printf( "%s 0x%x-0x%x (%d/%dGiB)\r", header, offset, offset + addr, addr/GIB, size/GIB); +} + int memtest_data(unsigned int *addr, unsigned long size, int random) { volatile unsigned int *array = addr; @@ -128,14 +143,13 @@ 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); + memtest_data_progress("Write:", (unsigned int)addr, 4*i, size); } - show_progress(i); + memtest_data_progress("Write:", (unsigned int)addr, 4*i, size); printf("\n"); seed_32 = 1; @@ -143,7 +157,6 @@ int memtest_data(unsigned int *addr, unsigned long size, int random) #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]; @@ -154,9 +167,9 @@ int memtest_data(unsigned int *addr, unsigned long size, int random) #endif } if (i%0x8000 == 0) - show_progress(i); + memtest_data_progress("Read: ", (unsigned int)addr, 4*i, size); } - show_progress(i); + memtest_data_progress("Read: ", (unsigned int)addr, 4*i, size); printf("\n"); return errors; @@ -191,7 +204,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); + printf("Write: %ld Mbps\n", write_speed); /* flush CPU and L2 caches */ flush_cpu_dcache(); @@ -209,9 +222,7 @@ 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("Read: %ld Mbps\n", read_speed); } int memtest(unsigned int *addr, unsigned long maxsize)