Skip to content

Commit 554b125

Browse files
authored
Merge pull request ARMmbed#106 from linlingao/fix_iar_linker
fix IAR linker script to conditionally include signature
2 parents 69f7ddf + cec7c83 commit 554b125

File tree

4 files changed

+74
-23
lines changed

4 files changed

+74
-23
lines changed

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/device/TOOLCHAIN_ARM_STD/CC3220SF.sct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#if defined(MBED_APP_SIZE)
4343
#define ROM_EXEC_SIZE MBED_APP_SIZE
4444
#else
45-
#define ROM_EXEC_SIZE (ROM_SIZE- (MBED_APP_START - ROM_START)
45+
#define ROM_EXEC_SIZE (ROM_SIZE- (MBED_APP_START - ROM_START))
4646
#endif
4747
#endif
4848
#else

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/device/TOOLCHAIN_GCC_ARM/gcc_arm.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#if defined(MBED_APP_SIZE)
3636
#define ROM_EXEC_SIZE MBED_APP_SIZE
3737
#else
38-
#define ROM_EXEC_SIZE (ROM_SIZE- (MBED_APP_START - ROM_START)
38+
#define ROM_EXEC_SIZE (ROM_SIZE- (MBED_APP_START - ROM_START))
3939
#endif
4040
#endif
4141
#else

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/device/TOOLCHAIN_IAR/CC3220SF.icf

Lines changed: 72 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,94 @@ define symbol FLASH_HDR_SIZE = 0x800;
77
define symbol RAM_START = 0x20000000;
88
define symbol RAM_SIZE = 0x40000;
99
define symbol VECTORS = 195; /* This value must match NVIC_NUM_VECTORS */
10-
define symbol HEAP_SIZE = 0xA000;
1110

1211
/* Common - Do not change */
1312

14-
if (!isdefinedsymbol(MBED_APP_START)) {
15-
define symbol MBED_APP_START = (ROM_START + FLASH_HDR_SIZE);
13+
if (isdefinedsymbol(MBED_APP_START)) {
14+
/*
15+
* There're two cases if MBED_APP_START is defined.
16+
* Case 1: MBED_APP_START is defined as ROM_START, this happens when restrict_size is turned on, most likely for bootloader build.
17+
* In this build, include FLASH_HDR region.
18+
*/
19+
if (MBED_APP_START == ROM_START) {
20+
define symbol FLASH_HDR_INCLUDED = 1;
21+
if (isdefinedsymbol(MBED_APP_SIZE)) {
22+
define symbol ROM_EXEC_START = (ROM_START + FLASH_HDR_SIZE);
23+
define symbol ROM_EXEC_SIZE = (MBED_APP_SIZE - FLASH_HDR_SIZE);
24+
}
25+
}
26+
else {
27+
/*
28+
* Case 2: MBED_APP_START is defined as a value greater than ROM_START, this is most likely a build other than the bootloader. E.g., the MCC build.
29+
* In this build, exclude FLASH_HDR region. This workarounds an issue in managed boodloader MCC build where the jump address and stack pointer point to the cookie area
30+
*/
31+
define symbol FLASH_HDR_INCLUDED = 0;
32+
define symbol ROM_EXEC_START = MBED_APP_START;
33+
if (isdefinedsymbol(MBED_APP_SIZE)) {
34+
define symbol ROM_EXEC_SIZE= MBED_APP_SIZE;
35+
}
36+
else {
37+
define symbol ROM_EXEC_SIZE = (ROM_SIZE- (MBED_APP_START - ROM_START));
38+
}
39+
}
1640
}
17-
18-
if (!isdefinedsymbol(MBED_APP_SIZE)) {
19-
define symbol MBED_APP_SIZE = (ROM_SIZE - FLASH_HDR_SIZE);
41+
else {
42+
/*
43+
* MBED_APP_START is not defined. This is most likely a bootloader build, or other apps that do not require boodloader.
44+
* In this build, include FLASH_HDR region
45+
*/
46+
define symbol FLASH_HDR_INCLUDED = 1;
47+
define symbol ROM_EXEC_START = (ROM_START + FLASH_HDR_SIZE);
48+
if (isdefinedsymbol (MBED_APP_SIZE)) {
49+
define symbol ROM_EXEC_SIZE = (MBED_APP_SIZE - FLASH_HDR_SIZE);
50+
}
51+
else {
52+
define symbol ROM_EXEC_SIZE = (ROM_SIZE - FLASH_HDR_SIZE);
53+
}
2054
}
2155

56+
2257
/* Round up VECTORS_SIZE to 8 bytes */
2358
define symbol VECTORS_SIZE = ((VECTORS * 4) + 7) & ~7;
24-
define symbol RAM_REGION_START = RAM_START + VECTORS_SIZE;
25-
define symbol RAM_REGION_SIZE = RAM_SIZE - VECTORS_SIZE;
26-
define symbol ISR_STACK_SIZE = 0x400;
59+
60+
/* boot stack size*/
61+
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
62+
define symbol MBED_BOOT_STACK_SIZE = 0x400;
63+
}
64+
/* Place the boot stack at the top of the RAM */
65+
define symbol CSTACK_START = (RAM_START + RAM_SIZE - MBED_BOOT_STACK_SIZE);
66+
define symbol CSTACK_SIZE = MBED_BOOT_STACK_SIZE;
67+
68+
/* The rest of RAM */
69+
define symbol RAM_REGION_START = (RAM_START + VECTORS_SIZE);
70+
define symbol RAM_REGION_SIZE = (RAM_SIZE - VECTORS_SIZE - MBED_BOOT_STACK_SIZE);
2771

2872
define memory mem with size = 4G;
73+
/* ROM regions */
2974
define region FLASH_HDR_region = mem:[from FLASH_HDR_START size FLASH_HDR_SIZE];
30-
define region FLASH_region = mem:[from MBED_APP_START size MBED_APP_SIZE];
31-
define region RAM_region = mem:[from RAM_REGION_START size RAM_REGION_SIZE];
75+
define region FLASH_region = mem:[from ROM_EXEC_START size ROM_EXEC_SIZE];
3276

33-
//
34-
// Keep the debug header
35-
//
36-
keep {section .dbghdr};
37-
place at start of FLASH_HDR_region { readonly section .dbghdr };
77+
/* RAM regions */
78+
define region RAM_region = mem:[from RAM_REGION_START size RAM_REGION_SIZE];
79+
define region CSTACK_region = mem:[from CSTACK_START size CSTACK_SIZE];
3880

39-
define block CSTACK with alignment = 8, size = ISR_STACK_SIZE { };
40-
define block HEAP with alignment = 8, size = HEAP_SIZE { };
81+
if (FLASH_HDR_INCLUDED == 1) {
82+
keep {section .dbghdr};
83+
place in FLASH_HDR_region { readonly section .dbghdr };
84+
}
4185

4286
initialize by copy { readwrite };
4387
do not initialize { section .noinit };
4488

45-
place at address mem: MBED_APP_START { readonly section .intvec };
89+
place at address mem: ROM_EXEC_START { readonly section .intvec };
4690

4791
place in FLASH_region { readonly };
48-
place in RAM_region { readwrite,
49-
block CSTACK, block HEAP };
92+
93+
define symbol __size_cstack__ = MBED_BOOT_STACK_SIZE;
94+
define block CSTACK with alignment = 8, size = __size_cstack__ { };
95+
place in CSTACK_region { block CSTACK };
96+
97+
define symbol __size_heap__ = 0x10000;
98+
define block HEAP with expanding size, alignment = 8, minimum size = __size_heap__ { };
99+
place in RAM_region { block HEAP, readwrite, zeroinit };
100+

0 commit comments

Comments
 (0)