summaryrefslogtreecommitdiff
path: root/util/uut/main.c
diff options
context:
space:
mode:
authorCHLin <CHLIN56@nuvoton.com>2018-06-11 14:13:12 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-06-15 10:57:33 -0700
commitdb1f369e08cdf839bce6525bc20a5488a5b14ad0 (patch)
treee6b62e0d66217dd6f47c7281b78093565836380b /util/uut/main.c
parentb7ff14aa41db159249acf68731eb64499d6bcfd0 (diff)
downloadchrome-ec-db1f369e08cdf839bce6525bc20a5488a5b14ad0.tar.gz
util: UUT: skip writing empty segment to save the flash time
In order to reduce the time of programming EC image, the UUT in this CL checks each segment before it is written. If the content of the segment is empty (ie. all 0xFF), the UUT will not write the empty data to flash but only erase it. BRANCH=none BUG=none TEST=No build errors for make buildall. TEST= ------------------------------------------------------------------------ 1. Connect the servo connector (J24) on npcx7 EVB to servo board v2 via flex cable. 2. Manually turn the switch SW1.6 to "ON" on npcx7 EVB. 3. Reset ec by issuing Power-Up or VCC1_RST reset. 4. Manually turn the switch SW1.6 to "OFF" on npcx7 EVB. 5. Move npcx7_evb from array BOARDS_NPCX_7M7X_JTAG to BOARDS_NPCX_UUT in flash_ec. 6. "./util/flash_ec --board=npcx7_evb", make sure ec boots up. (Note: "ec_reset" must be removed in line 1051 of flash_ec) 5."time ./util/flash_ec --board=cheza" flash time before this CL: 1m26.489s flash time after this CL : 0m36.760s 6. Dump the flash content via JTAG, make sure it is the same as cheza's ec.bin. Change-Id: Id5ee2bd3a03d13e9b693267b03613c9f2847e0c8 Signed-off-by: CHLin <CHLIN56@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/1095057 Commit-Ready: CH Lin <chlin56@nuvoton.com> Tested-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'util/uut/main.c')
-rw-r--r--util/uut/main.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/util/uut/main.c b/util/uut/main.c
index 251ee1bb4a..64a84e2725 100644
--- a/util/uut/main.c
+++ b/util/uut/main.c
@@ -118,28 +118,59 @@ static bool image_auto_write(uint32_t offset, uint8_t *buffer,
uint32_t data_buf[4];
uint32_t addr, chunk_remain, file_seg, flash_index, seg;
uint32_t count, percent, total;
+ uint32_t i;
flash_index = offset;
/* Monitor tag */
data_buf[0] = MONITOR_HDR_TAG;
- /* Where the source(RAM) address the firmware stored. */
- data_buf[2] = FIRMWARE_START_ADDR;
file_seg = file_size;
total = 0;
while (file_seg) {
seg = (file_seg > FIRMWARE_SEGMENT) ?
FIRMWARE_SEGMENT : file_seg;
+ /*
+ * Check if the content of the segment is all 0xff.
+ * If yes, there is no need to write.
+ * Call the monitor to erase the segment only for
+ * time efficiency.
+ */
+ for (i = 0; i < seg && buffer[i] == 0xFF; i++)
+ ;
+ if (i == seg) {
+ data_buf[1] = seg;
+ /*
+ * Set src_addr = 0 as a flag. When the monitor read 0
+ * from this field, it will do sector erase only.
+ */
+ data_buf[2] = 0;
+ data_buf[3] = flash_index;
+ opr_write_chunk((uint8_t *)data_buf, MONITOR_HDR_ADDR,
+ sizeof(data_buf));
+ if (opr_execute_return(MONITOR_ADDR) != true)
+ return false;
+ file_seg -= seg;
+ flash_index += seg;
+ buffer += seg;
+ total += seg;
+ percent = total * 100 / file_size;
+ printf("\r[%d%%] %d/%d", percent, total, file_size);
+ fflush(stdout);
+ continue;
+ }
chunk_remain = seg;
addr = FIRMWARE_START_ADDR;
/* the size to be programmed */
data_buf[1] = seg;
+ /* The source(RAM) address where the firmware is stored. */
+ data_buf[2] = FIRMWARE_START_ADDR;
/*
* The offset of the flash where the segment to be programmed.
*/
data_buf[3] = flash_index;
/* Write the monitor header to RAM */
- opr_write_chunk((uint8_t *)data_buf, MONITOR_HDR_ADDR, 16);
+ opr_write_chunk((uint8_t *)data_buf, MONITOR_HDR_ADDR,
+ sizeof(data_buf));
while (chunk_remain) {
count = (chunk_remain > MAX_RW_DATA_SIZE) ?
MAX_RW_DATA_SIZE : chunk_remain;
@@ -160,6 +191,9 @@ static bool image_auto_write(uint32_t offset, uint8_t *buffer,
flash_index += seg;
}
printf("\n");
+ /* Clear the UUT header tag */
+ data_buf[0] = 0;
+ opr_write_chunk((uint8_t *)data_buf, MONITOR_HDR_ADDR, 4);
return true;
}