Skip to content

Commit 70f9096

Browse files
authored
Merge pull request ARMmbed#78 from linlingao/manage_bootloader
changed gcc linker script to workaround an issue in managed bootloade…
2 parents a90605c + f0aacd2 commit 70f9096

File tree

3 files changed

+54
-13
lines changed

3 files changed

+54
-13
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "bootloader_CC3220SF",
3+
"target_overrides": {
4+
"*": {
5+
"target.app_offset": "0x8400",
6+
"target.header_offset": "0x8000",
7+
"target.bootloader_img": "mbed-bootloader-internal.bin"
8+
}
9+
}
10+
}

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

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,53 @@
88
#define RAM_SIZE 0x40000
99
#define VECTORS 195 /* This value must match NVIC_NUM_VECTORS */
1010

11-
/* Common - Do not change */
12-
13-
#if !defined(MBED_APP_START)
14-
#define MBED_APP_START (ROM_START + FLASH_HDR_SIZE)
15-
#endif
16-
17-
#if !defined(MBED_APP_SIZE)
18-
#define MBED_APP_SIZE (ROM_SIZE - FLASH_HDR_SIZE)
19-
#endif
20-
2111
/* Round up VECTORS_SIZE to 8 bytes */
2212
#define VECTORS_SIZE (((VECTORS * 4) + 7) & 0xFFFFFFF8)
2313

14+
#if defined(MBED_APP_START)
15+
/*
16+
* There're two cases if MBED_APP_START is defined.
17+
* Case 1: MBED_APP_START is defined as ROM_START, this happens when restrict_size is turned on, most likely for bootloader build.
18+
* In this build, include FLASH_HDR region.
19+
*/
20+
#define FLASH_HDR_INCLUDED 1
21+
22+
#if MBED_APP_START == ROM_START
23+
#if defined(MBED_APP_SIZE)
24+
#define ROM_EXEC_START (ROM_START + FLASH_HDR_SIZE)
25+
#define ROM_EXEC_SIZE (MBED_APP_SIZE - FLASH_HDR_SIZE)
26+
#endif
27+
#else
28+
/*
29+
* 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.
30+
* 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
31+
*/
32+
#define FLASH_HDR_INCLUDED 0
33+
#define ROM_EXEC_START MBED_APP_START
34+
#if defined(MBED_APP_SIZE)
35+
#define ROM_EXEC_SIZE MBED_APP_SIZE
36+
#else
37+
#define ROM_EXEC_SIZE (ROM_SIZE- (MBED_APP_START - ROM_START)
38+
#endif
39+
#endif
40+
#else
41+
/*
42+
* MBED_APP_START is not defined. This is most likely a bootloader build, or other apps that do not require boodloader.
43+
* In this build, include FLASH_HDR region
44+
*/
45+
#define FLASH_HDR_INCLUDED 1
46+
#define ROM_EXEC_START (ROM_START + FLASH_HDR_SIZE)
47+
#if defined(MBED_APP_SIZE)
48+
#define ROM_EXEC_SIZE (MBED_APP_SIZE - FLASH_HDR_SIZE)
49+
#else
50+
#define ROM_EXEC_SIZE (ROM_SIZE - FLASH_HDR_SIZE)
51+
#endif
52+
#endif
53+
2454
MEMORY
2555
{
26-
FLASH_HDR (rx) : ORIGIN = ROM_START, LENGTH = 0x800
27-
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
56+
FLASH_HDR (rx) : ORIGIN = FLASH_HDR_START, LENGTH = FLASH_HDR_SIZE
57+
FLASH (rx) : ORIGIN = ROM_EXEC_START, LENGTH = ROM_EXEC_SIZE
2858
RAM (rwx) : ORIGIN = RAM_START + VECTORS_SIZE, LENGTH = RAM_SIZE - VECTORS_SIZE
2959
}
3060

@@ -58,10 +88,11 @@ ENTRY(Reset_Handler)
5888

5989
SECTIONS
6090
{
91+
#if FLASH_HDR_INCLUDED == 1
6192
.dbghdr : ALIGN (2048) {
6293
KEEP (*(.dbghdr))
6394
} > FLASH_HDR
64-
95+
#endif
6596
.text :
6697
{
6798
KEEP(*(.isr_vector))

0 commit comments

Comments
 (0)