- added patch by Øyvind Harboe to Intel Hex Start Segment Address Record (Type 3)
[openocd.git] / src / target / image.c
index 5ecbb81d10fb0cb8acfdfad6e178a0799acf00a4..a1a2a441eda92b6bc83da619950a3ae3bf1b427e 100644 (file)
@@ -265,6 +265,19 @@ int image_ihex_buffer_complete(image_t *image)
                                full_address = (full_address & 0xffff) | (upper_address << 4);
                        }
                }
+               else if (record_type == 3) /* Start Segment Address Record */
+               {
+                       u32 dummy;
+                       
+                       /* "Start Segment Address Record" will not be supported */
+                       /* but we must consume it, and do not create an error.  */
+                       while (count-- > 0)
+                       {
+                               sscanf(&lpszLine[bytes_read], "%2x", &dummy);
+                               cal_checksum += (u8)dummy;
+                               bytes_read += 2;
+                       }
+               }
                else if (record_type == 4) /* Extended Linear Address Record */
                {
                        u16 upper_address;
@@ -578,6 +591,18 @@ int image_mot_buffer_complete(image_t *image)
                                full_address++;
                        }
                }
+               else if (record_type == 5)
+               {
+                       /* S5 is the data count record, we ignore it */
+                       u32 dummy;
+                       
+                       while (count-- > 0)
+                       {
+                               sscanf(&lpszLine[bytes_read], "%2x", &dummy);
+                               cal_checksum += (u8)dummy;
+                               bytes_read += 2;
+                       }
+               }
                else if (record_type >= 7 && record_type <= 9)
                {
                        /* S7, S8, S9 - ending records for 32, 24 and 16bit */
@@ -821,6 +846,7 @@ int image_read_section(image_t *image, int section, u32 offset, u32 size, u8 *bu
                                        IMAGE_MEMORY_CACHE_SIZE, image_memory->cache) != ERROR_OK)
                                {
                                        free(image_memory->cache);
+                                       image_memory->cache = NULL;
                                        return ERROR_IMAGE_TEMPORARILY_UNAVAILABLE;
                                }
                                image_memory->cache_address = address & ~(IMAGE_MEMORY_CACHE_SIZE - 1);
@@ -909,7 +935,10 @@ int image_close(image_t *image)
                fileio_close(&image_ihex->fileio);
                
                if (image_ihex->buffer)
+               {
                        free(image_ihex->buffer);
+                       image_ihex->buffer = NULL;
+               }
        }
        else if (image->type == IMAGE_ELF)
        {
@@ -918,17 +947,26 @@ int image_close(image_t *image)
                fileio_close(&image_elf->fileio);
 
                if (image_elf->header)
+               {
                        free(image_elf->header);
+                       image_elf->header = NULL;
+               }
 
                if (image_elf->segments)
+               {
                        free(image_elf->segments);
+                       image_elf->segments = NULL;
+               }
        }
        else if (image->type == IMAGE_MEMORY)
        {
                image_memory_t *image_memory = image->type_private;
                
                if (image_memory->cache)
+               {
                        free(image_memory->cache);
+                       image_memory->cache = NULL;
+               }
        }
        else if (image->type == IMAGE_SRECORD)
        {
@@ -937,7 +975,10 @@ int image_close(image_t *image)
                fileio_close(&image_mot->fileio);
                
                if (image_mot->buffer)
+               {
                        free(image_mot->buffer);
+                       image_mot->buffer = NULL;
+               }
        }
        else if (image->type == IMAGE_BUILDER)
        {
@@ -946,14 +987,21 @@ int image_close(image_t *image)
                for (i = 0; i < image->num_sections; i++)
                {
                        free(image->sections[i].private);
+                       image->sections[i].private = NULL;
                }
        }
 
        if (image->type_private)
+       {
                free(image->type_private);
+               image->type_private = NULL;
+       }
        
        if (image->sections)
+       {
                free(image->sections);
+               image->sections = NULL;
+       }
        
        return ERROR_OK;
 }
@@ -988,3 +1036,4 @@ int image_calculate_checksum(u8* buffer, u32 nbytes, u32* checksum)
        return ERROR_OK;
 }
 
+

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)