From 1aa6c5089ce14d219288735691277973e8ddeb25 Mon Sep 17 00:00:00 2001 From: danpetry Date: Fri, 12 Apr 2019 18:05:56 +0200 Subject: [PATCH 1/2] drivers/sdcard_spi: Reduce "wait for not busy" For the SAMR21-xpro, I found the counter that this variable initializes counts down at a rate of about 300 counts per second. Also, that typical wait times for an SD card are ~500ms max. 2000 counts should be plenty for any application. The previous count of 1 million was effectively blocking. --- drivers/sdcard_spi/include/sdcard_spi_internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/sdcard_spi/include/sdcard_spi_internal.h b/drivers/sdcard_spi/include/sdcard_spi_internal.h index dfc428891c8b..55d5e7fa818b 100644 --- a/drivers/sdcard_spi/include/sdcard_spi_internal.h +++ b/drivers/sdcard_spi/include/sdcard_spi_internal.h @@ -132,9 +132,9 @@ extern "C" { #define SD_DATA_TOKEN_RETRY_CNT 1000000 #define INIT_CMD_RETRY_CNT 1000000 #define INIT_CMD0_RETRY_CNT 3 -#define SD_WAIT_FOR_NOT_BUSY_CNT 1000000 /* use -1 for full blocking till the card isn't busy */ -#define SD_BLOCK_READ_CMD_RETRIES 10 /* only affects sending of cmd not whole transaction! */ -#define SD_BLOCK_WRITE_CMD_RETRIES 10 /* only affects sending of cmd not whole transaction! */ +#define SD_WAIT_FOR_NOT_BUSY_CNT 2000 /* use -1 for full blocking till the card isn't busy */ +#define SD_BLOCK_READ_CMD_RETRIES 10 /* only affects sending of cmd not whole transaction! */ +#define SD_BLOCK_WRITE_CMD_RETRIES 10 /* only affects sending of cmd not whole transaction! */ /* memory capacity in bytes = (C_SIZE+1) * SD_CSD_V2_C_SIZE_BLOCK_MULT * BLOCK_LEN */ #define SD_CSD_V2_C_SIZE_BLOCK_MULT 1024 From 8041727745ca1f0c8b183d9e389a95dc1469bdb2 Mon Sep 17 00:00:00 2001 From: danpetry Date: Fri, 12 Apr 2019 18:06:34 +0200 Subject: [PATCH 2/2] tests/pkg_fatfs_vfs: remove exception on failure Tests should return some error message upon failure rather than throwing an exception, because an exception can be an indication of an error in the test script. --- tests/pkg_fatfs_vfs/tests/01-run.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/tests/pkg_fatfs_vfs/tests/01-run.py b/tests/pkg_fatfs_vfs/tests/01-run.py index 091d5730efcc..ec70f573c145 100755 --- a/tests/pkg_fatfs_vfs/tests/01-run.py +++ b/tests/pkg_fatfs_vfs/tests/01-run.py @@ -9,26 +9,15 @@ import sys from testrunner import run - -class TestFailed(Exception): - pass - - def testfunc(child): child.expect(u"Tests for FatFs over VFS - test results will be printed in " "the format test_name:result\r\n") - while True: - res = child.expect([u"[^\n]*:\[OK\]\r\n", - u"Test end.\r\n", - u".[^\n]*:\[FAILED\]\r\n", - u".*\r\n"]) - if res > 1: - raise TestFailed(child.after.split(':', 1)[0] + " test failed!") - elif res == 1: - break - + child.expect([u"[^\n]*:\[OK\]\r\n", + u"Test end.\r\n", + u".[^\n]*:\[FAILED\]\r\n", + u".*\r\n"]) if __name__ == "__main__": sys.exit(run(testfunc))