100-15-cmd-sf-add-support-to-read-flash-unique-ID.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From e60939acbebd07161f3978d1c6f13123fdd2ebf2 Mon Sep 17 00:00:00 2001
  2. From: Weijie Gao <[email protected]>
  3. Date: Mon, 25 Jul 2022 11:27:02 +0800
  4. Subject: [PATCH 50/71] cmd: sf: add support to read flash unique ID
  5. This patch adds support to display unique ID from spi-nor flashes
  6. Signed-off-by: Weijie Gao <[email protected]>
  7. ---
  8. cmd/sf.c | 13 ++++++++++++-
  9. 1 file changed, 12 insertions(+), 1 deletion(-)
  10. --- a/cmd/sf.c
  11. +++ b/cmd/sf.c
  12. @@ -412,6 +412,14 @@ static int do_spi_protect(int argc, char
  13. return ret == 0 ? 0 : 1;
  14. }
  15. +static int do_spi_flash_read_uuid(void)
  16. +{
  17. + int ret = 0;
  18. + ret = flash->read_uuid(flash);
  19. +
  20. + return ret == 0 ? 0 : 1;
  21. +}
  22. +
  23. enum {
  24. STAGE_ERASE,
  25. STAGE_CHECK,
  26. @@ -606,6 +614,8 @@ static int do_spi_flash(struct cmd_tbl *
  27. ret = do_spi_flash_erase(argc, argv);
  28. else if (IS_ENABLED(CONFIG_SPI_FLASH_LOCK) && strcmp(cmd, "protect") == 0)
  29. ret = do_spi_protect(argc, argv);
  30. + else if (strcmp(cmd, "uuid") == 0)
  31. + ret = do_spi_flash_read_uuid();
  32. else if (IS_ENABLED(CONFIG_CMD_SF_TEST) && !strcmp(cmd, "test"))
  33. ret = do_spi_flash_test(argc, argv);
  34. else
  35. @@ -636,6 +646,7 @@ U_BOOT_LONGHELP(sf,
  36. #ifdef CONFIG_CMD_SF_TEST
  37. "\nsf test offset len - run a very basic destructive test"
  38. #endif
  39. + "sf uuid - read uuid from flash"
  40. );
  41. U_BOOT_CMD(