EV_COG_AD3029LZ: Rework linker scripts to support bootloader

- fix compiler warning message of flash_api.c
- eliminate absolute address of ROM tables
- add MBED_APP_START and MBED_APP_SIZE to linker scripts
pull/6690/head
Edmund Hsu 2018-04-20 15:57:05 +10:00
parent beb6a38009
commit e2d9eb8b79
7 changed files with 70 additions and 26 deletions

View File

@ -44,7 +44,6 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*****************************************************************************/ *****************************************************************************/
#include <stdint.h>
#ifdef __ARMCC_VERSION #ifdef __ARMCC_VERSION
#include <rt_misc.h> #include <rt_misc.h>
#endif #endif
@ -52,7 +51,6 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <startup_ADuCM3029.h> #include <startup_ADuCM3029.h>
#include <mbed_rtx.h> #include <mbed_rtx.h>
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
External function Declaration External function Declaration
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -61,9 +59,8 @@ extern void SramInit(void);
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
Checksum options Checksum options
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
#if defined (__ARMCC_VERSION)
__attribute__((section(".ARM.__at_0x000001A0"))) #if defined( __ICCARM__)
#elif defined( __ICCARM__)
__root __root
#endif /* __ICCARM__ */ #endif /* __ICCARM__ */
const uint32_t SECTION_PLACE(blank_checksum[],".checksum") = const uint32_t SECTION_PLACE(blank_checksum[],".checksum") =

View File

@ -7,7 +7,7 @@
* @date: $Date: $ * @date: $Date: $
*----------------------------------------------------------------------------- *-----------------------------------------------------------------------------
* *
Copyright (c) 2010-2017 Analog Devices, Inc. Copyright (c) 2010-2018 Analog Devices, Inc.
All rights reserved. All rights reserved.
@ -62,6 +62,8 @@ RESET_EXCPT_HNDLR
#define __STARTUP_H__ #define __STARTUP_H__
#define VECTOR_SECTION ".vectors" #define VECTOR_SECTION ".vectors"
/* IVT typedefs. */
typedef void( *pFunc )( void );
#ifdef __ARMCC_VERSION #ifdef __ARMCC_VERSION
void Default_Handler(void); void Default_Handler(void);
@ -71,6 +73,8 @@ void Default_Handler(void);
#define RESET_EXCPT_HNDLR __main #define RESET_EXCPT_HNDLR __main
#define COMPILER_NAME "ARMCC" #define COMPILER_NAME "ARMCC"
#define WEAK_FUNCTION(x) void x (void) __attribute__((weak, alias("Default_Handler"))); #define WEAK_FUNCTION(x) void x (void) __attribute__((weak, alias("Default_Handler")));
extern uint32_t Load$$LR$$LR_IROM1$$Base[];
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)Load$$LR$$LR_IROM1$$Base)
#elif defined(__ICCARM__) #elif defined(__ICCARM__)
#pragma diag_suppress=Pm093,Pm140 #pragma diag_suppress=Pm093,Pm140
@ -80,6 +84,8 @@ void Default_Handler(void);
#define RESET_EXCPT_HNDLR __iar_program_start #define RESET_EXCPT_HNDLR __iar_program_start
#define COMPILER_NAME "ICCARM" #define COMPILER_NAME "ICCARM"
#define WEAK_FUNCTION(x) WEAK_FUNC ( void x (void)) { while(1){} } #define WEAK_FUNCTION(x) WEAK_FUNC ( void x (void)) { while(1){} }
#pragma section=VECTOR_SECTION
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)__section_begin(VECTOR_SECTION))
#elif defined(__GNUC__) #elif defined(__GNUC__)
extern unsigned __etext; extern unsigned __etext;
@ -105,8 +111,11 @@ extern int __START(void) __attribute__((noreturn)); /* main entry point */
#define IVT_NAME __Vectors #define IVT_NAME __Vectors
#define COMPILER_NAME "GNUC" #define COMPILER_NAME "GNUC"
#define WEAK_FUNCTION(x) void x (void) __attribute__ ((weak, alias("Default_Handler"))); #define WEAK_FUNCTION(x) void x (void) __attribute__ ((weak, alias("Default_Handler")));
extern const pFunc IVT_NAME[];
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)IVT_NAME)
#define __STARTUP_CLEAR_BSS_MULTIPLE #define __STARTUP_CLEAR_BSS_MULTIPLE
#endif // __GNUC__ #endif // __GNUC__
#define LASTCRCPAGE 0 #define LASTCRCPAGE 0
#define BLANKX4 0xFFFFFFFF #define BLANKX4 0xFFFFFFFF
#define BLANKX20 BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4 #define BLANKX20 BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4
@ -115,8 +124,6 @@ extern int __START(void) __attribute__((noreturn)); /* main entry point */
#define BLANKX60 BLANKX20,BLANKX20,BLANKX20 #define BLANKX60 BLANKX20,BLANKX20,BLANKX20
void RESET_EXCPT_HNDLR(void); void RESET_EXCPT_HNDLR(void);
void Reset_Handler(void); void Reset_Handler(void);
/* IVT typedefs. */
typedef void( *pFunc )( void );
#define ADUCM3029_VECTORS /* Cortex-M3 Exceptions Handler */ \ #define ADUCM3029_VECTORS /* Cortex-M3 Exceptions Handler */ \
Reset_Handler, /* -15 */ \ Reset_Handler, /* -15 */ \

View File

@ -1,9 +1,10 @@
#! armcc -E
;****************************************************************************** ;******************************************************************************
; File: ADuCM3029.sct ; File: ADuCM3029.sct
; Scatter loading file for Analog Devices ADuCM3029 processor ; Scatter loading file for Analog Devices ADuCM3029 processor
; ;
; Copyright (c) 2011 - 2014 ARM LIMITED ; Copyright (c) 2011 - 2014 ARM LIMITED
; Copyright (c) 2016 - 2017 Analog Devices, Inc. ; Copyright (c) 2016 - 2018 Analog Devices, Inc.
; ;
; All rights reserved. ; All rights reserved.
; Redistribution and use in source and binary forms, with or without ; Redistribution and use in source and binary forms, with or without
@ -32,13 +33,30 @@
; Portions Copyright (c) 2017 Analog Devices, Inc. ; Portions Copyright (c) 2017 Analog Devices, Inc.
; ;
;****************************************************************************** ;******************************************************************************
#if !defined(MBED_APP_START)
#define MBED_APP_START 0
#endif
LR_IROM1 0x00000000 0x00040000 { #if !defined(MBED_APP_SIZE)
ADUCM_IROM1 0x00000000 0x00040000 { ; romflash start address #define MBED_APP_SIZE 0x40000
#endif
#define ADUCM_SECTOR_SIZE 0x800
#define ADUCM_VECTOR_SIZE 0x1A0
LR_IROM1 MBED_APP_START MBED_APP_SIZE {
FLASH0 MBED_APP_START ADUCM_VECTOR_SIZE {
*(.vectors, +First) *(.vectors, +First)
*(.checksum) }
FLASH1 (MBED_APP_START + ADUCM_VECTOR_SIZE) (ADUCM_SECTOR_SIZE - ADUCM_VECTOR_SIZE) {
*(.checksum, +Last)
}
ER_IROM1 (MBED_APP_START + ADUCM_SECTOR_SIZE) (MBED_APP_SIZE - ADUCM_SECTOR_SIZE) {
*(InRoot$$Sections) *(InRoot$$Sections)
.ANY (+RO) *(+RO)
} }
RW_IRAM1 0x20000200 { ; data section RW_IRAM1 0x20000200 { ; data section

View File

@ -1,17 +1,27 @@
/* /*
* Portions Copyright (c) 2016 - 2017 Analog Devices, Inc. * Portions Copyright (c) 2016 - 2018 Analog Devices, Inc.
* *
* Based on Device/ARM/ARMCM3/Source/GCC/gcc_arm.ld file in * Based on Device/ARM/ARMCM3/Source/GCC/gcc_arm.ld file in
* ARM.CMSIS.4.5.0.pack. * ARM.CMSIS.4.5.0.pack.
*/ */
#if !defined(MBED_APP_START)
#define MBED_APP_START 0
#endif
#if !defined(MBED_APP_SIZE)
#define MBED_APP_SIZE 0x40000
#endif
#define ADUCM_SECTOR_SIZE 0x800
/* Linker script to configure memory regions. */ /* Linker script to configure memory regions. */
MEMORY MEMORY
{ {
/* Flash bank0 */ /* The first 0x800 bytes of flash */
FLASH0 (rx) : ORIGIN = 0x00000000, LENGTH = 0x800 FLASH0 (rx) : ORIGIN = MBED_APP_START, LENGTH = ADUCM_SECTOR_SIZE
/* Flash bank0 - bank127*/ /* The rest of the flash */
FLASH (rx) : ORIGIN = 0x00000800, LENGTH = 256k - 0x800 FLASH (rx) : ORIGIN = MBED_APP_START + ADUCM_SECTOR_SIZE, LENGTH = MBED_APP_SIZE - ADUCM_SECTOR_SIZE
/* SRAM bank 0+1 */ /* SRAM bank 0+1 */
DSRAM_V (rwx) : ORIGIN = 0x20000000, LENGTH = 0x200 DSRAM_V (rwx) : ORIGIN = 0x20000000, LENGTH = 0x200
DSRAM_A (rwx) : ORIGIN = 0x20000200, LENGTH = 16k - 0x200 DSRAM_A (rwx) : ORIGIN = 0x20000200, LENGTH = 16k - 0x200

View File

@ -3,7 +3,7 @@
* ILINK Configuration File for Analog Devices ADuCM3029 processor * ILINK Configuration File for Analog Devices ADuCM3029 processor
* *
* Copyright (c) 2011 - 2014 ARM LIMITED * Copyright (c) 2011 - 2014 ARM LIMITED
* Copyright (c) 2016 - 2017 Analog Devices, Inc. * Copyright (c) 2016 - 2018 Analog Devices, Inc.
* *
* All rights reserved. * All rights reserved.
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,10 +29,23 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/ ******************************************************************************/
if (!isdefinedsymbol(MBED_APP_START)) {
define symbol MBED_APP_START = 0;
}
if (!isdefinedsymbol(MBED_APP_SIZE)) {
define symbol MBED_APP_SIZE = 0x40000;
}
define symbol ADUCM_SECTOR_SIZE = 0x800;
define symbol ADUCM_VECTOR_SIZE = 0x1A0;
define memory mem with size = 4G; define memory mem with size = 4G;
define region ROM_PAGE0_INTVEC = mem:[from 0x00000000 size 0x000001A0]; define region ROM_PAGE0_INTVEC = mem:[from MBED_APP_START size ADUCM_VECTOR_SIZE];
define region ROM_PAGE0_CHECKSUM = mem:[from 0x000001A0 size 0x00000660]; define region ROM_PAGE0_CHECKSUM = mem:[from MBED_APP_START+ADUCM_VECTOR_SIZE size ADUCM_SECTOR_SIZE-ADUCM_VECTOR_SIZE];
define region ROM_REGION = mem:[from 0x00000800 size 254K]; define region ROM_REGION = mem:[from MBED_APP_START+ADUCM_SECTOR_SIZE size MBED_APP_SIZE-ADUCM_SECTOR_SIZE];
define region RAM_bank1_region = mem:[from 0x20000200 size 0x00003E00]; define region RAM_bank1_region = mem:[from 0x20000200 size 0x00003E00];
define region RAM_bank2_region = mem:[from 0x20004000 size 0x00004000] define region RAM_bank2_region = mem:[from 0x20004000 size 0x00004000]
| mem:[from 0x20040000 size 0x00008000]; | mem:[from 0x20040000 size 0x00008000];

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010-2017 Analog Devices, Inc. * Copyright (c) 2010-2018 Analog Devices, Inc.
* *
* All rights reserved. * All rights reserved.
* *
@ -48,7 +48,6 @@
#define NVIC_NUM_VECTORS (NVIC_USER_IRQ_OFFSET + NVIC_USER_IRQ_NUMBER) #define NVIC_NUM_VECTORS (NVIC_USER_IRQ_OFFSET + NVIC_USER_IRQ_NUMBER)
#define NVIC_RAM_VECTOR_ADDRESS 0x20000000 #define NVIC_RAM_VECTOR_ADDRESS 0x20000000
#define NVIC_FLASH_VECTOR_ADDRESS 0x0
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010-2017 Analog Devices, Inc. * Copyright (c) 2010-2018 Analog Devices, Inc.
* *
* All rights reserved. * All rights reserved.
* *
@ -68,7 +68,7 @@ static const flash_algo_t flash_algo_config = {
.erase_sector = 0x0000006F, .erase_sector = 0x0000006F,
.program_page = 0x000000AB, .program_page = 0x000000AB,
.static_base = 0x0000017C, .static_base = 0x0000017C,
.algo_blob = FLASH_ALGO .algo_blob = (uint32_t *)FLASH_ALGO
}; };
static const sector_info_t sectors_info[] = { static const sector_info_t sectors_info[] = {