summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-17 19:17:24 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-17 19:17:24 +0000
commit8ca8313c4388b75efefc50ee07810b31c8ef81da (patch)
treefd2150ae65b25798f4b7e471006a0b442ffb9430 /src
parent71f4a6e0a67ae7f3da6c30f4ea401d9957a35f0e (diff)
downloadopenocd+libswd-8ca8313c4388b75efefc50ee07810b31c8ef81da.tar.gz
openocd+libswd-8ca8313c4388b75efefc50ee07810b31c8ef81da.tar.bz2
openocd+libswd-8ca8313c4388b75efefc50ee07810b31c8ef81da.tar.xz
openocd+libswd-8ca8313c4388b75efefc50ee07810b31c8ef81da.zip
Richard <news@muppet.plus.com> fixed bug in padding code
git-svn-id: svn://svn.berlios.de/openocd/trunk@923 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/flash/flash.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/flash/flash.c b/src/flash/flash.c
index 71d054f5..5193ce9a 100644
--- a/src/flash/flash.c
+++ b/src/flash/flash.c
@@ -1052,10 +1052,9 @@ int flash_write(target_t *target, image_t *image, u32 *written, int erase)
{
u32 size_read;
- if (buffer_size - run_size <= image->sections[section].size - section_offset)
- size_read = buffer_size - run_size;
- else
- size_read = image->sections[section].size - section_offset;
+ size_read = run_size - buffer_size;
+ if (size_read > image->sections[section].size - section_offset)
+ size_read = image->sections[section].size - section_offset;
if ((retval = image_read_section(image, section, section_offset,
size_read, buffer + buffer_size, &size_read)) != ERROR_OK || size_read == 0)
@@ -1067,7 +1066,7 @@ int flash_write(target_t *target, image_t *image, u32 *written, int erase)
/* see if we need to pad the section */
while (padding[section]--)
- buffer[size_read++] = 0xff;
+ (buffer+buffer_size)[size_read++] = 0xff;
buffer_size += size_read;
section_offset += size_read;