From b4f2c1a62a37f851d006151b91d6464bc3287699 Mon Sep 17 00:00:00 2001 From: Federico Pellegrin Date: Wed, 3 Oct 2018 08:16:15 +0200 Subject: [PATCH] tests/periph_flashpage: short raw write test if hardware supports it --- tests/periph_flashpage/main.c | 26 ++++++++++++++++++++++++++ tests/periph_flashpage/tests/01-run.py | 10 ++++++++++ 2 files changed, 36 insertions(+) diff --git a/tests/periph_flashpage/main.c b/tests/periph_flashpage/main.c index e74e66d77a..d517625c58 100644 --- a/tests/periph_flashpage/main.c +++ b/tests/periph_flashpage/main.c @@ -319,6 +319,29 @@ static int cmd_test_last(int argc, char **argv) return 0; } +#ifdef MODULE_PERIPH_FLASHPAGE_RAW +/** + * @brief Does a short raw write on last page available + * + * @note Since every hardware can have different flash layouts for + * automated testing we always write to the last page available + * so we are independent of the size or layout + */ +static int cmd_test_last_raw(int argc, char **argv) +{ + (void) argc; + (void) argv; + + /* try to align */ + memcpy(raw_buf, "test12344321tset", 16); + + flashpage_write_raw((void*) ((int)CPU_FLASH_BASE + (int)FLASHPAGE_SIZE * ((int)FLASHPAGE_NUMOF - 2)), raw_buf, strlen(raw_buf)); + + puts("wrote raw short buffer to last flash page"); + return 0; +} +#endif + static const shell_command_t shell_commands[] = { { "info", "Show information about pages", cmd_info }, { "dump", "Dump the selected page to STDOUT", cmd_dump }, @@ -332,6 +355,9 @@ static const shell_command_t shell_commands[] = { { "edit", "Write bytes to the local page buffer", cmd_edit }, { "test", "Write and verify test pattern", cmd_test }, { "test_last", "Write and verify test pattern on last page available", cmd_test_last }, +#ifdef MODULE_PERIPH_FLASHPAGE_RAW + { "test_last_raw", "Write and verify raw short write on last page available", cmd_test_last_raw }, +#endif { NULL, NULL, NULL } }; diff --git a/tests/periph_flashpage/tests/01-run.py b/tests/periph_flashpage/tests/01-run.py index 226c7011d6..34327efe3c 100755 --- a/tests/periph_flashpage/tests/01-run.py +++ b/tests/periph_flashpage/tests/01-run.py @@ -14,6 +14,16 @@ def testfunc(child): # writes and verifies the last page of the flash child.sendline("test_last") child.expect_exact('wrote local page buffer to last flash page') + child.expect('>') + + # check if board has raw write capability and if so test that as well + # capability is deduced from help contents + child.sendline("help") + index = child.expect(['test_last_raw', '>']) + if index == 0: + child.sendline("test_last_raw") + child.expect_exact('wrote raw short buffer to last flash page') + child.expect('>') if __name__ == "__main__":