[flashrom] [PATCH 3/5] dediprog: Show UID.
Stefan Tauner
stefan.tauner at alumni.tuwien.ac.at
Mon Jun 22 03:37:22 CEST 2015
Whatever that is...
To that end, send the respective command and print result with a "new"
helpers.c function.
Signed-off-by: Stefan Tauner <stefan.tauner at alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner at alumni.tuwien.ac.at>
---
dediprog.c | 19 +++++++++++++++++++
flash.h | 1 +
helpers.c | 7 +++++++
3 files changed, 27 insertions(+)
diff --git a/dediprog.c b/dediprog.c
index ce7ff7a..a6801be 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -730,6 +730,18 @@ static int dediprog_shutdown(void *data)
return 0;
}
+/* Return the 8-byte UID for the flash */
+static int get_uid(uint8_t buf[8])
+{
+ int ret = dediprog_read(CMD_GET_UID, 0, 0, buf, 8);
+ if (ret != 8) {
+ msg_perr("get_uid failed (%s)!\n", usb_strerror());
+ return 1;
+ }
+
+ return 0;
+}
+
/* URB numbers refer to the first log ever captured. */
int dediprog_init(void)
{
@@ -872,6 +884,13 @@ int dediprog_init(void)
return 1;
}
+ uint8_t uid[8];
+ if (get_uid(uid) != 0)
+ return 1;
+ msg_pdbg("UID:");
+ print_hex_buf(uid, sizeof(uid));
+ msg_pdbg("\n");
+
register_spi_master(&spi_master_dediprog);
dediprog_set_leds(LED_NONE);
diff --git a/flash.h b/flash.h
index 2c2839f..f7bd94b 100644
--- a/flash.h
+++ b/flash.h
@@ -251,6 +251,7 @@ void print_supported_wiki(void);
/* helpers.c */
uint32_t address_to_bits(uint32_t addr);
+void print_hex_buf(uint8_t *buf, size_t len);
int bitcount(unsigned long a);
int max(int a, int b);
int min(int a, int b);
diff --git a/helpers.c b/helpers.c
index 7a146c3..a82ba55 100644
--- a/helpers.c
+++ b/helpers.c
@@ -34,6 +34,13 @@ uint32_t address_to_bits(uint32_t addr)
return 32 - lzb;
}
+void print_hex_buf(uint8_t *buf, size_t len)
+{
+ size_t i;
+ for (i = 0; i < len; i++)
+ msg_pdbg(" %02x", buf[i]);
+}
+
int bitcount(unsigned long a)
{
int i = 0;
--
Kind regards, Stefan Tauner
More information about the flashrom
mailing list