Patchwork Annotate evil twins

login
register
about
Submitter David Borg
Date 2010-09-04 00:35:04
Message ID <AANLkTinGRa+AEcJ2Xf9=TBc=iBEZsWHQP3s4EAEZthAF@mail.gmail.com>
Download mbox | patch
Permalink /patch/1861/
State Rejected
Headers show

Comments

David Borg - 2010-09-04 00:35:04
Updated to apply cleanly against current revision (1151). Changed the
bit used to indicate evil twins, as it is now used by FEATURE_WRSR_*

Regards,

David

>On 22.07.2010 15:43, Daniel Lenski wrote:
>> On Thu, 2010-07-22 at 14:54 +0200, Carl-Daniel Hailfinger wrote:
>>
>>> 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 <c-d.hailfinger.devel.2...@gmx.net>
>>>
>>
>> I should point out that the A25L40PT and A25L40PU got erase-tested by
>> Rudolf Marek while we were trying to figure out if they were really evil
>> twins.  My patch added the erase-tested bit, but I think you took this
>> out.
>>
>
>Yes, sorry for not mentioning this in the commit mail. Right now we only
>check if at least one erase function worked. There is no way (except
>editing the source code) to test all erase functions for a given chip.
>This will change once
>[PATCH] Move implicit erase out of chip drivers, clean up
>is committed and we have partial write.
>
>Regards,
>Carl-Daniel
>
>--
>http://www.hailfinger.org/

Patch

Index: flash.h
===================================================================
--- flash.h	(revision 1151)
+++ flash.h	(working copy)
@@ -86,6 +86,14 @@ 
 #define FEATURE_WRSR_EWSR	(1 << 6)
 #define FEATURE_WRSR_WREN	(1 << 7)
 #define FEATURE_WRSR_EITHER	(FEATURE_WRSR_EWSR | FEATURE_WRSR_WREN)
+/* 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 << 8)
+#define FEATURE_EVIL_TWIN_OF(a,b) (1 << 8)
 
 struct flashchip {
 	const char *vendor;
Index: cli_classic.c
===================================================================
--- cli_classic.c	(revision 1151)
+++ cli_classic.c	(working copy)
@@ -400,7 +400,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);
Index: flashchips.c
===================================================================
--- flashchips.c	(revision 1151)
+++ flashchips.c	(working copy)
@@ -477,6 +477,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,
@@ -509,6 +510,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,