Merge branch 'ci/add_flash_performance_info' into 'master'

ci: Add more information for flash performance test

Closes IDF-2739

See merge request espressif/esp-idf!12912
This commit is contained in:
Michael (XIAO Xufeng)
2021-04-26 06:22:12 +00:00
2 changed files with 59 additions and 15 deletions

View File

@@ -157,6 +157,15 @@ typedef void (*flash_test_func_t)(const esp_partition_t *part);
#endif // !CONFIG_IDF_TARGET_ESP32C3
#endif //CONFIG_SPIRAM
#if SOC_CCOMP_TIMER_SUPPORTED
#define TEST_FLASH_PERFORMANCE_CCOMP_GREATER_THAN(name, value, chip) \
printf("[Performance][" PERFORMANCE_STR(name) "]: %d, flash_chip: %s\n", value, chip);\
_TEST_PERFORMANCE_ASSERT(value > PERFORMANCE_CON(IDF_PERFORMANCE_MIN_, name));
#else
#define TEST_FLASH_PERFORMANCE_CCOMP_GREATER_THAN(name, value, chip) \
printf("[Performance][" PERFORMANCE_STR(name) "]: %d, flash_chip: %s\n", value, chip);
#endif //SOC_CCOMP_TIMER_SUPPORTED
//currently all the configs are the same with esp_flash_spi_device_config_t, no more information required
typedef esp_flash_spi_device_config_t flashtest_config_t;
@@ -1048,6 +1057,37 @@ static uint32_t measure_read(const char* name, const esp_partition_t* part, uint
return time_measure_end(&time_ctx);
}
static const char* get_chip_vendor(uint32_t id)
{
switch (id)
{
case 0x20:
return "XMC";
break;
case 0x68:
return "BOYA";
break;
case 0xC8:
return "GigaDevice";
break;
case 0x9D:
return "ISSI";
break;
case 0xC2:
return "MXIC";
break;
case 0xEF:
return "Winbond";
break;
case 0xA1:
return "Fudan Micro";
break;
default:
break;
}
return "generic";
}
#define MEAS_WRITE(n) (measure_write("write in "#n"-byte chunks", part, data_to_write, n))
#define MEAS_READ(n) (measure_read("read in "#n"-byte chunks", part, data_read, n))
@@ -1073,36 +1113,39 @@ static void test_flash_read_write_performance(const esp_partition_t *part)
TEST_ASSERT_EQUAL_HEX8_ARRAY(data_to_write, data_read, total_len);
#if !CONFIG_SPIRAM && !CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE
# define CHECK_DATA(bus, suffix) TEST_PERFORMANCE_CCOMP_GREATER_THAN(FLASH_SPEED_BYTE_PER_SEC_##bus##suffix, "%d", speed_##suffix)
# define CHECK_ERASE(bus, var) TEST_PERFORMANCE_CCOMP_GREATER_THAN(FLASH_SPEED_BYTE_PER_SEC_##bus##ERASE, "%d", var)
# define CHECK_DATA(bus, suffix, chip) TEST_FLASH_PERFORMANCE_CCOMP_GREATER_THAN(FLASH_SPEED_BYTE_PER_SEC_##bus##suffix, speed_##suffix, chip)
# define CHECK_ERASE(bus, var, chip) TEST_FLASH_PERFORMANCE_CCOMP_GREATER_THAN(FLASH_SPEED_BYTE_PER_SEC_##bus##ERASE, var, chip)
#else
# define CHECK_DATA(bus, suffix) ((void)speed_##suffix)
# define CHECK_ERASE(bus, var) ((void)var)
# define CHECK_DATA(bus, suffix, chip) ((void)speed_##suffix);((void)chip)
# define CHECK_ERASE(bus, var, chip) ((void)var);((void)chip)
#endif
// Erase time may vary a lot, can increase threshold if this fails with a reasonable speed
#define CHECK_PERFORMANCE(bus) do {\
CHECK_DATA(bus, WR_4B); \
CHECK_DATA(bus, RD_4B); \
CHECK_DATA(bus, WR_2KB); \
CHECK_DATA(bus, RD_2KB); \
CHECK_ERASE(bus, erase_1); \
CHECK_ERASE(bus, erase_2); \
#define CHECK_PERFORMANCE(bus, chip) do {\
CHECK_DATA(bus, WR_4B, chip); \
CHECK_DATA(bus, RD_4B, chip); \
CHECK_DATA(bus, WR_2KB, chip); \
CHECK_DATA(bus, RD_2KB, chip); \
CHECK_ERASE(bus, erase_1, chip); \
CHECK_ERASE(bus, erase_2, chip); \
} while (0)
spi_host_device_t host_id;
int cs_id;
uint32_t id;
esp_flash_read_id(chip, &id);
const char *chip_name = get_chip_vendor(id >> 16);
get_chip_host(chip, &host_id, &cs_id);
if (host_id != SPI1_HOST) {
// Chips on other SPI buses
CHECK_PERFORMANCE(EXT_);
CHECK_PERFORMANCE(EXT_, chip_name);
} else if (cs_id == 0) {
// Main flash
CHECK_PERFORMANCE();
CHECK_PERFORMANCE(,chip_name);
} else {
// Other cs pins on SPI1
CHECK_PERFORMANCE(SPI1_);
CHECK_PERFORMANCE(SPI1_, chip_name);
}
free(data_to_write);
free(data_read);

View File

@@ -32,6 +32,7 @@ except ImportError:
from serial.tools import list_ports
from tiny_test_fw import DUT, Utility
from tiny_test_fw.Utility import format_case_id
try:
import esptool
@@ -70,7 +71,7 @@ class IDFRecvThread(DUT.RecvThread):
def collect_performance(self, comp_data):
matches = self.PERFORMANCE_PATTERN.findall(comp_data)
for match in matches:
Utility.console_log('[Performance][{}]: {}'.format(match[0], match[1]),
Utility.console_log('[Performance][{}]: {}'.format(format_case_id(match[0], self.dut.app.target, self.dut.app.config_name), match[1]),
color='orange')
self.performance_items.put((match[0], match[1]))