[adding flashrom(a)flashrom.org to CC]
On 03.10.2009 18:40, Peter Stuge wrote:
> Carl-Daniel Hailfinger wrote:
>
>> Given that flashrom already has a generic image layout feature, I
>> propose to have cbfstool spit out an image layout file which is
>> then read by flashrom. This makes flashrom independent of CBFS and
>> that's a good thing (think upgrade).
>>
>
> This is trivial to implement and might be a good first step, but it's
> absolutely horrible from a usability perspective;
>
> The user would need to keep track of and understand no less than two
> tools, AND an intermediary layout file, in order to perform the
> single task of partial firmware update.
>
The user has to understand cbfstool and lar anyway right now if he/she
wants to do anything useful with fallback/normal. The user also has to
understand flashrom to flash the resulting image. The user will not
directly inspect the ROM image, nor will he/she directly inspect the
layout file.
> I think it is quite neccessary for flashrom to understand CBFS (and
> LAR, for v3 users).
>
What about WPH and other formats from proprietary BIOS vendors? Flashrom
has more users who deal with WPH and related formats than it has users
who deal with CBFS or LAR.
IIRC the Unix philosophy is roughly "Create programs that do one thing
and do it well. Use simple programs together." I like that philosophy.
One option would be to have cbfstool and lar execute the flashrom binary.
Regards,
Carl-Daniel
--
http://www.hailfinger.org/
This was tested on a "custom" mainboard
Of interest to the flashrom group would be that this
worked on "Intel ICH9M-E", Chip set with an Atmel "AT25DF641" 8MB chip
this was a "./flashrom -r save.img" -V >./flashrom-trace.txt
===
This flash part has status UNTESTED for operations: PROBE READ ERASE
WRITE
Please email a report to flashrom(a)flashrom.org if any of the above
operations
work correctly for you with this flash part. Please include the flashrom
output with the additional -V option for all operations you tested (-V,
-rV,
-wV, -EV), and mention which mainboard you tested. Thanks for your help!
===
Reading flash... done.
<<flashrom-trace.txt>>
After save of SPI rom image I did a cmp -l between what I put on it with
a ms-dos fpt.exe program
and the saved image => compare came out identical
I will send more traces as I do write ... etc.
If you need / want more info I will do what I can to get it for you
Thomas Buckeyne
Sr Firmware Eng.
Bally Technologies
6601 South Bermuda Road
Las Vegas, NV 89119
Direct 702.584.7109
Main 702.584.7700
Author: uwe
Date: 2009-10-01 20:40:02 +0200 (Thu, 01 Oct 2009)
New Revision: 742
Modified:
trunk/flashrom.c
trunk/ft2232_spi.c
Log:
Cosmetics and small coding style fixes (trivial).
Also, introduce BITMODE_BITBANG_SPI to eliminate a magic value.
Signed-off-by: Uwe Hermann <uwe(a)hermann-uwe.de>
Acked-by: Uwe Hermann <uwe(a)hermann-uwe.de>
Modified: trunk/flashrom.c
===================================================================
--- trunk/flashrom.c 2009-10-01 14:51:25 UTC (rev 741)
+++ trunk/flashrom.c 2009-10-01 18:40:02 UTC (rev 742)
@@ -563,12 +563,12 @@
return ret;
}
-void emergency_help_message()
+void emergency_help_message(void)
{
fprintf(stderr, "Your flash chip is in an unknown state.\n"
- "Get help on IRC at irc.freenode.net channel #flashrom or\n"
- "mail flashrom(a)flashrom.org\n"
- "------------------------------------------------------------\n"
+ "Get help on IRC at irc.freenode.net (channel #flashrom) or\n"
+ "mail flashrom(a)flashrom.org!\n--------------------"
+ "-----------------------------------------------------------\n"
"DO NOT REBOOT OR POWEROFF!\n");
}
Modified: trunk/ft2232_spi.c
===================================================================
--- trunk/ft2232_spi.c 2009-10-01 14:51:25 UTC (rev 741)
+++ trunk/ft2232_spi.c 2009-10-01 18:40:02 UTC (rev 742)
@@ -29,15 +29,20 @@
#include "spi.h"
#include <ftdi.h>
-/* the 'H' chips can run internally at either 12Mhz or 60Mhz.
- * the non-H chips can only run at 12Mhz. */
+/*
+ * The 'H' chips can run internally at either 12MHz or 60MHz.
+ * The non-H chips can only run at 12MHz.
+ */
#define CLOCK_5X 1
-/* in either case, the divisor is a simple integer clock divider.
- * if CLOCK_5X is set, this divisor divides 30Mhz, else it
- * divides 6Mhz */
-#define DIVIDE_BY 3 // e.g. '3' will give either 10Mhz or 2Mhz spi clock
+/*
+ * In either case, the divisor is a simple integer clock divider.
+ * If CLOCK_5X is set, this divisor divides 30MHz, else it divides 6MHz.
+ */
+#define DIVIDE_BY 3 /* e.g. '3' will give either 10MHz or 2MHz SPI clock. */
+#define BITMODE_BITBANG_NORMAL 1
+#define BITMODE_BITBANG_SPI 2
static struct ftdi_context ftdic_context;
@@ -76,7 +81,7 @@
if (ftdi_init(ftdic) < 0) {
fprintf(stderr, "ftdi_init failed\n");
- return EXIT_FAILURE;
+ return EXIT_FAILURE; // TODO
}
if (programmer_param && !strlen(programmer_param)) {
@@ -113,9 +118,9 @@
f = ftdi_usb_open(ftdic, 0x0403, ft2232_type);
if (f < 0 && f != -5) {
- fprintf(stderr, "Unable to open ftdi device: %d (%s)\n", f,
+ fprintf(stderr, "Unable to open FTDI device: %d (%s)\n", f,
ftdi_get_error_string(ftdic));
- exit(-1);
+ exit(-1); // TODO
}
if (ftdi_set_interface(ftdic, ft2232_interface) < 0) {
@@ -124,7 +129,7 @@
}
if (ftdi_usb_reset(ftdic) < 0) {
- fprintf(stderr, "Unable to reset ftdi device\n");
+ fprintf(stderr, "Unable to reset FTDI device\n");
}
if (ftdi_set_latency_timer(ftdic, 2) < 0) {
@@ -135,13 +140,13 @@
fprintf(stderr, "Unable to set chunk size\n");
}
- if (ftdi_set_bitmode(ftdic, 0x00, 2) < 0) {
- fprintf(stderr, "Unable to set bitmode\n");
+ if (ftdi_set_bitmode(ftdic, 0x00, BITMODE_BITBANG_SPI) < 0) {
+ fprintf(stderr, "Unable to set bitmode to SPI\n");
}
#if CLOCK_5X
printf_debug("Disable divide-by-5 front stage\n");
- buf[0] = 0x8a; /* disable divide-by-5 */
+ buf[0] = 0x8a; /* Disable divide-by-5. */
if (send_buf(ftdic, buf, 1))
return -1;
#define MPSSE_CLK 60.0
@@ -154,16 +159,16 @@
printf_debug("Set clock divisor\n");
buf[0] = 0x86; /* command "set divisor" */
/* valueL/valueH are (desired_divisor - 1) */
- buf[1] = (DIVIDE_BY-1) & 0xff;
- buf[2] = ((DIVIDE_BY-1) >> 8) & 0xff;
+ buf[1] = (DIVIDE_BY - 1) & 0xff;
+ buf[2] = ((DIVIDE_BY - 1) >> 8) & 0xff;
if (send_buf(ftdic, buf, 3))
return -1;
printf("SPI clock is %fMHz\n",
- (double)(MPSSE_CLK / (((DIVIDE_BY-1) + 1) * 2)));
+ (double)(MPSSE_CLK / (((DIVIDE_BY - 1) + 1) * 2)));
- /* Disconnect TDI/DO to TDO/DI for Loopback */
- printf_debug("No loopback of tdi/do tdo/di\n");
+ /* Disconnect TDI/DO to TDO/DI for loopback. */
+ printf_debug("No loopback of TDI/DO TDO/DI\n");
buf[0] = 0x85;
if (send_buf(ftdic, buf, 1))
return -1;
@@ -180,7 +185,7 @@
if (send_buf(ftdic, buf, 3))
return -1;
- printf_debug("\nft2232 chosen\n");
+ // printf_debug("\nft2232 chosen\n");
buses_supported = CHIP_BUSTYPE_SPI;
spi_controller = SPI_CONTROLLER_FT2232;
@@ -193,7 +198,7 @@
{
struct ftdi_context *ftdic = &ftdic_context;
static unsigned char *buf = NULL;
- int i, ret = 0;
+ int i = 0, ret = 0;
if (writecnt > 65536 || readcnt > 65536)
return SPI_INVALID_LENGTH;
@@ -201,15 +206,13 @@
buf = realloc(buf, writecnt + readcnt + 100);
if (!buf) {
fprintf(stderr, "Out of memory!\n");
- exit(1);
+ exit(1); // -1
}
- i = 0;
-
- /* minimize USB transfers by packing as many commands
- * as possible together. if we're not expecting to
- * read, we can assert CS, write, and deassert CS all
- * in one shot. if reading, we do three separate
+ /*
+ * Minimize USB transfers by packing as many commands as possible
+ * together. If we're not expecting to read, we can assert CS#, write,
+ * and deassert CS# all in one shot. If reading, we do three separate
* operations.
*/
printf_debug("Assert CS#\n");
@@ -221,11 +224,12 @@
buf[i++] = 0x11;
buf[i++] = (writecnt - 1) & 0xff;
buf[i++] = ((writecnt - 1) >> 8) & 0xff;
- memcpy(buf+i, writearr, writecnt);
+ memcpy(buf + i, writearr, writecnt);
i += writecnt;
}
- /* optionally terminate this batch of commands with a
+ /*
+ * Optionally terminate this batch of commands with a
* read command, then do the fetch of the results.
*/
if (readcnt) {
@@ -235,13 +239,13 @@
ret = send_buf(ftdic, buf, i);
i = 0;
if (ret == 0) {
- /* FIXME: This is unreliable. There's no guarantee that we read
- * the response directly after sending the read command.
- * We may be scheduled out etc.
+ /*
+ * FIXME: This is unreliable. There's no guarantee that
+ * we read the response directly after sending the read
+ * command. We may be scheduled out etc.
*/
ret = get_buf(ftdic, readarr, readcnt);
}
-
}
printf_debug("De-assert CS#\n");
@@ -266,7 +270,7 @@
int i;
spi_disable_blockprotect();
- /* Erase first */
+ /* Erase first. */
printf("Erasing flash before programming... ");
if (erase_flash(flash)) {
fprintf(stderr, "ERASE FAILED!\n");
@@ -285,7 +289,7 @@
fprintf(stderr, "%s: write fail %d\n", __func__, r);
return 1;
}
-
+
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
/* loop */;
}