Skip to content

Commit

Permalink
Copy code to ITCM_RAM
Browse files Browse the repository at this point in the history
  • Loading branch information
blckmn committed Jul 10, 2017
1 parent 7a8a2d1 commit ff01735
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/main/fc/fc_init.c
Expand Up @@ -240,6 +240,12 @@ void spiPreInit(void)

void init(void)
{
/* Load functions into ITCM RAM */
extern unsigned char critical_code_start;
extern unsigned char critical_code_end;
extern unsigned char critical_code;
memcpy(&critical_code_start, &critical_code, (int) (&critical_code_end - &critical_code_start));

#ifdef USE_HAL_DRIVER
HAL_Init();
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/main/target/link/stm32_flash_f722.ld
Expand Up @@ -22,8 +22,9 @@ ENTRY(Reset_Handler)
/* Specify the memory areas */
MEMORY
{
ITCM_ISR (rx) : ORIGIN = 0x00000000, LENGTH = 1K
ITCM_RAM (rx) : ORIGIN = 0x00000400, LENGTH = 15K

ITCM_RAM (rx) : ORIGIN = 0x00000000, LENGTH = 16K
ITCMFL (rx) : ORIGIN = 0x00200000, LENGTH = 16K
ITCMFL1 (rx) : ORIGIN = 0x00208000, LENGTH = 480K

Expand Down
4 changes: 4 additions & 0 deletions src/main/target/link/stm32_flash_f7_split.ld
Expand Up @@ -35,12 +35,16 @@ SECTIONS
} >FLASH

/* Critical program code goes into ITCM RAM */
/* Copy specific fast-executing code to ITCM RAM */
critical_code = LOADADDR(.critical_code);
.critical_code :
{
. = ALIGN(4);
critical_code_start = .;
*(.critical_code)
*(.critical_code*)
. = ALIGN(4);
critical_code_end = .;
} >ITCM_RAM AT >FLASH1

/* The program code and other data goes into FLASH */
Expand Down

0 comments on commit ff01735

Please sign in to comment.