Skip to content

Commit edafefb

Browse files
committed
Migrate NUCLEO_F303K8 to Mbed OS 5 baremetal
* Use two memory regions in ARM toolchain linker file to support Microlib * Replace `target.default_lib` with `target.c_lib` * Specify supported lib sizes per toolchain * Add support for Mbed OS 5 * Increase RAM size from 12KB to 16KB as per MCU datasheet
1 parent 532654e commit edafefb

File tree

4 files changed

+45
-15
lines changed

4 files changed

+45
-15
lines changed

targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303x8/device/TOOLCHAIN_ARM_STD/stm32f303x8.sct

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,49 @@
2828
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3030

31+
#if !defined(MBED_APP_START)
32+
#define MBED_APP_START 0x08000000
33+
#endif
34+
35+
; STM32F303K8: 64KB FLASH (0x10000)
36+
#if !defined(MBED_APP_SIZE)
37+
#define MBED_APP_SIZE 0x10000
38+
#endif
39+
40+
#if !defined(MBED_RAM_START)
41+
#define MBED_RAM_START 0x20000000
42+
#endif
43+
44+
;16KB SRAM (0x4000)
45+
#if !defined(MBED_RAM_SIZE)
46+
#define MBED_RAM_SIZE 0x4000
47+
#endif
48+
49+
3150
#if !defined(MBED_BOOT_STACK_SIZE)
32-
#define MBED_BOOT_STACK_SIZE 0x400
51+
#define MBED_BOOT_STACK_SIZE 0x400
3352
#endif
3453

35-
#define Stack_Size MBED_BOOT_STACK_SIZE
54+
; 60 Non-Core vectors + 16 ARM Core System Handler Vectors vectors + reserved areas = 98 vectors 392 bytes (0x188) to be reserved in RAM
55+
#define VECTOR_SIZE 0x188
56+
57+
#define RAM_FIXED_SIZE (MBED_BOOT_STACK_SIZE+VECTOR_SIZE)
3658

37-
; STM32F303K8: 64KB FLASH (0x10000) + 12KB SRAM (0x3000)
38-
LR_IROM1 0x08000000 0x10000 { ; load region size_region
59+
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
3960

40-
ER_IROM1 0x08000000 0x10000 { ; load address = execution address
61+
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address
4162
*.o (RESET, +First)
4263
*(InRoot$$Sections)
4364
.ANY (+RO)
4465
}
4566

46-
; 98 vectors = 392 bytes (0x188) to be reserved in RAM
47-
RW_IRAM1 (0x20000000+0x188) (0x3000-0x188-Stack_Size) { ; RW data
67+
RW_IRAM1 (MBED_RAM_START+VECTOR_SIZE) (MBED_RAM_SIZE-VECTOR_SIZE) { ; RW data
4868
.ANY (+RW +ZI)
4969
}
5070

51-
ARM_LIB_STACK (0x20000000+0x3000) EMPTY -Stack_Size { ; stack
71+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
5272
}
53-
}
5473

74+
ARM_LIB_STACK (MBED_RAM_START+MBED_RAM_SIZE) EMPTY -MBED_BOOT_STACK_SIZE { ; stack
75+
}
76+
}

targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303x8/device/TOOLCHAIN_GCC_ARM/STM32F303X8.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77
STACK_SIZE = MBED_BOOT_STACK_SIZE;
88

9+
/* 60 Non-Core vectors + 16 ARM Core System Handler Vectors vectors + reserved areas = 392 bytes (0x188) to be reserved in RAM */
910
MEMORY
1011
{
1112
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
1213
CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 4K
13-
RAM (rwx) : ORIGIN = 0x20000188, LENGTH = 12K - 0x188
14+
RAM (rwx) : ORIGIN = 0x20000188, LENGTH = 16K - 0x188
1415
}
1516

1617
/* Linker script to place sections and symbol values. Should be used together

targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303x8/device/TOOLCHAIN_IAR/stm32f303x8.icf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ define symbol __region_ROM_end__ = 0x0800FFFF;
66
define symbol __region_CCMRAM_start__ = 0x10000000;
77
define symbol __region_CCMRAM_end__ = 0x10000FFF;
88

9-
/* [RAM = 12kb = 0x3000] Vector table dynamic copy: 98 vectors = 392 bytes (0x188) to be reserved in RAM */
9+
/* [RAM = 16kb = 0x4000] Vector table dynamic copy: 98 vectors = 392 bytes (0x188) to be reserved in RAM */
1010
define symbol __NVIC_start__ = 0x20000000;
1111
define symbol __NVIC_end__ = 0x20000187; /* No need to add 4 more bytes to be aligned on 8 bytes */
1212
define symbol __region_RAM_start__ = 0x20000188;
13-
define symbol __region_RAM_end__ = 0x20002FFF;
13+
define symbol __region_RAM_end__ = 0x20003FFF;
1414

1515
/* Memory regions */
1616
define memory mem with size = 4G;

targets/targets.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3630,12 +3630,19 @@
36303630
}
36313631
},
36323632
"overrides": {
3633-
"lse_available": 0
3633+
"lse_available": 0,
3634+
"boot-stack-size": "0x400",
3635+
"tickless-from-us-ticker": true
36343636
},
36353637
"detect_code": [
36363638
"0775"
36373639
],
3638-
"default_lib": "small",
3640+
"supported_c_libs": {
3641+
"arm": ["std", "small"],
3642+
"gcc_arm": ["std", "small"],
3643+
"iar": ["std"]
3644+
},
3645+
"c_lib": "small",
36393646
"device_has_add": [
36403647
"ANALOGOUT",
36413648
"CAN",
@@ -3645,7 +3652,7 @@
36453652
"LPTICKER"
36463653
],
36473654
"release_versions": [
3648-
"2"
3655+
"2", "5"
36493656
],
36503657
"device_name": "STM32F303K8"
36513658
},

0 commit comments

Comments
 (0)