summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Salcedo <bsalcedo@gmx.us>2013-01-03 20:44:30 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-01-03 20:44:30 +0000
commit30dfdbaf3ab30974a6d76e085525d52c033e4215 (patch)
tree05451bdc93ffcab3935c6ac35f5f0dd480c9f012
parente34e3e8a49172ba09eb058c9a028706647dca165 (diff)
downloadast2050-flashrom-30dfdbaf3ab30974a6d76e085525d52c033e4215.zip
ast2050-flashrom-30dfdbaf3ab30974a6d76e085525d52c033e4215.tar.gz
Add user interface to activate the Bus Pirate pull-up resistors
When working with some flash chips using the Bus Pirate programmer, the use of the Bus Pirate's on-board pull-up resistors is sometimes necessary. On v3 hardware the use of said pull-up resistors requires the user to apply a voltage to the VPU pin of the Bus Pirate, and then command it to use them. For v4 hardware which supports also fixed internal 3.3V and 5V sources no documentation could be found. Here is a link to information pertaining to what this patch does: http://dangerousprototypes.com/docs/SPI_(binary)#0100wxyz_-_Configure_peripherals_w.3Dpower.2C_x.3Dpull-ups.2C_y.3DAUX.2C_z.3DCS Bonus: small cleanup of superfluous stack variables. Corresponding to flashrom svn r1641. Signed-off-by: Brian Salcedo <bsalcedo@gmx.us> Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Tested-by: Brian Salcedo <bsalcedo@gmx.us> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
-rw-r--r--buspirate_spi.c37
-rw-r--r--flashrom.814
2 files changed, 40 insertions, 11 deletions
diff --git a/buspirate_spi.c b/buspirate_spi.c
index 55d4133..d2ebc75 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -201,14 +201,14 @@ out_shutdown:
int buspirate_spi_init(void)
{
- char *dev = NULL;
- char *speed = NULL;
char *tmp;
+ char *dev;
+ int i;
unsigned int fw_version_major = 0;
unsigned int fw_version_minor = 0;
int spispeed = 0x7;
int ret = 0;
- int i;
+ int pullup = 0;
dev = extract_programmer_param("dev");
if (dev && !strlen(dev)) {
@@ -220,18 +220,29 @@ int buspirate_spi_init(void)
return 1;
}
- speed = extract_programmer_param("spispeed");
- if (speed) {
- for (i = 0; spispeeds[i].name; i++)
- if (!strncasecmp(spispeeds[i].name, speed,
- strlen(spispeeds[i].name))) {
+ tmp = extract_programmer_param("spispeed");
+ if (tmp) {
+ for (i = 0; spispeeds[i].name; i++) {
+ if (!strncasecmp(spispeeds[i].name, tmp, strlen(spispeeds[i].name))) {
spispeed = spispeeds[i].speed;
break;
}
+ }
if (!spispeeds[i].name)
msg_perr("Invalid SPI speed, using default.\n");
}
- free(speed);
+ free(tmp);
+
+ tmp = extract_programmer_param("pullups");
+ if (tmp) {
+ if (strcasecmp("on", tmp) == 0)
+ pullup = 1;
+ else if (strcasecmp("off", tmp) == 0)
+ ; // ignore
+ else
+ msg_perr("Invalid pullups state, not using them.\n");
+ }
+ free(tmp);
/* Default buffer size is 19: 16 bytes data, 3 bytes control. */
#define DEFAULT_BUFSIZE (16 + 3)
@@ -395,12 +406,16 @@ int buspirate_spi_init(void)
}
/* Initial setup (SPI peripherals config): Enable power, CS high, AUX */
- bp_commbuf[0] = 0x40 | 0xb;
+ bp_commbuf[0] = 0x40 | 0x0b;
+ if (pullup == 1) {
+ bp_commbuf[0] |= (1 << 2);
+ msg_pdbg("Enabling pull-up resistors.\n");
+ }
ret = buspirate_sendrecv(bp_commbuf, 1, 1);
if (ret)
return 1;
if (bp_commbuf[0] != 0x01) {
- msg_perr("Protocol error while setting power/CS/AUX!\n");
+ msg_perr("Protocol error while setting power/CS/AUX(/Pull-up resistors)!\n");
return 1;
}
diff --git a/flashrom.8 b/flashrom.8
index 102bd62..90afced 100644
--- a/flashrom.8
+++ b/flashrom.8
@@ -637,6 +637,20 @@ where
can be
.BR 30k ", " 125k ", " 250k ", " 1M ", " 2M ", " 2.6M ", " 4M " or " 8M
(in Hz). The default is the maximum frequency of 8 MHz.
+.sp
+An optional pullups parameter specifies the use of the Bus Pirate internal pull-up resistors. This may be
+needed if you are working with a flash ROM chip that you have physically removed from the board. Syntax is
+.sp
+.B " flashrom -p buspirate_spi:pullups=state"
+.sp
+where
+.B state
+can be
+.BR on " or " off .
+More information about the Bus Pirate pull-up resistors and their purpose is available at
+.nh
+.BR "http://dangerousprototypes.com/docs/Practical_guide_to_Bus_Pirate_pull-up_resistors " .
+Only the external supply voltage (Vpu) is supported as of this writing.
.SS
.BR "dediprog " programmer
An optional
OpenPOWER on IntegriCloud