Commit c2a4af5ca8032d69818bac6d4030233af50f09a9

Authored by Angus Ainslie
Committed by Stefano Babic
1 parent 8ad1c9c26f
Exists in emb_lf_v2022.04

cmd: fuse: add a fuse comparison function

Compare a hexval to the fuse value and return pass or fail.

Signed-off-by: Angus Ainslie <angus@akkea.ca>

Showing 1 changed file with 21 additions and 1 deletions Side-by-side Diff

... ... @@ -45,7 +45,7 @@
45 45 {
46 46 const char *op = argc >= 2 ? argv[1] : NULL;
47 47 int confirmed = argc >= 3 && !strcmp(argv[2], "-y");
48   - u32 bank, word, cnt, val;
  48 + u32 bank, word, cnt, val, cmp;
49 49 int ret, i;
50 50  
51 51 argc -= 2 + confirmed;
... ... @@ -73,6 +73,24 @@
73 73 printf(" %.8x", val);
74 74 }
75 75 putc('\n');
  76 + } else if (!strcmp(op, "cmp")) {
  77 + if (argc != 3 || strtou32(argv[2], 0, &cmp))
  78 + return CMD_RET_USAGE;
  79 +
  80 + printf("Comparing bank %u:\n", bank);
  81 + printf("\nWord 0x%.8x:", word);
  82 + printf("\nValue 0x%.8x:", cmp);
  83 +
  84 + ret = fuse_read(bank, word, &val);
  85 + if (ret)
  86 + goto err;
  87 +
  88 + printf("0x%.8x\n", val);
  89 + if (val != cmp) {
  90 + printf("failed\n");
  91 + return CMD_RET_FAILURE;
  92 + }
  93 + printf("passed\n");
76 94 } else if (!strcmp(op, "sense")) {
77 95 if (argc == 2)
78 96 cnt = 1;
... ... @@ -137,6 +155,8 @@
137 155 "Fuse sub-system",
138 156 "read <bank> <word> [<cnt>] - read 1 or 'cnt' fuse words,\n"
139 157 " starting at 'word'\n"
  158 + "fuse cmp <bank> <word> <hexval> - compare 'hexval' to fuse\n"
  159 + " at 'word'\n"
140 160 "fuse sense <bank> <word> [<cnt>] - sense 1 or 'cnt' fuse words,\n"
141 161 " starting at 'word'\n"
142 162 "fuse prog [-y] <bank> <word> <hexval> [<hexval>...] - program 1 or\n"