tools: standalone_mp3: Add read test, increase speed to 25 MHz
All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m22s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Successful in 10s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 11s

Add a read test to the SD tests in standalone_mp3, and also apply the
drive strength setup and higher clockrate from board_Rev1.py.

Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
2025-10-19 16:57:19 +02:00
parent 8e4f2fde21
commit 2809d3f6e7
2 changed files with 34 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ include(../../lib/micropython/lib/pico-sdk/pico_sdk_init.cmake)
project(standalone_mp3)
option(ENABLE_WRITE_TEST "Enable write test" OFF)
option(ENABLE_READ_TEST "Enable read test" ON)
option(ENABLE_PLAY_TEST "Enable mp3 playback test" OFF)
option(ENABLE_SD_READ_CRC "Enable crc check when reading from sd card" OFF)
option(ENABLE_SD_DEBUG "Enable debug output for sd card driver" OFF)
@@ -37,6 +38,10 @@ if(ENABLE_WRITE_TEST)
target_compile_definitions(standalone_mp3 PRIVATE WRITE_TEST)
endif()
if(ENABLE_READ_TEST)
target_compile_definitions(standalone_mp3 PRIVATE READ_TEST)
endif()
if(ENABLE_PLAY_TEST)
target_compile_definitions(standalone_mp3 PRIVATE PLAY_TEST)
endif()

View File

@@ -157,7 +157,7 @@ static void write_test(struct sd_context *sd_context)
data_buffer[i] ^= 0xff;
}
if(!sd_writeblock(sd_context, 0, data_buffer)) {
if (!sd_writeblock(sd_context, 0, data_buffer)) {
printf("sd_writeblock failed\n");
return;
}
@@ -165,6 +165,20 @@ static void write_test(struct sd_context *sd_context)
} while (data_buffer[SD_SECTOR_SIZE - 1] != 0xAA);
}
static void read_test(struct sd_context *sd_context)
{
uint8_t data_buffer[512];
const uint64_t before = time_us_64();
for (int block = 0; block < 245760; ++block) {
if (!sd_readblock(sd_context, block, data_buffer)) {
printf("sd_readblock(%d) failed\n", block);
return;
}
}
const uint64_t elapsed = time_us_64() - before;
printf("%llu ms elapsed, %f kB/s\n", elapsed / 1000LLU, 128 * 1024.f / (elapsed / 1000000.f));
}
int main()
{
stdio_init_all();
@@ -172,10 +186,23 @@ int main()
struct sd_context sd_context;
if (!sd_init(&sd_context, 3, 4, 2, 5, 15000000)) {
#define DRIVE_STRENGTH GPIO_DRIVE_STRENGTH_8MA
#define SLEW_RATE GPIO_SLEW_RATE_SLOW
gpio_set_drive_strength(2, DRIVE_STRENGTH);
gpio_set_slew_rate(2, SLEW_RATE);
gpio_set_drive_strength(3, DRIVE_STRENGTH);
gpio_set_slew_rate(3, SLEW_RATE);
if (!sd_init(&sd_context, 3, 4, 2, 5, 25000000)) {
printf("sd_init failed\n");
return 1;
}
#ifdef READ_TEST
read_test(&sd_context);
#endif
#ifdef WRITE_TEST
write_test(&sd_context);
#endif