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)
This commit is contained in:
Florent Kermarrec 2020-09-14 11:50:54 +02:00
parent c169494793
commit 1d63d66a09
1 changed files with 22 additions and 11 deletions

View File

@ -3,7 +3,6 @@
#include <stdio.h> #include <stdio.h>
#include <lfsr.h> #include <lfsr.h>
#include <system.h> #include <system.h>
#include <progress.h>
#include <generated/soc.h> #include <generated/soc.h>
#include <generated/csr.h> #include <generated/csr.h>
@ -12,6 +11,10 @@
// #define MEMTEST_DATA_DEBUG // #define MEMTEST_DATA_DEBUG
// #define MEMTEST_ADDR_DEBUG // #define MEMTEST_ADDR_DEBUG
#define KIB 1024
#define MIB (KIB*1024)
#define GIB (MIB*1024)
#define ONEZERO 0xAAAAAAAA #define ONEZERO 0xAAAAAAAA
#define ZEROONE 0x55555555 #define ZEROONE 0x55555555
@ -118,6 +121,18 @@ int memtest_addr(unsigned int *addr, unsigned long size, int random)
return errors; 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) int memtest_data(unsigned int *addr, unsigned long size, int random)
{ {
volatile unsigned int *array = addr; volatile unsigned int *array = addr;
@ -128,14 +143,13 @@ int memtest_data(unsigned int *addr, unsigned long size, int random)
errors = 0; errors = 0;
seed_32 = 1; seed_32 = 1;
init_progression_bar(size/4);
for(i = 0; i < size/4; i++) { for(i = 0; i < size/4; i++) {
seed_32 = seed_to_data_32(seed_32, random); seed_32 = seed_to_data_32(seed_32, random);
array[i] = seed_32; array[i] = seed_32;
if (i%0x8000 == 0) 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"); printf("\n");
seed_32 = 1; seed_32 = 1;
@ -143,7 +157,6 @@ int memtest_data(unsigned int *addr, unsigned long size, int random)
#ifdef CONFIG_L2_SIZE #ifdef CONFIG_L2_SIZE
flush_l2_cache(); flush_l2_cache();
#endif #endif
init_progression_bar(size/4);
for(i = 0; i < size/4; i++) { for(i = 0; i < size/4; i++) {
seed_32 = seed_to_data_32(seed_32, random); seed_32 = seed_to_data_32(seed_32, random);
rdata = array[i]; rdata = array[i];
@ -154,9 +167,9 @@ int memtest_data(unsigned int *addr, unsigned long size, int random)
#endif #endif
} }
if (i%0x8000 == 0) 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"); printf("\n");
return errors; return errors;
@ -191,7 +204,7 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only)
end = timer0_value_read(); end = timer0_value_read();
write_speed = (8*size*(CONFIG_CLOCK_FREQUENCY/1000000))/(start - end); 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 and L2 caches */
flush_cpu_dcache(); flush_cpu_dcache();
@ -209,9 +222,7 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only)
timer0_update_value_write(1); timer0_update_value_write(1);
end = timer0_value_read(); end = timer0_value_read();
read_speed = (8*size*(CONFIG_CLOCK_FREQUENCY/1000000))/(start - end); 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) int memtest(unsigned int *addr, unsigned long maxsize)