Hello,
Thanks for reply
I dont want to run some functions from SRAM. My target is copy whole data from Flash to SRAM using __TEXT_END symbol that can give me the size of the Flash data and copied to SRAM specific section (user defined) and then jump to the function which is copied into SRAM from FLASH.
example:
typedef void (*tRamLoop)(void);
extern const uint32_t __TEXT_END;
extern const uint32_t __SSRAM_LOOP_START_ADDR; /* from linker script */
extern const uint32_t __SSRAM_LOOP_SIZE; /* from linker script */
extern const uint32_t __start;
/**
* Main bl handler function (running in ram)
* \return void
*/
static void ramLoop()
{
/* Start the scheduler */
vTaskStartScheduler();
}
/**
* Function runs in flash and copies codebase from flash
* to ram in order to execute the main bl function in ram.
* \return void
*/
static void copyToRam()
{
unsigned long cntl = (unsigned long)&__TEXT_END;
unsigned long cnts = (unsigned long)&__start;
unsigned long *psrc=(unsigned long *)&__start;
unsigned long *pDst = (unsigned long *)0;
unsigned long dst = (unsigned long)&__SSRAM_LOOP_START_ADDR;
unsigned long size = (unsigned long)&__SSRAM_LOOP_SIZE;
/* size of the text in flash */
unsigned long textSize = cntl - cnts;
tRamLoop pRamLoop = NULL;
/* Make sure RAM offset is a multiple of 8 */
while (dst % 8 != 0)
{
dst++;
}
/* Calculate where to jump */
pRamLoop = (tRamLoop)(ramLoop + dst - cnts);
/* Copy to ram */
pDst = (unsigned long *)dst;
textSize /= 4;
while (textSize--)
{
*pDst++ = *pSrc++;
}
/* Jump */
pRamLoop();
}
copyToRam function is called in the main after board initialization.