Evil twins are chips with identical IDs and different/incompatible
characteristics (e.g. eraseblock layout, write strategy or size).
Annotate them so flashrom can tell the user that it's not a matter of
simply picking one of the chips in a list of multiple chips found.

This patch only touches the AMIC A25L40PT and A25L40PU.
I'm fairly sure there are more evil twins, but those two were touched
recently.

Signed-off-by: Carl-Daniel Hailfinger <[email protected]>

Index: flashrom-evil_twin/flash.h
===================================================================
--- flashrom-evil_twin/flash.h  (Revision 1096)
+++ flashrom-evil_twin/flash.h  (Arbeitskopie)
@@ -180,6 +180,14 @@
 #define FEATURE_ADDR_2AA       (1 << 2)
 #define FEATURE_ADDR_AAA       (2 << 2)
 #define FEATURE_ADDR_SHIFTED   (1 << 5)
+/* Evil twins are chips with the same ID and different erase/write
+ * characteristics. The second macro discards its arguments for now and allows
+ * human readable annotation while at the same time providing a zero cost
+ * simplified machine readable annotation. The first macro is there to check
+ * quickly if the chip has any evil twins.
+ */
+#define FEATURE_EVIL_TWIN      (1 << 6)
+#define FEATURE_EVIL_TWIN_OF(a,b) (1 << 6)
 
 struct flashchip {
        const char *vendor;
Index: flashrom-evil_twin/flashchips.c
===================================================================
--- flashrom-evil_twin/flashchips.c     (Revision 1096)
+++ flashrom-evil_twin/flashchips.c     (Arbeitskopie)
@@ -1372,6 +1372,7 @@
                .model_id       = AMIC_A25L40PT,
                .total_size     = 512,
                .page_size      = 256,
+               .feature_bits   = FEATURE_EVIL_TWIN_OF("AMIC", "A25L40PU"),
                .tested         = TEST_OK_PRW,
                .probe          = probe_spi_rdid4,
                .probe_timing   = TIMING_ZERO,
@@ -1404,6 +1405,7 @@
                .model_id       = AMIC_A25L40PU,
                .total_size     = 512,
                .page_size      = 256,
+               .feature_bits   = FEATURE_EVIL_TWIN_OF("AMIC", "A25L40PT"),
                .tested         = TEST_OK_PRW,
                .probe          = probe_spi_rdid4,
                .probe_timing   = TIMING_ZERO,
Index: flashrom-evil_twin/cli_classic.c
===================================================================
--- flashrom-evil_twin/cli_classic.c    (Revision 1096)
+++ flashrom-evil_twin/cli_classic.c    (Arbeitskopie)
@@ -399,7 +399,8 @@
        if (flashes[1]) {
                printf("Multiple flash chips were detected:");
                for (i = 0; i < ARRAY_SIZE(flashes) && flashes[i]; i++)
-                       printf(" %s", flashes[i]->name);
+                       printf("%s %s%s", i ? "," : "", flashes[i]->name,
+                              flashes[i]->feature_bits & FEATURE_EVIL_TWIN ? " 
(evil twin)" : "");
                printf("\nPlease specify which chip to use with the -c 
<chipname> option.\n");
                programmer_shutdown();
                exit(1);


-- 
http://www.hailfinger.org/


_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to