Lines Matching full:sh
47 static int parse_helper(const struct shell *sh, size_t *argc, in parse_helper() argument
59 shell_error(sh, "Given flash device was not found"); in parse_helper()
65 shell_error(sh, "Default flash driver not ready"); in parse_helper()
71 shell_error(sh, "No flash device specified (required)"); in parse_helper()
79 shell_error(sh, "Missing address."); in parse_helper()
88 static int cmd_erase(const struct shell *sh, size_t argc, char *argv[]) in cmd_erase() argument
97 result = parse_helper(sh, &argc, &argv, &flash_dev, &page_addr); in cmd_erase()
110 shell_error(sh, "Could not determine page size, " in cmd_erase()
121 shell_error(sh, "Erase Failed, code %d.", result); in cmd_erase()
123 shell_print(sh, "Erase success."); in cmd_erase()
130 static int cmd_write(const struct shell *sh, size_t argc, char *argv[]) in cmd_write() argument
139 ret = parse_helper(sh, &argc, &argv, &flash_dev, &w_addr); in cmd_write()
145 shell_error(sh, "Missing data to be written."); in cmd_write()
161 shell_error(sh, "Write internal ERROR!"); in cmd_write()
165 shell_print(sh, "Write OK."); in cmd_write()
168 shell_print(sh, "Verification read ERROR!"); in cmd_write()
173 shell_print(sh, "Verified."); in cmd_write()
175 shell_error(sh, "Verification ERROR!"); in cmd_write()
182 static int cmd_copy(const struct shell *sh, size_t argc, char *argv[]) in cmd_copy() argument
192 shell_error(sh, "missing parameters"); in cmd_copy()
206 shell_error(sh, "%s failed: %d", "flash_copy()", ret); in cmd_copy()
210 shell_print(sh, "Copied %u bytes from %s:%x to %s:%x", size, argv[1], src_offset, argv[2], in cmd_copy()
216 static int cmd_read(const struct shell *sh, size_t argc, char *argv[]) in cmd_read() argument
225 ret = parse_helper(sh, &argc, &argv, &flash_dev, &addr); in cmd_read()
242 shell_error(sh, "Read ERROR!"); in cmd_read()
245 shell_hexdump_line(sh, addr, data, todo); in cmd_read()
249 shell_print(sh, ""); in cmd_read()
254 static int cmd_test(const struct shell *sh, size_t argc, char *argv[]) in cmd_test() argument
264 result = parse_helper(sh, &argc, &argv, &flash_dev, &addr); in cmd_test()
272 shell_error(sh, "<size> must be at most 0x%x.", in cmd_test()
291 shell_error(sh, "Erase Failed, code %d.", result); in cmd_test()
295 shell_print(sh, "Erase OK."); in cmd_test()
300 shell_error(sh, "Write failed, code %d", result); in cmd_test()
304 shell_print(sh, "Write OK."); in cmd_test()
309 shell_print(sh, "Verification read failed, code: %d", result); in cmd_test()
314 shell_error(sh, "Verification ERROR!"); in cmd_test()
318 shell_print(sh, "Verified OK."); in cmd_test()
322 shell_print(sh, "Erase-Write-Verify test done."); in cmd_test()
332 static int read_write_erase_validate(const struct shell *sh, size_t argc, char *argv[], in read_write_erase_validate() argument
336 shell_error(sh, "Missing parameters: <device> <offset> <size> <repeat>"); in read_write_erase_validate()
344 shell_error(sh, "<size> must be between 0x1 and 0x%x.", in read_write_erase_validate()
350 shell_error(sh, "<repeat> must be between 1 and 10."); in read_write_erase_validate()
357 static void speed_output(const struct shell *sh, uint64_t total_time, double loops, double size) in speed_output() argument
372 shell_print(sh, "Total: %llums, Per loop: ~%.0fms, Speed: ~%.1f%sps", in speed_output()
376 static int cmd_read_test(const struct shell *sh, size_t argc, char *argv[]) in cmd_read_test() argument
389 result = parse_helper(sh, &argc, &argv, &flash_dev, &addr); in cmd_read_test()
394 result = read_write_erase_validate(sh, argc, argv, &size, &repeat); in cmd_read_test()
405 shell_error(sh, "Read failed: %d", result); in cmd_read_test()
411 shell_print(sh, "Loop #%u done in %llums.", loops, loop_time); in cmd_read_test()
415 speed_output(sh, total_time, (double)loops, (double)size); in cmd_read_test()
421 static int cmd_write_test(const struct shell *sh, size_t argc, char *argv[]) in cmd_write_test() argument
433 result = parse_helper(sh, &argc, &argv, &flash_dev, &addr); in cmd_write_test()
438 result = read_write_erase_validate(sh, argc, argv, &size, &repeat); in cmd_write_test()
453 shell_error(sh, "Write failed: %d", result); in cmd_write_test()
459 shell_print(sh, "Loop #%u done in %llu ticks.", loops, loop_time); in cmd_write_test()
463 speed_output(sh, total_time, (double)loops, (double)size); in cmd_write_test()
469 static int cmd_erase_test(const struct shell *sh, size_t argc, char *argv[]) in cmd_erase_test() argument
481 result = parse_helper(sh, &argc, &argv, &flash_dev, &addr); in cmd_erase_test()
486 result = read_write_erase_validate(sh, argc, argv, &size, &repeat); in cmd_erase_test()
501 shell_error(sh, "Erase failed: %d", result); in cmd_erase_test()
507 shell_print(sh, "Loop #%u done in %llums.", loops, loop_time); in cmd_erase_test()
511 speed_output(sh, total_time, (double)loops, (double)size); in cmd_erase_test()
517 static int cmd_erase_write_test(const struct shell *sh, size_t argc, char *argv[]) in cmd_erase_write_test() argument
530 result_erase = parse_helper(sh, &argc, &argv, &flash_dev, &addr); in cmd_erase_write_test()
535 result_erase = read_write_erase_validate(sh, argc, argv, &size, &repeat); in cmd_erase_write_test()
551 shell_error(sh, "Erase failed: %d", result_erase); in cmd_erase_write_test()
556 shell_error(sh, "Write failed: %d", result_write); in cmd_erase_write_test()
562 shell_print(sh, "Loop #%u done in %llums.", loops, loop_time); in cmd_erase_write_test()
566 speed_output(sh, total_time, (double)loops, (double)size); in cmd_erase_write_test()
573 static int set_bypass(const struct shell *sh, shell_bypass_cb_t bypass) in set_bypass() argument
578 shell_error(sh, "flash load supports setting bypass on a single instance."); in set_bypass()
587 shell_print(sh, "Loading..."); in set_bypass()
590 shell_set_bypass(sh, bypass); in set_bypass()
595 static void bypass_cb(const struct shell *sh, uint8_t *recv, size_t len) in bypass_cb() argument
617 shell_error(sh, "Write to addr %x on dev %p ERROR!", in bypass_cb()
621 shell_print(sh, "Written chunk %d", flash_load_chunk); in bypass_cb()
639 set_bypass(sh, NULL); in bypass_cb()
640 shell_error(sh, "Write to addr %x on dev %p ERROR!", in bypass_cb()
645 shell_print(sh, "Written chunk %d", flash_load_chunk); in bypass_cb()
651 set_bypass(sh, NULL); in bypass_cb()
652 shell_print(sh, "Read all"); in bypass_cb()
656 static int cmd_load(const struct shell *sh, size_t argc, char *argv[]) in cmd_load() argument
664 result = parse_helper(sh, &argc, &argv, &flash_dev, &addr); in cmd_load()
675 shell_error(sh, "Size must be %zu bytes aligned", write_block_size); in cmd_load()
683 shell_error(sh, "Size of buffer is too small to be aligned to %zu.", in cmd_load()
692 shell_warn(sh, "Load buffer was not aligned to %zu.", write_block_size); in cmd_load()
693 shell_warn(sh, "Effective load buffer size was set from %d to %d", in cmd_load()
705 shell_print(sh, "Send %d bytes to complete flash load command", size); in cmd_load()
707 set_bypass(sh, bypass_cb); in cmd_load()
711 static int cmd_page_info(const struct shell *sh, size_t argc, char *argv[]) in cmd_page_info() argument
718 result = parse_helper(sh, &argc, &argv, &flash_dev, &addr); in cmd_page_info()
726 shell_error(sh, "Could not determine page size, error code %d.", result); in cmd_page_info()
730 shell_print(sh, "Page for address 0x%x:\nstart offset: 0x%lx\nsize: %zu\nindex: %d", in cmd_page_info()
790 static int cmd_flash(const struct shell *sh, size_t argc, char **argv) in cmd_flash() argument
792 shell_error(sh, "%s:unknown parameter: %s", argv[0], argv[1]); in cmd_flash()