ResetISR() is the first call after a reset.
__attribute__ ((section(".after_vectors")))
void
ResetISR(void) {
//
// Copy the data sections from flash to SRAM.
//
unsigned int LoadAddr, ExeAddr, SectionLen;
unsigned int *SectionTableAddr;
// Load base address of Global Section Table
SectionTableAddr = &__data_section_table;
// Copy the data sections from flash to SRAM.
while (SectionTableAddr < &__data_section_table_end) {
LoadAddr = *SectionTableAddr++;
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
data_init(LoadAddr, ExeAddr, SectionLen);
}
// At this point, SectionTableAddr = &__bss_section_table;
// Zero fill the bss segment
while (SectionTableAddr < &__bss_section_table_end) {
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
bss_init(ExeAddr, SectionLen);
}
#if defined (__USE_CMSIS) || defined (__USE_LPCOPEN)
SystemInit();
#endif
#if defined (__cplusplus)
//
// Call C++ library initialisation
//
__libc_init_array();
#endif
#if defined (__REDLIB__)
// Call the Redlib library, which in turn calls main()
__main() ;
#else
main();
#endif
//
// main() shouldn't return, but if it does, we'll just enter an
infinite loop
//
while (1) {
;
}
}
There isn't any weak function call, anyway I can add my own.
> You can fiddle with either the linker script or the ResetISR function to
> avoid clearing the sdram bss (and copying the sdram initialised data)
> during ResetISR, and do it manually after initialising the ram.
Yes, this is another possibility.
You didn't mention NOLOAD (noinit). It seems to me another good approach
for my problem.
> Often, however, it is a good idea /not/ to use sdram for bss or data.
> Use the internal ram (DTC ram if possible, or OCRAM - depending on the
> particular chip) for that. Put your heap in sdram, along with other big
> buffers such as network buffers, FreeRTOS heap, etc. These can all be
> initialised later once the ram is configured. And you can mark any
> large statically allocated arrays or structures with a section attribute
> for a "noinit" section of the sdram.
I have some images saved in a SDCard and I have to show them on the
display in some cases. I have plenty of SDRAM for other purposes
(framebuffer, for example) so I thought, why read images from SDCard
every time I have to show them?
At startup, I copy images from SDCard to SDRAM and later I can access
images directly from SDRAM.
The maximum size of all images is 2MB and I have this free space on SDRAM.