Anastasia Klimchuk has uploaded this change for review.

View Change

dummyflasher: Enable higher frequency emulation

The patch also adds a section on a manpage to explain the freq
parameter in dummyflasher.

Change-Id: Iaca5d95f8f977bf0c2283c6458d8977e6ce70251
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
---
M doc/classic_cli_manpage.rst
M dummyflasher.c
2 files changed, 14 insertions(+), 5 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/23/84423/1
diff --git a/doc/classic_cli_manpage.rst b/doc/classic_cli_manpage.rst
index e2ce684..ba77b7a 100644
--- a/doc/classic_cli_manpage.rst
+++ b/doc/classic_cli_manpage.rst
@@ -616,6 +616,15 @@
syntax where ``state`` is ``yes`` or ``no`` (default value). ``yes`` means active state of the pin implies that chip is
write-protected (on real hardware the pin is usually negated, but not here).

+**Frequency**
+ Frequency can be emulated in ``Hz`` (default), ``KHz``, or ``MHz`` (not case sensitive).
+ If ``freq`` parameter is passed in from command line, commands will delay for certain time before returning,
+ so that to emulate the requested frequency.
+
+ The delay is calculated based on the assumption that we only work with bytes and transfer at 1 bit/Hz::
+
+ flashrom -p dummy:emulate=W25Q128FV,freq=64mhz
+

nic3com, nicrealtek, nicnatsemi, nicintel, nicintel_eeprom, nicintel_spi, gfxnvidia, ogp_spi, drkaiser, satasii, satamv, atahpt, atavia, atapromise, it8212 programmers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/dummyflasher.c b/dummyflasher.c
index cf4ca03..283e0c6 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -55,7 +55,7 @@
uint8_t emu_status_len; /* number of emulated status registers */
/* If "freq" parameter is passed in from command line, commands will delay
* for this period before returning. */
- unsigned long int delay_us;
+ unsigned long long delay_ns;
unsigned int emu_max_byteprogram_size;
unsigned int emu_max_aai_size;
unsigned int emu_jedec_se_size;
@@ -901,7 +901,7 @@
msg_pspew(" 0x%02x", readarr[i]);
msg_pspew("\n");

- default_delay((writecnt + readcnt) * emu_data->delay_us);
+ default_delay(((writecnt + readcnt) * emu_data->delay_ns) / 1000);
return 0;
}

@@ -1128,7 +1128,7 @@
/* frequency to emulate in Hz (default), KHz, or MHz */
tmp = extract_programmer_param_str(cfg, "freq");
if (tmp) {
- unsigned long int freq;
+ unsigned long long freq;
char *units = tmp;
char *end = tmp + strlen(tmp);

@@ -1172,7 +1172,7 @@
return 1;
}
/* Assume we only work with bytes and transfer at 1 bit/Hz */
- data->delay_us = (1000000 * 8) / freq;
+ data->delay_ns = (1000000000ull * 8) / freq;
}
free(tmp);

@@ -1402,7 +1402,7 @@
return 1;
}
data->emu_chip = EMULATE_NONE;
- data->delay_us = 0;
+ data->delay_ns = 0;
data->spi_write_256_chunksize = 256;

msg_pspew("%s\n", __func__);

To view, visit change 84423. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: Iaca5d95f8f977bf0c2283c6458d8977e6ce70251
Gerrit-Change-Number: 84423
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>