Skip to content

Commit

Permalink
Merge pull request ARMmbed#78 from linlingao/manage_bootloader
Browse files Browse the repository at this point in the history
changed gcc linker script to workaround an issue in managed bootloade…
  • Loading branch information
linlingao authored Oct 18, 2018
2 parents a90605c + f0aacd2 commit 70f9096
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "bootloader_CC3220SF",
"target_overrides": {
"*": {
"target.app_offset": "0x8400",
"target.header_offset": "0x8000",
"target.bootloader_img": "mbed-bootloader-internal.bin"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,53 @@
#define RAM_SIZE 0x40000
#define VECTORS 195 /* This value must match NVIC_NUM_VECTORS */

/* Common - Do not change */

#if !defined(MBED_APP_START)
#define MBED_APP_START (ROM_START + FLASH_HDR_SIZE)
#endif

#if !defined(MBED_APP_SIZE)
#define MBED_APP_SIZE (ROM_SIZE - FLASH_HDR_SIZE)
#endif

/* Round up VECTORS_SIZE to 8 bytes */
#define VECTORS_SIZE (((VECTORS * 4) + 7) & 0xFFFFFFF8)

#if defined(MBED_APP_START)
/*
* There're two cases if MBED_APP_START is defined.
* Case 1: MBED_APP_START is defined as ROM_START, this happens when restrict_size is turned on, most likely for bootloader build.
* In this build, include FLASH_HDR region.
*/
#define FLASH_HDR_INCLUDED 1

#if MBED_APP_START == ROM_START
#if defined(MBED_APP_SIZE)
#define ROM_EXEC_START (ROM_START + FLASH_HDR_SIZE)
#define ROM_EXEC_SIZE (MBED_APP_SIZE - FLASH_HDR_SIZE)
#endif
#else
/*
* 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.
* 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
*/
#define FLASH_HDR_INCLUDED 0
#define ROM_EXEC_START MBED_APP_START
#if defined(MBED_APP_SIZE)
#define ROM_EXEC_SIZE MBED_APP_SIZE
#else
#define ROM_EXEC_SIZE (ROM_SIZE- (MBED_APP_START - ROM_START)
#endif
#endif
#else
/*
* MBED_APP_START is not defined. This is most likely a bootloader build, or other apps that do not require boodloader.
* In this build, include FLASH_HDR region
*/
#define FLASH_HDR_INCLUDED 1
#define ROM_EXEC_START (ROM_START + FLASH_HDR_SIZE)
#if defined(MBED_APP_SIZE)
#define ROM_EXEC_SIZE (MBED_APP_SIZE - FLASH_HDR_SIZE)
#else
#define ROM_EXEC_SIZE (ROM_SIZE - FLASH_HDR_SIZE)
#endif
#endif

MEMORY
{
FLASH_HDR (rx) : ORIGIN = ROM_START, LENGTH = 0x800
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
FLASH_HDR (rx) : ORIGIN = FLASH_HDR_START, LENGTH = FLASH_HDR_SIZE
FLASH (rx) : ORIGIN = ROM_EXEC_START, LENGTH = ROM_EXEC_SIZE
RAM (rwx) : ORIGIN = RAM_START + VECTORS_SIZE, LENGTH = RAM_SIZE - VECTORS_SIZE
}

Expand Down Expand Up @@ -58,10 +88,11 @@ ENTRY(Reset_Handler)

SECTIONS
{
#if FLASH_HDR_INCLUDED == 1
.dbghdr : ALIGN (2048) {
KEEP (*(.dbghdr))
} > FLASH_HDR

#endif
.text :
{
KEEP(*(.isr_vector))
Expand Down

0 comments on commit 70f9096

Please sign in to comment.