software: Review/Cleanup #998.
- Fix compilation in sdram.c. - Fix warnings. - Move Sequential/Random mode printf to memtest. - Reduce SPI Flash test size (Testing full SPI Flash makes the boot too long, especially in random mode).
This commit is contained in:
parent
7fa49e2d0d
commit
babbcd28bc
|
@ -202,10 +202,10 @@ static void mem_speed_handler(int nb_params, char **params)
|
||||||
unsigned int *addr;
|
unsigned int *addr;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
bool read_only = false;
|
bool read_only = false;
|
||||||
bool random_access = false;
|
bool random = false;
|
||||||
|
|
||||||
if (nb_params < 1) {
|
if (nb_params < 1) {
|
||||||
printf("mem_speed <addr> <size> [<readonly>] [<random_access>]");
|
printf("mem_speed <addr> <size> [<readonly>] [<random>]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,13 +230,13 @@ static void mem_speed_handler(int nb_params, char **params)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nb_params >= 4) {
|
if (nb_params >= 4) {
|
||||||
random_access = (bool) strtoul(params[3], &c, 0);
|
random = (bool) strtoul(params[3], &c, 0);
|
||||||
if (*c != 0) {
|
if (*c != 0) {
|
||||||
printf("Incorrect random_access value");
|
printf("Incorrect random value");
|
||||||
return;
|
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);
|
define_command(mem_speed, mem_speed_handler, "Test memory speed", MEM_CMDS);
|
||||||
|
|
|
@ -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_addr(unsigned int *addr, unsigned long size, int random);
|
||||||
int memtest_data(unsigned int *addr, unsigned long size, int random, struct memtest_config *config);
|
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);
|
int memtest(unsigned int *addr, unsigned long maxsize);
|
||||||
|
|
||||||
#endif /* __MEMTEST_H */
|
#endif /* __MEMTEST_H */
|
||||||
|
|
|
@ -252,11 +252,11 @@ int memtest_data(unsigned int *addr, unsigned long size, int random, struct memt
|
||||||
return errors;
|
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;
|
volatile unsigned long *array = (unsigned long *)addr;
|
||||||
int i;
|
int i;
|
||||||
unsigned int seed_32;
|
unsigned int seed_32 = 0;
|
||||||
uint32_t start, end;
|
uint32_t start, end;
|
||||||
unsigned long write_speed = 0;
|
unsigned long write_speed = 0;
|
||||||
unsigned long read_speed;
|
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);
|
const unsigned int sz = sizeof(unsigned long);
|
||||||
|
|
||||||
printf("Memspeed at %p (", addr);
|
printf("Memspeed at %p (", addr);
|
||||||
|
if (random)
|
||||||
|
printf("Random, ");
|
||||||
|
else
|
||||||
|
printf("Sequential, ");
|
||||||
print_size(size);
|
print_size(size);
|
||||||
printf(")...\n");
|
printf(")...\n");
|
||||||
|
|
||||||
|
@ -301,7 +305,7 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only, bool rando
|
||||||
|
|
||||||
int num = size/sz;
|
int num = size/sz;
|
||||||
|
|
||||||
if (random_access) {
|
if (random) {
|
||||||
for (i = 0; i < size/sz; i++) {
|
for (i = 0; i < size/sz; i++) {
|
||||||
seed_32 = seed_to_data_32(seed_32, i);
|
seed_32 = seed_to_data_32(seed_32, i);
|
||||||
data = array[seed_32 % num];
|
data = array[seed_32 % num];
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ int sdram_init(void)
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memspeed((unsigned int *) MAIN_RAM_BASE, MEMTEST_DATA_SIZE, false);
|
memspeed((unsigned int *) MAIN_RAM_BASE, MEMTEST_DATA_SIZE, false, 0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CSR_DDRCTRL_BASE
|
#ifdef CSR_DDRCTRL_BASE
|
||||||
ddrctrl_init_done_write(1);
|
ddrctrl_init_done_write(1);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <crc.h>
|
#include <crc.h>
|
||||||
|
#include <memtest.h>
|
||||||
|
|
||||||
#include <generated/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <generated/mem.h>
|
#include <generated/mem.h>
|
||||||
|
@ -84,7 +85,7 @@ static void spiflash_master_write(uint32_t val, size_t len, size_t width, uint32
|
||||||
|
|
||||||
void spiflash_init(void)
|
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
|
#ifdef SPIFLASH_MODULE_DUMMY_BITS
|
||||||
spiflash_dummy_bits_setup(SPIFLASH_MODULE_DUMMY_BITS);
|
spiflash_dummy_bits_setup(SPIFLASH_MODULE_DUMMY_BITS);
|
||||||
|
@ -107,18 +108,15 @@ void spiflash_init(void)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Clk frequency auto-calibration. */
|
|
||||||
#ifndef SPIFLASH_SKIP_FREQ_INIT
|
#ifndef SPIFLASH_SKIP_FREQ_INIT
|
||||||
/* Clk frequency auto-calibration. */
|
/* Clk frequency auto-calibration. */
|
||||||
spiflash_freq_init();
|
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
|
#endif
|
||||||
|
|
||||||
printf("SPI Flash bandwidth benchmarks\n");
|
memspeed((unsigned int *) SPIFLASH_BASE, SPIFLASH_SIZE/16, 1, 0);
|
||||||
printf("Sequential accesses:");
|
memspeed((unsigned int *) SPIFLASH_BASE, SPIFLASH_SIZE/16, 1, 1);
|
||||||
memspeed(SPIFLASH_BASE, SPIFLASH_SIZE, 1, 0);
|
|
||||||
printf("Random accesses:");
|
|
||||||
memspeed(SPIFLASH_BASE, SPIFLASH_SIZE, 1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue