Allow setting delay loop speed from the command line. This can speed up delay loop calibration somewhat (some time is lost to delay loop verification).
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-specifydelayloop/cli_classic.c =================================================================== --- flashrom-specifydelayloop/cli_classic.c (Revision 1250) +++ flashrom-specifydelayloop/cli_classic.c (Arbeitskopie) @@ -351,9 +351,6 @@ flash = NULL; }
- /* FIXME: Delay calibration should happen in programmer code. */ - myusec_calibrate_delay(); - if (programmer_init(pparam)) { fprintf(stderr, "Error: Programmer initialization failed.\n"); exit(1); Index: flashrom-specifydelayloop/flashrom.8 =================================================================== --- flashrom-specifydelayloop/flashrom.8 (Revision 1250) +++ flashrom-specifydelayloop/flashrom.8 (Arbeitskopie) @@ -220,6 +220,21 @@ programmers use a key/value interface in which the key and value is separated by an equal sign and different pairs are separated by a comma or a colon. .TP +.B Common parameters for all programmers +The initial delay loop calibration of flashrom usually takes more than one +second, and in case of a machine with high system load or variable CPU speed +flashrom may repeat the delay loop calibration a few times until it is satisfied +with the precision or until it gives up. You can speed up the delay loop +calibration using +.sp +.B " flashrom -p programmername:delayloops=value" +.sp +where value is the number of loops per microsecond (Mloops per second) reported +during the last flashrom run in verbose mode. flashrom will use the specified +value as basis for the delay loop calibration, so do not worry if it is not the +exact value. You can expect an 1 GHz CPU to have delayloop values between 250 +and 2000. +.TP .BR "internal " programmer Some mainboards require to run mainboard specific code to enable flash erase and write support (and probe support on old systems with parallel flash). Index: flashrom-specifydelayloop/flashrom.c =================================================================== --- flashrom-specifydelayloop/flashrom.c (Revision 1250) +++ flashrom-specifydelayloop/flashrom.c (Arbeitskopie) @@ -527,6 +527,10 @@ programmer_param = param; msg_pdbg("Initializing %s programmer\n", programmer_table[programmer].name); + + /* FIXME: Delay calibration should be programmer specific. */ + myusec_calibrate_delay(); + ret = programmer_table[programmer].init(); if (programmer_param && strlen(programmer_param)) { msg_perr("Unhandled programmer parameters: %s\n", Index: flashrom-specifydelayloop/udelay.c =================================================================== --- flashrom-specifydelayloop/udelay.c (Revision 1250) +++ flashrom-specifydelayloop/udelay.c (Arbeitskopie) @@ -26,6 +26,7 @@ #include <stdlib.h> #include <limits.h> #include "flash.h" +#include "programmer.h"
/* loops per microsecond */ static unsigned long micro = 1; @@ -89,6 +90,7 @@ unsigned long count = 1000; unsigned long timeusec, resolution; int i, tries = 0; + char *delayloops;
msg_pinfo("Calibrating delay loop... "); resolution = measure_os_delay_resolution(); @@ -98,6 +100,18 @@ msg_pinfo("OS timer resolution is unusable. "); }
+ delayloops = extract_programmer_param("delayloops"); + if (delayloops) { + micro = strtoul(delayloops, NULL, 0); + free(delayloops); + if (micro == 0) { + /* The delay calibration function is void, we have to + * recover instead of throwing an error. + */ + micro = 1; + } + } + recalibrate: count = 1000; while (1) {