-
-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optim: vector table moved to RAM on STM32 MCUs (#507)
* optim: vectors moved to RAM on STM32 MCUs * fix: Invalid lib_dep removed
- Loading branch information
Showing
18 changed files
with
108 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
#if defined(PLATFORM_STM32) | ||
|
||
#include <stm32_def.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
|
||
|
||
void __attribute__((used)) copy_functions_to_ram(void) | ||
{ | ||
/* Copy RAM_CODE section into RAM. | ||
* NOTE: vectors are the first and then other code. | ||
* Check variants/ldscript_gen.ld file. | ||
*/ | ||
extern uint8_t ram_code_start; | ||
extern uint8_t ram_code_end; | ||
extern uint8_t ram_code; | ||
memcpy(&ram_code_start, &ram_code, (size_t) (&ram_code_end - &ram_code_start)); | ||
} | ||
|
||
void __attribute__((constructor(102))) __attribute__((used)) init_vectors(void) | ||
{ | ||
copy_functions_to_ram(); | ||
|
||
/** Reset vector location | ||
* | ||
* g_pfnVectors variable comes from the system startup files and | ||
* must always point to beginning of the vectors table where | ||
* stack pointer is the first word and second is the reset vector. | ||
* Vector table is automatically aligned by the linker command file. | ||
*/ | ||
extern uint32_t g_pfnVectors; | ||
SCB->VTOR = (__IO uint32_t) &g_pfnVectors; | ||
} | ||
|
||
extern "C" | ||
void __attribute__((used)) initVariant(void) | ||
{ | ||
/* This can be used to run some init before \ref setup() */ | ||
} | ||
|
||
#endif // PLATFORM_STM32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
***************************************************************************** | ||
** | ||
|
||
** Abstract : Linker script for STM32F303CC Device with | ||
** 256KByte FLASH, 40KByte RAM, 8KByte CCMRAM | ||
** | ||
|
||
/* Specify the memory areas */ | ||
MEMORY | ||
{ | ||
RAM_CODE (rx) : ORIGIN = 0x20000000, LENGTH = 1K | ||
RAM_DATA (xrw) : ORIGIN = 0x20000000 + LENGTH(RAM_CODE), LENGTH = 40K - LENGTH(RAM_CODE) | ||
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 8K | ||
FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 256K - 0x8000 | ||
} | ||
|
||
INCLUDE "variants/ldscript_gen.ld" |