software/libase/memtest: improve printfs and add progress bar on data test.
This commit is contained in:
parent
497413664e
commit
55e0193701
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
#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>
|
||||||
|
|
||||||
|
@ -127,16 +128,22 @@ 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)
|
||||||
|
show_progress(i);
|
||||||
}
|
}
|
||||||
|
show_progress(i);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
seed_32 = 1;
|
seed_32 = 1;
|
||||||
flush_cpu_dcache();
|
flush_cpu_dcache();
|
||||||
#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];
|
||||||
|
@ -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);
|
printf("[data 0x%0x]: 0x%08x vs 0x%08x\n", i, rdata, seed_32);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if (i%0x8000 == 0)
|
||||||
|
show_progress(i);
|
||||||
}
|
}
|
||||||
|
show_progress(i);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
@ -161,6 +172,8 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only)
|
||||||
__attribute__((unused)) unsigned long data;
|
__attribute__((unused)) unsigned long data;
|
||||||
const unsigned int sz = sizeof(unsigned long);
|
const unsigned int sz = sizeof(unsigned long);
|
||||||
|
|
||||||
|
printf("Memspeed at 0x%08x...\n", addr);
|
||||||
|
|
||||||
/* init timer */
|
/* init timer */
|
||||||
timer0_en_write(0);
|
timer0_en_write(0);
|
||||||
timer0_reload_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();
|
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);
|
||||||
|
|
||||||
/* flush CPU and L2 caches */
|
/* flush CPU and L2 caches */
|
||||||
flush_cpu_dcache();
|
flush_cpu_dcache();
|
||||||
|
@ -195,8 +209,9 @@ 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("Memspeed Writes: %ldMbps Reads: %ldMbps\n", write_speed, read_speed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int memtest(unsigned int *addr, unsigned long maxsize)
|
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 addr_size = MEMTEST_ADDR_SIZE < maxsize ? MEMTEST_ADDR_SIZE : maxsize;
|
||||||
unsigned long data_size = MEMTEST_DATA_SIZE < maxsize ? MEMTEST_DATA_SIZE : maxsize;
|
unsigned long data_size = MEMTEST_DATA_SIZE < maxsize ? MEMTEST_DATA_SIZE : maxsize;
|
||||||
|
|
||||||
|
printf("Memtest at 0x%08x...\n", addr);
|
||||||
|
|
||||||
bus_errors = memtest_bus(addr, bus_size);
|
bus_errors = memtest_bus(addr, bus_size);
|
||||||
if(bus_errors != 0)
|
|
||||||
printf("Memtest bus failed: %d/%d errors\n", bus_errors, bus_size/4);
|
|
||||||
|
|
||||||
addr_errors = memtest_addr(addr, addr_size, MEMTEST_ADDR_RANDOM);
|
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);
|
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;
|
return 0;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
printf("Memtest OK\n");
|
printf("Memtest OK\n");
|
||||||
memspeed(addr, data_size, false);
|
memspeed(addr, data_size, false);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// License: BSD
|
// License: BSD
|
||||||
|
|
||||||
#include <generated/csr.h>
|
#include <generated/csr.h>
|
||||||
|
#include <generated/mem.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -787,7 +788,7 @@ int sdrlevel(void)
|
||||||
|
|
||||||
int sdrinit(void)
|
int sdrinit(void)
|
||||||
{
|
{
|
||||||
printf("Initializing SDRAM...\n");
|
printf("Initializing DRAM @0x%08x...\n", MAIN_RAM_BASE);
|
||||||
|
|
||||||
#ifdef CSR_DDRCTRL_BASE
|
#ifdef CSR_DDRCTRL_BASE
|
||||||
ddrctrl_init_done_write(0);
|
ddrctrl_init_done_write(0);
|
||||||
|
|
Loading…
Reference in New Issue