David Hendricks has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/37407 )
Change subject: print.c: Fix alignment in print_supported_boards_helper()
......................................................................
print.c: Fix alignment in print_supported_boards_helper()
Commit 61e16e5 eliminated some duplicate logic for printing test status,
but in doing so introduced a regression where some entries in `flashrom
-L` output became unaligned.
Up until then, it was assumed that the status field will always be
8-wide, including space for padding. This patch fixes alignment when
using test_state_to_text() by making the padding consistent with other
fields where a for-loop is used to pad the field up to a maximum width.
Change-Id: Ie0a0b45c6466d14447aca443c2697e2048c6ef14
Signed-off-by: David Hendricks <david.hendricks(a)gmail.com>
---
M flash.h
M print.c
2 files changed, 29 insertions(+), 14 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/07/37407/1
diff --git a/flash.h b/flash.h
index 1a9bd9f..e7b1c89 100644
--- a/flash.h
+++ b/flash.h
@@ -145,10 +145,11 @@
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) */
+ 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) */
+ TEST_STATE_END, /* Not a test state, just an indicator of how many are defined. */
};
#define TEST_UNTESTED (struct tested){ .probe = NT, .read = NT, .erase = NT, .write = NT }
diff --git a/print.c b/print.c
index 6a7ff5d..e5be6b6 100644
--- a/print.c
+++ b/print.c
@@ -35,6 +35,20 @@
}
}
+static size_t max_test_state_len(void)
+{
+ int i;
+ size_t max_len;
+
+ for (i = max_len = 0; i < TEST_STATE_END; i++) {
+ size_t len = strlen(test_state_to_text(i));
+ if (len > max_len)
+ max_len = len;
+ }
+
+ return max_len;
+}
+
static int print_supported_chips(void)
{
const char *delim = "/";
@@ -388,8 +402,12 @@
for (i = strlen("Board"); i < maxboardlen; i++)
msg_ginfo(" ");
- msg_ginfo("Status Required value for\n");
- for (i = 0; i < maxvendorlen + maxboardlen + strlen("Status "); i++)
+ msg_ginfo("Status");
+ for (i = strlen("Status"); i < max_test_state_len(); i++)
+ msg_ginfo(" ");
+
+ msg_ginfo("Required value for\n");
+ for (i = 0; i < maxvendorlen + maxboardlen + max_test_state_len(); i++)
msg_ginfo(" ");
msg_ginfo("-p internal:mainboard=\n");
@@ -401,14 +419,10 @@
for (i = 0; i < maxboardlen - strlen(b->name); i++)
msg_ginfo(" ");
- switch (b->working) {
- case OK: msg_ginfo("OK "); break;
- case NT: msg_ginfo("NT "); break;
- case DEP: msg_ginfo("DEP "); break;
- case NA: msg_ginfo("N/A "); break;
- case BAD:
- default: msg_ginfo("BAD "); break;
- }
+ const char *test_state = test_state_to_text(b->working);
+ msg_ginfo("%s", test_state);
+ for (i = 0; i < max_test_state_len() - strlen(test_state); i++)
+ msg_ginfo(" ");
for (e = board_matches; e->vendor_name != NULL; e++) {
if (strcmp(e->vendor_name, b->vendor)
--
To view, visit https://review.coreboot.org/c/flashrom/+/37407
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie0a0b45c6466d14447aca443c2697e2048c6ef14
Gerrit-Change-Number: 37407
Gerrit-PatchSet: 1
Gerrit-Owner: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-MessageType: newchange
David Hendricks has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/37406 )
Change subject: dediprog: add serial argument
......................................................................
dediprog: add serial argument
A quick hack to be able to select dediprogs by USB serial argument by
just adding a @serial_number parameter to dediprog_open() and using it
in preference to @id if available (since it is more specific).
Change-Id: I9cdfbce6cf941c16bf7b7364aa4166b91369e661
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez(a)intel.com>
---
M dediprog.c
M flashrom.8.tmpl
2 files changed, 23 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/06/37406/1
diff --git a/dediprog.c b/dediprog.c
index 175e099..480cf67 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -1006,15 +1006,19 @@
/*
* Open a dediprog_handle with the USB device at the given index.
* @index index of the USB device
+ * @serial_number serial number of the USB device (id is ignored then)
* @return 0 for success, -1 for error, -2 for busy device
*/
-static int dediprog_open(int index)
+static int dediprog_open(int index, char *serial_number)
{
const uint16_t vid = devs_dediprog[0].vendor_id;
const uint16_t pid = devs_dediprog[0].device_id;
int ret;
- dediprog_handle = usb_dev_get_by_vid_pid_number(usb_ctx, vid, pid, (unsigned int) index);
+ if (serial_number)
+ dediprog_handle = usb_dev_get_by_vid_pid_serial(usb_ctx, vid, pid, serial_number);
+ else
+ dediprog_handle = usb_dev_get_by_vid_pid_number(usb_ctx, vid, pid, (unsigned int) index);
if (!dediprog_handle) {
msg_perr("Could not find a Dediprog programmer on USB.\n");
libusb_exit(usb_ctx);
@@ -1057,7 +1061,8 @@
int dediprog_init(void)
{
- char *voltage, *id_str, *device, *spispeed, *target_str;
+ char *voltage, *id_str, *device, *spispeed, *target_str,
+ *serial_number;
int spispeed_idx = 1;
int millivolt = 3500;
int id = -1; /* -1 defaults to enumeration order */
@@ -1091,6 +1096,7 @@
msg_pinfo("Setting voltage to %i mV\n", millivolt);
}
+ serial_number = extract_programmer_param("serial");
id_str = extract_programmer_param("id");
if (id_str) {
char prefix0, prefix1;
@@ -1183,9 +1189,14 @@
return 1;
}
- if (id != -1) {
+ if (serial_number) {
+ if (dediprog_open(0, serial_number)) {
+ return 1;
+ }
+ found_id = dediprog_read_id();
+ } else if (id != -1) {
for (i = 0; ; i++) {
- ret = dediprog_open(i);
+ ret = dediprog_open(i, NULL);
if (ret == -1) {
/* no dev */
libusb_exit(usb_ctx);
@@ -1218,7 +1229,7 @@
break;
}
} else {
- if (dediprog_open(usedevice)) {
+ if (dediprog_open(usedevice, NULL)) {
return 1;
}
found_id = dediprog_read_id();
@@ -1276,6 +1287,5 @@
if (register_spi_master(&spi_master_dediprog) || dediprog_set_leds(LED_NONE))
return 1;
-
return 0;
}
diff --git a/flashrom.8.tmpl b/flashrom.8.tmpl
index 27f3846..5af1a38 100644
--- a/flashrom.8.tmpl
+++ b/flashrom.8.tmpl
@@ -928,6 +928,12 @@
.BR 0V ", " 1.8V ", " 2.5V ", " 3.5V
or the equivalent in mV.
.sp
+You can use the
+.B serial
+parameter to explicitly specify which dediprog device should be used
+based on their USB serial number::
+.sp
+.B " flashrom \-p dediprog:serial=1230A12"
An optional
.B device
parameter specifies which of multiple connected Dediprog devices should be used.
--
To view, visit https://review.coreboot.org/c/flashrom/+/37406
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I9cdfbce6cf941c16bf7b7364aa4166b91369e661
Gerrit-Change-Number: 37406
Gerrit-PatchSet: 1
Gerrit-Owner: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-MessageType: newchange
Ryan O'Leary has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/37723 )
Change subject: Match -c parameter against patterns in chip names
......................................................................
Match -c parameter against patterns in chip names
This includes patterns such as "EN29GL064H/L", "Am29F002(N)BB" and
"A25LQ032/A25LQ32A".
This was inspired by a breakage in one of my scripts. The script
hard-coded "-c CHIPX". When upstream changed the chip name to
"CHIPX/CHIPY", my script broke. By recognizing this pattern, the -c
parameter is more resilient to these types of changes.
Since an exact match on the whole name takes priority (the current
behavior), this should not break anyone's workflow.
Change-Id: Iae00bb1108f2d5a0c10977cff63f9348b9fc017f
Signed-off-by: Ryan O'Leary <ryanoleary(a)google.com>
---
M cli_classic.c
1 file changed, 69 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/23/37723/1
diff --git a/cli_classic.c b/cli_classic.c
index 73cc417..43aac0b 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -103,6 +103,68 @@
return 0;
}
+/*
+ * Return 1 if the chip name matches the pattern, otherwise 0.
+ *
+ * The pattern may be:
+ * 1. A single slash followed by a single character.
+ * Ex: "EN29GL064H/L" matches "EN29GL064H" and "EN29GL064L".
+ * 2. One character in parens.
+ * Ex: "Am29F002(N)BB" matches "Am29F002BB" and "Am29F002NBB".
+ * Ex: "EN29F002(A)(N)B" matches four different chip names.
+ * 3. A slash-separated list.
+ * Ex: "A25LQ032/A25LQ32A" matches "A25LQ032" and "A25LQ32A".
+ * Ex: "MX25L12835F/MX25L12845E/MX25L12865E" matches "MX25L12835F", "MX25L12845E" and "MX25L12865E".
+ *
+ * #2 may be nested in #3, for example "W29C010(M)/W29C011A/W29EE011/W29EE012".
+ */
+static int chip_name_match_pattern(const char *pattern, const char *chip) {
+ int plen = strlen(pattern);
+ int clen = strlen(chip);
+
+ if (plen < 3 || clen < 3) {
+ return 0;
+ }
+
+ /* Single slash followed by single character. */
+ if (pattern[plen-2] == '/') {
+ for (int pidx = 0; pidx < plen - 2; pidx++)
+ if (pattern[pidx] == '/')
+ return 0;
+ return plen - 2 == clen &&
+ strncmp(pattern, chip, plen - 3) == 0 &&
+ (pattern[plen-1] == chip[clen-1] ||
+ pattern[plen-3] == chip[clen-1]);
+ }
+
+ int cidx = 0;
+ for (int pidx = 0; pidx < plen; pidx++) {
+ if (pattern[pidx] == '/') {
+ /* Check for termination. */
+ if (cidx == clen)
+ break;
+ cidx = 0; /* Reset. */
+ } else if (pattern[pidx] == '(') {
+ if (pidx + 2 >= plen ||
+ pattern[pidx+1] == ')' ||
+ pattern[pidx+1] == '(' ||
+ pattern[pidx+2] != ')')
+ return 0; /* Invalid pattern. */
+ if (pattern[pidx+1] == chip[cidx])
+ cidx++;
+ pidx += 2;
+ } else if (pattern[pidx] == chip[cidx]) {
+ cidx++;
+ } else {
+ /* Reset to next slash. */
+ while (pidx < plen && pattern[pidx] != '/')
+ pidx++;
+ cidx = 0;
+ }
+ }
+ return cidx == clen;
+}
+
int main(int argc, char *argv[])
{
const struct flashchip *chip = NULL;
@@ -421,15 +483,22 @@
}
/* Does a chip with the requested name exist in the flashchips array? */
if (chip_to_probe) {
+ /* First check for exact match. */
for (chip = flashchips; chip && chip->name; chip++)
if (!strcmp(chip->name, chip_to_probe))
break;
+ /* Failing that, perform a pattern match. */
+ if (!chip || !chip->name)
+ for (chip = flashchips; chip && chip->name; chip++)
+ if (chip_name_match_pattern(chip->name, chip_to_probe))
+ break;
if (!chip || !chip->name) {
msg_cerr("Error: Unknown chip '%s' specified.\n", chip_to_probe);
msg_gerr("Run flashrom -L to view the hardware supported in this flashrom version.\n");
ret = 1;
goto out;
}
+ msg_gdbg("Using chip \"%s\".\n", chip->name);
/* Keep chip around for later usage in case a forced read is requested. */
}
--
To view, visit https://review.coreboot.org/c/flashrom/+/37723
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Iae00bb1108f2d5a0c10977cff63f9348b9fc017f
Gerrit-Change-Number: 37723
Gerrit-PatchSet: 1
Gerrit-Owner: Ryan O'Leary <ryanoleary(a)google.com>
Gerrit-MessageType: newchange
Hello Angel Pons, Miklós Márton, David Hendricks,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/flashrom/+/38034
to review the following change.
Change subject: stlinkv3_spi: Move a declaration out of for-loop head
......................................................................
stlinkv3_spi: Move a declaration out of for-loop head
GCC 4.8 wants an explicit `-std=c99` or something for this to work. It
seems easier to keep the common declaration style.
Change-Id: Ic0819f82169df4d66cc949494229b0749c06e8f6
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M stlinkv3_spi.c
1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/34/38034/1
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c
index 02e87bc..7338911 100644
--- a/stlinkv3_spi.c
+++ b/stlinkv3_spi.c
@@ -333,6 +333,7 @@
int rc = 0;
int actual_length = 0;
uint32_t rw_status = 0;
+ unsigned int i;
if (stlinkv3_spi_set_SPI_NSS(SPI_NSS_LOW)) {
msg_perr("Failed to set the NSS pin to low\n");
@@ -346,7 +347,7 @@
command[2] = (uint8_t)write_cnt;
command[3] = (uint8_t)(write_cnt >> 8);
- for (unsigned int i = 0; (i < 8) && (i < write_cnt); i++)
+ for (i = 0; (i < 8) && (i < write_cnt); i++)
command[4+i] = write_arr[i];
rc = libusb_bulk_transfer(stlinkv3_handle, STLINK_EP_OUT,
--
To view, visit https://review.coreboot.org/c/flashrom/+/38034
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ic0819f82169df4d66cc949494229b0749c06e8f6
Gerrit-Change-Number: 38034
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Miklós Márton <martonmiklosqdev(a)gmail.com>
Gerrit-MessageType: newchange