diff options
-rw-r--r-- | flash.h | 59 | ||||
-rw-r--r-- | flashchips.c | 4 | ||||
-rw-r--r-- | flashrom.c | 53 | ||||
-rw-r--r-- | print.c | 24 | ||||
-rw-r--r-- | print_wiki.c | 44 |
5 files changed, 113 insertions, 71 deletions
@@ -120,6 +120,26 @@ enum write_granularity { #define FEATURE_OTP (1 << 8) #define FEATURE_QPI (1 << 9) +enum test_state { + OK = 0, + NT = 1, /* Not tested */ + BAD, /* Known to not work */ + DEP, /* Support depends on configuration (e.g. Intel flash descriptor) */ + NA, /* Not applicable (e.g. write support on ROM chips) */ +}; + +#define TEST_UNTESTED (struct tested){ .probe = NT, .read = NT, .erase = NT, .write = NT } + +#define TEST_OK_PROBE (struct tested){ .probe = OK, .read = NT, .erase = NT, .write = NT } +#define TEST_OK_PR (struct tested){ .probe = OK, .read = OK, .erase = NT, .write = NT } +#define TEST_OK_PRE (struct tested){ .probe = OK, .read = OK, .erase = OK, .write = NT } +#define TEST_OK_PREW (struct tested){ .probe = OK, .read = OK, .erase = OK, .write = OK } + +#define TEST_BAD_PROBE (struct tested){ .probe = BAD, .read = NT, .erase = NT, .write = NT } +#define TEST_BAD_PR (struct tested){ .probe = BAD, .read = BAD, .erase = NT, .write = NT } +#define TEST_BAD_PRE (struct tested){ .probe = BAD, .read = BAD, .erase = BAD, .write = NT } +#define TEST_BAD_PREW (struct tested){ .probe = BAD, .read = BAD, .erase = BAD, .write = BAD } + struct flashctx; typedef int (erasefunc_t)(struct flashctx *flash, unsigned int addr, unsigned int blocklen); @@ -143,11 +163,13 @@ struct flashchip { unsigned int page_size; int feature_bits; - /* - * Indicate if flashrom has been tested with this flash chip and if - * everything worked correctly. - */ - uint32_t tested; + /* Indicate how well flashrom supports different operations of this flash chip. */ + struct tested { + enum test_state probe; + enum test_state read; + enum test_state erase; + enum test_state write; + } tested; int (*probe) (struct flashctx *flash); @@ -192,27 +214,6 @@ struct flashctx { struct registered_programmer *pgm; }; -#define TEST_UNTESTED 0 - -#define TEST_OK_PROBE (1 << 0) -#define TEST_OK_READ (1 << 1) -#define TEST_OK_ERASE (1 << 2) -#define TEST_OK_WRITE (1 << 3) -#define TEST_OK_PR (TEST_OK_PROBE | TEST_OK_READ) -#define TEST_OK_PRE (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE) -#define TEST_OK_PRW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_WRITE) -#define TEST_OK_PREW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE | TEST_OK_WRITE) -#define TEST_OK_MASK 0x0f - -#define TEST_BAD_PROBE (1 << 4) -#define TEST_BAD_READ (1 << 5) -#define TEST_BAD_ERASE (1 << 6) -#define TEST_BAD_WRITE (1 << 7) -#define TEST_BAD_EW (TEST_BAD_ERASE | TEST_BAD_WRITE) -#define TEST_BAD_REW (TEST_BAD_READ | TEST_BAD_ERASE | TEST_BAD_WRITE) -#define TEST_BAD_PREW (TEST_BAD_PROBE | TEST_BAD_READ | TEST_BAD_ERASE | TEST_BAD_WRITE) -#define TEST_BAD_MASK 0xf0 - /* Timing used in probe routines. ZERO is -2 to differentiate between an unset * field and zero delay. * @@ -265,12 +266,6 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it, i int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename); int write_buf_to_file(const unsigned char *buf, unsigned long size, const char *filename); -enum test_state { - OK = 0, - NT = 1, /* Not tested */ - BAD -}; - /* Something happened that shouldn't happen, but we can go on. */ #define ERROR_NONFATAL 0x100 diff --git a/flashchips.c b/flashchips.c index dee7d9eb..027b9961 100644 --- a/flashchips.c +++ b/flashchips.c @@ -2189,7 +2189,7 @@ const struct flashchip flashchips[] = { .model_id = ATMEL_AT26F004, .total_size = 512, .page_size = 256, - .tested = TEST_BAD_WRITE, + .tested = {.probe = NT, .read = NT, .erase = NT, .write = BAD }, .feature_bits = FEATURE_WRSR_WREN, .probe = probe_spi_rdid, .probe_timing = TIMING_ZERO, @@ -5915,7 +5915,7 @@ const struct flashchip flashchips[] = { .model_id = MACRONIX_MX23L3254, .total_size = 4096, .page_size = 256, - .tested = TEST_OK_PR | TEST_BAD_EW, + .tested = {.probe = OK, .read = OK, .erase = NA, .write = NA}, .probe = probe_spi_rdid, .probe_timing = TIMING_ZERO, .write = NULL, /* MX23L3254 is a mask ROM, so it is read-only */ @@ -1791,32 +1791,43 @@ void check_chip_supported(const struct flashchip *chip) "clone the contents of this chip (see man page for " "details).\n"); } - if (TEST_OK_MASK != (chip->tested & TEST_OK_MASK)) { + + if ((chip->tested.erase == NA) && (chip->tested.write == NA)) { + msg_cdbg("This chip's main memory can not be erased/written by design.\n"); + } + + if ((chip->tested.probe == BAD) || (chip->tested.probe == NT) || + (chip->tested.read == BAD) || (chip->tested.read == NT) || + (chip->tested.erase == BAD) || (chip->tested.erase == NT) || + (chip->tested.write == BAD) || (chip->tested.write == NT)){ msg_cinfo("===\n"); - if (chip->tested & TEST_BAD_MASK) { + if ((chip->tested.probe == BAD) || + (chip->tested.read == BAD) || + (chip->tested.erase == BAD) || + (chip->tested.write == BAD)) { msg_cinfo("This flash part has status NOT WORKING for operations:"); - if (chip->tested & TEST_BAD_PROBE) + if (chip->tested.probe == BAD) msg_cinfo(" PROBE"); - if (chip->tested & TEST_BAD_READ) + if (chip->tested.read == BAD) msg_cinfo(" READ"); - if (chip->tested & TEST_BAD_ERASE) + if (chip->tested.erase == BAD) msg_cinfo(" ERASE"); - if (chip->tested & TEST_BAD_WRITE) + if (chip->tested.write == BAD) msg_cinfo(" WRITE"); msg_cinfo("\n"); } - if ((!(chip->tested & TEST_BAD_PROBE) && !(chip->tested & TEST_OK_PROBE)) || - (!(chip->tested & TEST_BAD_READ) && !(chip->tested & TEST_OK_READ)) || - (!(chip->tested & TEST_BAD_ERASE) && !(chip->tested & TEST_OK_ERASE)) || - (!(chip->tested & TEST_BAD_WRITE) && !(chip->tested & TEST_OK_WRITE))) { + if ((chip->tested.probe == NT) || + (chip->tested.read == NT) || + (chip->tested.erase == NT) || + (chip->tested.write == NT)) { msg_cinfo("This flash part has status UNTESTED for operations:"); - if (!(chip->tested & TEST_BAD_PROBE) && !(chip->tested & TEST_OK_PROBE)) + if (chip->tested.probe == NT) msg_cinfo(" PROBE"); - if (!(chip->tested & TEST_BAD_READ) && !(chip->tested & TEST_OK_READ)) + if (chip->tested.read == NT) msg_cinfo(" READ"); - if (!(chip->tested & TEST_BAD_ERASE) && !(chip->tested & TEST_OK_ERASE)) + if (chip->tested.erase == NT) msg_cinfo(" ERASE"); - if (!(chip->tested & TEST_BAD_WRITE) && !(chip->tested & TEST_OK_WRITE)) + if (chip->tested.write == NT) msg_cinfo(" WRITE"); msg_cinfo("\n"); } @@ -1859,7 +1870,7 @@ int chip_safety_check(const struct flashctx *flash, int force, int read_it, int if (read_it || erase_it || write_it || verify_it) { /* Everything needs read. */ - if (chip->tested & TEST_BAD_READ) { + if (chip->tested.read == BAD) { msg_cerr("Read is not working on this chip. "); if (!force) return 1; @@ -1873,7 +1884,11 @@ int chip_safety_check(const struct flashctx *flash, int force, int read_it, int } if (erase_it || write_it) { /* Write needs erase. */ - if (chip->tested & TEST_BAD_ERASE) { + if (chip->tested.erase == NA) { + msg_cerr("Erase is not possible on this chip.\n"); + return 1; + } + if (chip->tested.erase == BAD) { msg_cerr("Erase is not working on this chip. "); if (!force) return 1; @@ -1886,7 +1901,11 @@ int chip_safety_check(const struct flashctx *flash, int force, int read_it, int } } if (write_it) { - if (chip->tested & TEST_BAD_WRITE) { + if (chip->tested.write == NA) { + msg_cerr("Write is not possible on this chip.\n"); + return 1; + } + if (chip->tested.write == BAD) { msg_cerr("Write is not working on this chip. "); if (!force) return 1; @@ -249,38 +249,46 @@ static int print_supported_chips(void) for (i = curdevlen; i < maxchiplen; i++) msg_ginfo(" "); - if ((chip->tested & TEST_OK_PROBE)) + if (chip->tested.probe == OK) msg_ginfo("P"); + else if (chip->tested.probe == NA) + msg_ginfo("-"); else msg_ginfo(" "); - if ((chip->tested & TEST_OK_READ)) + if (chip->tested.read == OK) msg_ginfo("R"); + else if (chip->tested.read == NA) + msg_ginfo("-"); else msg_ginfo(" "); - if ((chip->tested & TEST_OK_ERASE)) + if (chip->tested.erase == OK) msg_ginfo("E"); + else if (chip->tested.erase == NA) + msg_ginfo("-"); else msg_ginfo(" "); - if ((chip->tested & TEST_OK_WRITE)) + if (chip->tested.write == OK) msg_ginfo("W"); + else if (chip->tested.write == NA) + msg_ginfo("-"); else msg_ginfo(" "); for (i = 0; i < border; i++) msg_ginfo(" "); - if ((chip->tested & TEST_BAD_PROBE)) + if (chip->tested.probe == BAD) msg_ginfo("P"); else msg_ginfo(" "); - if ((chip->tested & TEST_BAD_READ)) + if (chip->tested.read == BAD) msg_ginfo("R"); else msg_ginfo(" "); - if ((chip->tested & TEST_BAD_ERASE)) + if (chip->tested.erase == BAD) msg_ginfo("E"); else msg_ginfo(" "); - if ((chip->tested & TEST_BAD_WRITE)) + if (chip->tested.write == BAD) msg_ginfo("W"); else msg_ginfo(" "); diff --git a/print_wiki.c b/print_wiki.c index 5dcc4b6d..cad6fef4 100644 --- a/print_wiki.c +++ b/print_wiki.c @@ -249,7 +249,6 @@ static void print_supported_boards_wiki(void) static void print_supported_chips_wiki(int cols) { unsigned int lines_per_col; - uint32_t t; char *s; char vmax[6]; char vmin[6]; @@ -287,7 +286,35 @@ static void print_supported_chips_wiki(int cols) c = !c; old = f; - t = f->tested; + const char *probe, *read, *write, *erase; + switch (f->tested.probe) { + case OK: probe = "OK"; break; + case BAD: probe = "No"; break; + case NA: probe = "NA"; break; + case DEP: probe = "Dep"; break; + default: probe = "?3"; break; + } + switch (f->tested.read) { + case OK: read = "OK"; break; + case BAD: read = "No"; break; + case NA: read = "NA"; break; + case DEP: read = "Dep"; break; + default: read = "?3"; break; + } + switch (f->tested.erase) { + case OK: erase = "OK"; break; + case BAD: erase = "No"; break; + case NA: erase = "NA"; break; + case DEP: erase = "Dep"; break; + default: erase = "?3"; break; + } + switch (f->tested.write) { + case OK: write = "OK"; break; + case BAD: write = "No"; break; + case NA: write = "NA"; break; + case DEP: write = "Dep"; break; + default: write = "?3"; break; + } s = flashbuses_to_text(f->bustype); sprintf(vmin, "%0.03f", f->voltage.min / (double)1000); sprintf(vmax, "%0.03f", f->voltage.max / (double)1000); @@ -298,16 +325,9 @@ static void print_supported_chips_wiki(int cols) "|| %s || %s \n", (c == 1) ? "eeeeee" : "dddddd", f->vendor, f->name, f->total_size, s, - (t & TEST_OK_PROBE) ? "OK" : - (t & TEST_BAD_PROBE) ? "No" : "?3", - (t & TEST_OK_READ) ? "OK" : - (t & TEST_BAD_READ) ? "No" : "?3", - (t & TEST_OK_ERASE) ? "OK" : - (t & TEST_BAD_ERASE) ? "No" : "?3", - (t & TEST_OK_WRITE) ? "OK" : - (t & TEST_BAD_WRITE) ? "No" : "?3", - f->voltage.min ? vmin : "N/A", - f->voltage.min ? vmax : "N/A"); + probe, read, erase, write, + f->voltage.min ? vmin : "?", + f->voltage.max ? vmax : "?"); free(s); if (((i % lines_per_col) + 1) == lines_per_col) |