6a4e6c3ca6efa9b7b7048f5248d268f3e46d9c76
[openwrt/staging/dedeckeh.git] / package / boot / uboot-mediatek / patches / 100-15-cmd-sf-add-support-to-read-flash-unique-ID.patch
1 From e60939acbebd07161f3978d1c6f13123fdd2ebf2 Mon Sep 17 00:00:00 2001
2 From: Weijie Gao <weijie.gao@mediatek.com>
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
6 This patch adds support to display unique ID from spi-nor flashes
7
8 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
9 ---
10 cmd/sf.c | 13 ++++++++++++-
11 1 file changed, 12 insertions(+), 1 deletion(-)
12
13 --- a/cmd/sf.c
14 +++ b/cmd/sf.c
15 @@ -407,6 +407,14 @@ static int do_spi_protect(int argc, char
16 return ret == 0 ? 0 : 1;
17 }
18
19 +static int do_spi_flash_read_uuid(void)
20 +{
21 + int ret = 0;
22 + ret = flash->read_uuid(flash);
23 +
24 + return ret == 0 ? 0 : 1;
25 +}
26 +
27 enum {
28 STAGE_ERASE,
29 STAGE_CHECK,
30 @@ -603,6 +611,8 @@ static int do_spi_flash(struct cmd_tbl *
31 ret = do_spi_flash_erase(argc, argv);
32 else if (strcmp(cmd, "protect") == 0)
33 ret = do_spi_protect(argc, argv);
34 + else if (strcmp(cmd, "uuid") == 0)
35 + ret = do_spi_flash_read_uuid();
36 else if (IS_ENABLED(CONFIG_CMD_SF_TEST) && !strcmp(cmd, "test"))
37 ret = do_spi_flash_test(argc, argv);
38 else
39 @@ -633,7 +643,8 @@ static const char long_help[] =
40 " at `addr' to flash at `offset'\n"
41 " or to start of mtd `partition'\n"
42 "sf protect lock/unlock sector len - protect/unprotect 'len' bytes starting\n"
43 - " at address 'sector'"
44 + " at address 'sector'\n"
45 + "sf uuid - read uuid from flash"
46 #ifdef CONFIG_CMD_SF_TEST
47 "\nsf test offset len - run a very basic destructive test"
48 #endif