From 36d2aafec10998735f93b47a96a0f66c52484af7 Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Mon, 25 Jul 2022 11:27:02 +0800 Subject: [PATCH 13/30] cmd: sf: add support to read flash unique ID This patch adds support to display unique ID from spi-nor flashes Signed-off-by: Weijie Gao --- cmd/sf.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/cmd/sf.c +++ b/cmd/sf.c @@ -421,6 +421,14 @@ static int do_spi_protect(int argc, char return ret == 0 ? 0 : 1; } +static int do_spi_flash_read_uuid(void) +{ + int ret = 0; + ret = flash->read_uuid(flash); + + return ret == 0 ? 0 : 1; +} + enum { STAGE_ERASE, STAGE_CHECK, @@ -615,6 +623,8 @@ static int do_spi_flash(struct cmd_tbl * ret = do_spi_flash_erase(argc, argv); else if (IS_ENABLED(CONFIG_SPI_FLASH_LOCK) && strcmp(cmd, "protect") == 0) ret = do_spi_protect(argc, argv); + else if (strcmp(cmd, "uuid") == 0) + ret = do_spi_flash_read_uuid(); else if (IS_ENABLED(CONFIG_CMD_SF_TEST) && !strcmp(cmd, "test")) ret = do_spi_flash_test(argc, argv); else @@ -638,6 +648,7 @@ U_BOOT_LONGHELP(sf, "sf update addr offset|partition len - erase and write `len' bytes from memory\n" " at `addr' to flash at `offset'\n" " or to start of mtd `partition'\n" + "sf uuid - read uuid from flash\n" #ifdef CONFIG_SPI_FLASH_LOCK "sf protect lock/unlock sector len - protect/unprotect 'len' bytes starting\n" " at address 'sector'"