Hi, I'm developing a product based on the STM32, we're using openocd for
debugging
and production programming, so it's important to have things working right.
I was having trouble when I added a global initialised variable, which caused
a .data section to be created after the .text with padding before the next
section,
which contains setup data. What happened was that the padding would start at the
beginning of the .text section offset by the number of bytes of .data, which
gave me one or two vectors and garbage instead of actual code.
I tracked it down to where the padding is added to the assembled image, it
needs to use the offset from the current buffer position rather than the start
of the buffer. Also, size_read is calculated in a weird way, generating negative
unsigned ints, which sometimes works depending on the way it gets optimised.
Hope this is useful :)
Richard M.
Index: flash.c
===================================================================
--- flash.c (revision 919)
+++ flash.c (working copy)
@@ -1052,9 +1052,8 @@
{
u32 size_read;
- if (buffer_size - run_size <=
image->sections[section].size - section_offset)
- size_read = buffer_size - run_size;
- else
+ 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,
@@ -1067,7 +1066,7 @@
/* 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;
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development