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:
Florent Kermarrec 2021-08-23 17:59:11 +02:00
parent 7fa49e2d0d
commit babbcd28bc
5 changed files with 20 additions and 18 deletions

View File

@ -202,10 +202,10 @@ static void mem_speed_handler(int nb_params, char **params)
unsigned int *addr;
unsigned long size;
bool read_only = false;
bool random_access = false;
bool random = false;
if (nb_params < 1) {
printf("mem_speed <addr> <size> [<readonly>] [<random_access>]");
printf("mem_speed <addr> <size> [<readonly>] [<random>]");
return;
}
@ -230,13 +230,13 @@ static void mem_speed_handler(int nb_params, char **params)
}
if (nb_params >= 4) {
random_access = (bool) strtoul(params[3], &c, 0);
random = (bool) strtoul(params[3], &c, 0);
if (*c != 0) {
printf("Incorrect random_access value");
printf("Incorrect random value");
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);

View File

@ -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_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);
#endif /* __MEMTEST_H */

View File

@ -252,11 +252,11 @@ int memtest_data(unsigned int *addr, unsigned long size, int random, struct memt
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;
int i;
unsigned int seed_32;
unsigned int seed_32 = 0;
uint32_t start, end;
unsigned long write_speed = 0;
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);
printf("Memspeed at %p (", addr);
if (random)
printf("Random, ");
else
printf("Sequential, ");
print_size(size);
printf(")...\n");
@ -301,7 +305,7 @@ void memspeed(unsigned int *addr, unsigned long size, bool read_only, bool rando
int num = size/sz;
if (random_access) {
if (random) {
for (i = 0; i < size/sz; i++) {
seed_32 = seed_to_data_32(seed_32, i);
data = array[seed_32 % num];

View File

@ -1254,7 +1254,7 @@ int sdram_init(void)
#endif
return 0;
}
memspeed((unsigned int *) MAIN_RAM_BASE, MEMTEST_DATA_SIZE, false);
memspeed((unsigned int *) MAIN_RAM_BASE, MEMTEST_DATA_SIZE, false, 0);
#endif
#ifdef CSR_DDRCTRL_BASE
ddrctrl_init_done_write(1);

View File

@ -5,6 +5,7 @@
#include <stdlib.h>
#include <string.h>
#include <crc.h>
#include <memtest.h>
#include <generated/csr.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)
{
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
spiflash_dummy_bits_setup(SPIFLASH_MODULE_DUMMY_BITS);
@ -107,18 +108,15 @@ void spiflash_init(void)
#endif
/* Clk frequency auto-calibration. */
#ifndef SPIFLASH_SKIP_FREQ_INIT
/* Clk frequency auto-calibration. */
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
printf("SPI Flash bandwidth benchmarks\n");
printf("Sequential accesses:");
memspeed(SPIFLASH_BASE, SPIFLASH_SIZE, 1, 0);
printf("Random accesses:");
memspeed(SPIFLASH_BASE, SPIFLASH_SIZE, 1, 1);
memspeed((unsigned int *) SPIFLASH_BASE, SPIFLASH_SIZE/16, 1, 0);
memspeed((unsigned int *) SPIFLASH_BASE, SPIFLASH_SIZE/16, 1, 1);
}
#endif