2015-09-19 11:31 PM
2015-09-20 03:50 AM
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.
ieint 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.2015-09-23 09:07 AM
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;