2016-04-25 07:26 AM
Hi
My task is to execute a code from RAM instead of Flash but i dont know how can i able to do it . i am using f429 discovery.Could anyone help me ?Thanks2016-04-25 09:00 AM
Who assigns these tasks?
So what are your choices here? Copy some amount of code the RAM and call it, or specify load regions within the linker script or scatter file to place specific functions into RAM when building the image?typedef int (*pFunction)(void);
void RamCode(void)
{
static const uint16_t Code[] = { 0xF04F, 0x007B, 0x4770 }; // payload
uint8_t Buffer[16]; // as big as required
pFunction RunCode;
memcpy(Buffer, Code, sizeof(Code)); // Copy code
RunCode = (pFunction)&Buffer[1]; // +1 for Thumb code
printf(''%d
'',RunCode());
}
2016-04-25 09:03 AM
/**
* @brief Enable or disable the power down mode during RUN mode .
* @param NewState: new state of the power down mode during RUN mode.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
__ramfunc void RAM_FLASH_RUNPowerDownCmd(FunctionalState NewState)
{
if (NewState != DISABLE)
{
/* Unlock the RUN_PD bit */
FLASH->PDKEYR = FLASH_PDKEY1;
FLASH->PDKEYR = FLASH_PDKEY2;
/* Set the RUN_PD bit in FLASH_ACR register to put Flash in power down mode */
FLASH->ACR |= (uint32_t)FLASH_ACR_RUN_PD;
}
else
{
/* Clear the RUN_PD bit in FLASH_ACR register to put Flash in idle mode */
FLASH->ACR &= (uint32_t)(~(uint32_t)FLASH_ACR_RUN_PD);
}
}
You can do this sort of thing in IAR, and perhaps similar things in Keil or GNU/GCC by using #pragma or attribute type things to direct a subset of the code into RAM sections/segments.
2016-04-25 10:54 AM
Hi clive,
Its about specify ta region in linker scipt for a specific functions into RAM when building the image.i am not using Keil or IAR. i am using eclipse to develop project. kindly help me how can i specify a location in liker scirpt.Thank you for the code.2016-04-25 12:37 PM
Which eclipse? AC6? Or clean distribution? With or without ARM plugin?
Open linker script Find definition data section, copy it, change names for your purpose for example ram_func main section name and elemens, adresses, In startup or in source code write code for ram_func section. Freddie Chopin provide very good startup for this (multiple copy loop). check example for LPC4XXX.