cancel
Showing results for 
Search instead for 
Did you mean: 

Unknown data at the end of the hex file

chun-ho
Associate
Posted on September 20, 2015 at 08:31

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
2 REPLIES 2
Posted on September 20, 2015 at 12:50

It's the 0x38 bytes of initialize statics it's copying to RAM (0x20000000), when the processor starts the RAM is ''random'', your program has initialized variable that have some values, some zeros, and these must be copied from FLASH.

ie

int foo = 12345; // some global value (ie RW)

int bar[256]; // some global array that is zero'd (ie ZI)

Look at the ''Program Size'' line emitted by the Linker in the Build Log window, and at the back end of the .MAP file.

Instead of using the AT directive, you need to modify the scatter file (.SCT) to keep the changeable flash variables outside the primary load region, by creating another load region and section, and directing them into that. Or by creating a location outside of the scope of the linker, ie by shrinking IROM1, and have your code check if the content is erased FLASH (ie 0xFFFFFFFF) and writing in your new, or default value(s). If you have a bunch of the them, use a structure with an integrity check, it will  be easier to manage.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chun-ho
Associate
Posted on September 23, 2015 at 18:07

The problem have been solved, thanks for your help 🙂

Modifications i have made: [Original scatter file]

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x08000000 0x00010000 { ; load region size_region
ER_IROM1 0x08000000 0x00010000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00002000 { ; RW data
.ANY (+RW +ZI)
}
}

[Modified file]

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x08000000 0x0000FC00 { ; load region size_region
ER_IROM1 0x08000000 0x0000FC00 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00002000 { ; RW data
.ANY (+RW +ZI)
}
}
LR_SETTING_BYTES 0x0800FC00 0x00000400 {
ER_SETTING_BYTES 0x0800FC00 0x00000400 {
*(__settingByte)
}
}

To store data, use:

const
uint16_t defaultSettingByte __attribute__((section(
''__settingByte''
), used)) = 0x0073;