From ea3ca125bbcde2fbd7836a70132f08a3ffbf4072 Mon Sep 17 00:00:00 2001 From: Jan Van Winkel Date: Mon, 7 Jan 2019 21:19:08 +0100 Subject: [PATCH] flash: Use flash page layout size in flash shell Use the page size retrieved via page layout in flash erase shell command in case erase size is not given. Signed-off-by: Jan Van Winkel --- drivers/flash/flash_shell.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/flash/flash_shell.c b/drivers/flash/flash_shell.c index 4ae9b2b23c3..7b7e8c6a0ae 100644 --- a/drivers/flash/flash_shell.c +++ b/drivers/flash/flash_shell.c @@ -52,12 +52,18 @@ static int cmd_erase(const struct shell *shell, size_t argc, char *argv[]) if (argc > 2) { size = strtoul(argv[2], NULL, 16); } else { -#if defined(CONFIG_SOC_FLASH_NRF) - size = NRF_FICR->CODEPAGESIZE; -#else - error(shell, "Missing size."); - return -EINVAL; -#endif + struct flash_pages_info info; + + result = flash_get_page_info_by_offs(flash_dev, page_addr, + &info); + + if (result != 0) { + error(shell, "Could not determine page size, " + "code %d.", result); + return -EINVAL; + } + + size = info.size; } flash_write_protection_set(flash_dev, 0);