static int cmd_test(int argc, char **argv) { int page; char fill = 'a'; if (argc < 2) { printf("usage: %s <page>\n", argv[0]); return 1; } page = getpage(argv[1]); if (page < 0) { return 1; } for (unsigned i = 0; i < sizeof(page_mem); i++) { page_mem[i] = (uint8_t)fill++; if (fill > 'z') { fill = 'a'; } } if (flashpage_write_and_verify(page, page_mem) != FLASHPAGE_OK) { printf("error verifying the content of page %i\n", page); return 1; } printf("wrote local page buffer to flash page %i at addr %p\n", page, flashpage_addr(page)); return 0; }
/** * @brief Does a write and verify test 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(int argc, char **argv) { (void) argc; (void) argv; char fill = 'a'; for (unsigned i = 0; i < sizeof(page_mem); i++) { page_mem[i] = (uint8_t)fill++; if (fill > 'z') { fill = 'a'; } } if (flashpage_write_and_verify((int)FLASHPAGE_NUMOF - 1, page_mem) != FLASHPAGE_OK) { puts("error verifying the content of last page"); return 1; } puts("wrote local page buffer to last flash page"); return 0; }
static int cmd_write(int argc, char **argv) { int page; if (argc < 2) { printf("usage: %s <page>\n", argv[0]); return 1; } page = getpage(argv[1]); if (page < 0) { return 1; } if (flashpage_write_and_verify(page, page_mem) != FLASHPAGE_OK) { printf("error: verification for page %i failed\n", page); return 1; } printf("wrote local page buffer to flash page %i at addr %p\n", page, flashpage_addr(page)); return 0; }