Commit 61f3d4b7 authored by Andreas Fritiofson's avatar Andreas Fritiofson Committed by Øyvind Harboe
Browse files

target: increase chunk size in dump_image



Replace the big stack-allocated buffer with a much bigger heap-allocated.
There was no explanation for the apparently arbitrary chunk size, and
performance was improved by increasing it, leveling out at about 4k.

Change-Id: I3b06d4469092ec8d89d0ce05bff0b7cf213c5062
Signed-off-by: default avatarAndreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/404


Tested-by: jenkins
Reviewed-by: default avatarMarti Bolivar <mbolivar@leaflabs.com>
Reviewed-by: default avatarØyvind Harboe <oyvindharboe@gmail.com>
parent fce4ac57
...@@ -2797,7 +2797,7 @@ COMMAND_HANDLER(handle_load_image_command) ...@@ -2797,7 +2797,7 @@ COMMAND_HANDLER(handle_load_image_command)
COMMAND_HANDLER(handle_dump_image_command) COMMAND_HANDLER(handle_dump_image_command)
{ {
struct fileio fileio; struct fileio fileio;
uint8_t buffer[560]; uint8_t *buffer;
int retval, retvaltemp; int retval, retvaltemp;
uint32_t address, size; uint32_t address, size;
struct duration bench; struct duration bench;
...@@ -2809,17 +2809,23 @@ COMMAND_HANDLER(handle_dump_image_command) ...@@ -2809,17 +2809,23 @@ COMMAND_HANDLER(handle_dump_image_command)
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], address); COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], address);
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], size); COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], size);
uint32_t buf_size = (size > 4096) ? 4096 : size;
buffer = malloc(buf_size);
if (!buffer)
return ERROR_FAIL;
retval = fileio_open(&fileio, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY); retval = fileio_open(&fileio, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY);
if (retval != ERROR_OK) if (retval != ERROR_OK) {
free(buffer);
return retval; return retval;
}
duration_start(&bench); duration_start(&bench);
retval = ERROR_OK;
while (size > 0) while (size > 0)
{ {
size_t size_written; size_t size_written;
uint32_t this_run_size = (size > 560) ? 560 : size; uint32_t this_run_size = (size > buf_size) ? buf_size : size;
retval = target_read_buffer(target, address, this_run_size, buffer); retval = target_read_buffer(target, address, this_run_size, buffer);
if (retval != ERROR_OK) if (retval != ERROR_OK)
{ {
...@@ -2836,6 +2842,8 @@ COMMAND_HANDLER(handle_dump_image_command) ...@@ -2836,6 +2842,8 @@ COMMAND_HANDLER(handle_dump_image_command)
address += this_run_size; address += this_run_size;
} }
free(buffer);
if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK))
{ {
int filesize; int filesize;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment