Skip to content

Commit e2d9eb8

Browse files
author
Edmund Hsu
committed
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
1 parent beb6a38 commit e2d9eb8

File tree

7 files changed

+70
-26
lines changed

7 files changed

+70
-26
lines changed

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/TARGET_EV_COG_AD3029LZ/device/startup_ADuCM3029.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4444
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4545
*
4646
*****************************************************************************/
47-
#include <stdint.h>
4847
#ifdef __ARMCC_VERSION
4948
#include <rt_misc.h>
5049
#endif
5150
#include <cmsis.h>
5251
#include <startup_ADuCM3029.h>
5352
#include <mbed_rtx.h>
5453

55-
5654
/*----------------------------------------------------------------------------
5755
External function Declaration
5856
*----------------------------------------------------------------------------*/
@@ -61,9 +59,8 @@ extern void SramInit(void);
6159
/*----------------------------------------------------------------------------
6260
Checksum options
6361
*----------------------------------------------------------------------------*/
64-
#if defined (__ARMCC_VERSION)
65-
__attribute__((section(".ARM.__at_0x000001A0")))
66-
#elif defined( __ICCARM__)
62+
63+
#if defined( __ICCARM__)
6764
__root
6865
#endif /* __ICCARM__ */
6966
const uint32_t SECTION_PLACE(blank_checksum[],".checksum") =

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/TARGET_EV_COG_AD3029LZ/device/startup_ADuCM3029.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @date: $Date: $
88
*-----------------------------------------------------------------------------
99
*
10-
Copyright (c) 2010-2017 Analog Devices, Inc.
10+
Copyright (c) 2010-2018 Analog Devices, Inc.
1111
1212
All rights reserved.
1313
@@ -62,6 +62,8 @@ RESET_EXCPT_HNDLR
6262
#define __STARTUP_H__
6363

6464
#define VECTOR_SECTION ".vectors"
65+
/* IVT typedefs. */
66+
typedef void( *pFunc )( void );
6567

6668
#ifdef __ARMCC_VERSION
6769
void Default_Handler(void);
@@ -71,6 +73,8 @@ void Default_Handler(void);
7173
#define RESET_EXCPT_HNDLR __main
7274
#define COMPILER_NAME "ARMCC"
7375
#define WEAK_FUNCTION(x) void x (void) __attribute__((weak, alias("Default_Handler")));
76+
extern uint32_t Load$$LR$$LR_IROM1$$Base[];
77+
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)Load$$LR$$LR_IROM1$$Base)
7478

7579
#elif defined(__ICCARM__)
7680
#pragma diag_suppress=Pm093,Pm140
@@ -80,6 +84,8 @@ void Default_Handler(void);
8084
#define RESET_EXCPT_HNDLR __iar_program_start
8185
#define COMPILER_NAME "ICCARM"
8286
#define WEAK_FUNCTION(x) WEAK_FUNC ( void x (void)) { while(1){} }
87+
#pragma section=VECTOR_SECTION
88+
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)__section_begin(VECTOR_SECTION))
8389

8490
#elif defined(__GNUC__)
8591
extern unsigned __etext;
@@ -105,8 +111,11 @@ extern int __START(void) __attribute__((noreturn)); /* main entry point */
105111
#define IVT_NAME __Vectors
106112
#define COMPILER_NAME "GNUC"
107113
#define WEAK_FUNCTION(x) void x (void) __attribute__ ((weak, alias("Default_Handler")));
114+
extern const pFunc IVT_NAME[];
115+
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)IVT_NAME)
108116
#define __STARTUP_CLEAR_BSS_MULTIPLE
109117
#endif // __GNUC__
118+
110119
#define LASTCRCPAGE 0
111120
#define BLANKX4 0xFFFFFFFF
112121
#define BLANKX20 BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4
@@ -115,8 +124,6 @@ extern int __START(void) __attribute__((noreturn)); /* main entry point */
115124
#define BLANKX60 BLANKX20,BLANKX20,BLANKX20
116125
void RESET_EXCPT_HNDLR(void);
117126
void Reset_Handler(void);
118-
/* IVT typedefs. */
119-
typedef void( *pFunc )( void );
120127

121128
#define ADUCM3029_VECTORS /* Cortex-M3 Exceptions Handler */ \
122129
Reset_Handler, /* -15 */ \

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/TOOLCHAIN_ARM_STD/ADuCM3029.sct

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
#! armcc -E
12
;******************************************************************************
23
; File: ADuCM3029.sct
34
; Scatter loading file for Analog Devices ADuCM3029 processor
45
;
56
; Copyright (c) 2011 - 2014 ARM LIMITED
6-
; Copyright (c) 2016 - 2017 Analog Devices, Inc.
7+
; Copyright (c) 2016 - 2018 Analog Devices, Inc.
78
;
89
; All rights reserved.
910
; Redistribution and use in source and binary forms, with or without
@@ -32,13 +33,30 @@
3233
; Portions Copyright (c) 2017 Analog Devices, Inc.
3334
;
3435
;******************************************************************************
36+
#if !defined(MBED_APP_START)
37+
#define MBED_APP_START 0
38+
#endif
3539

36-
LR_IROM1 0x00000000 0x00040000 {
37-
ADUCM_IROM1 0x00000000 0x00040000 { ; romflash start address
40+
#if !defined(MBED_APP_SIZE)
41+
#define MBED_APP_SIZE 0x40000
42+
#endif
43+
44+
#define ADUCM_SECTOR_SIZE 0x800
45+
46+
#define ADUCM_VECTOR_SIZE 0x1A0
47+
48+
LR_IROM1 MBED_APP_START MBED_APP_SIZE {
49+
FLASH0 MBED_APP_START ADUCM_VECTOR_SIZE {
3850
*(.vectors, +First)
39-
*(.checksum)
51+
}
52+
53+
FLASH1 (MBED_APP_START + ADUCM_VECTOR_SIZE) (ADUCM_SECTOR_SIZE - ADUCM_VECTOR_SIZE) {
54+
*(.checksum, +Last)
55+
}
56+
57+
ER_IROM1 (MBED_APP_START + ADUCM_SECTOR_SIZE) (MBED_APP_SIZE - ADUCM_SECTOR_SIZE) {
4058
*(InRoot$$Sections)
41-
.ANY (+RO)
59+
*(+RO)
4260
}
4361

4462
RW_IRAM1 0x20000200 { ; data section

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/TOOLCHAIN_GCC_ARM/ADuCM3029.ld

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
/*
2-
* Portions Copyright (c) 2016 - 2017 Analog Devices, Inc.
2+
* Portions Copyright (c) 2016 - 2018 Analog Devices, Inc.
33
*
44
* Based on Device/ARM/ARMCM3/Source/GCC/gcc_arm.ld file in
55
* ARM.CMSIS.4.5.0.pack.
66
*/
77

8+
#if !defined(MBED_APP_START)
9+
#define MBED_APP_START 0
10+
#endif
11+
12+
#if !defined(MBED_APP_SIZE)
13+
#define MBED_APP_SIZE 0x40000
14+
#endif
15+
16+
#define ADUCM_SECTOR_SIZE 0x800
17+
818
/* Linker script to configure memory regions. */
919
MEMORY
1020
{
11-
/* Flash bank0 */
12-
FLASH0 (rx) : ORIGIN = 0x00000000, LENGTH = 0x800
13-
/* Flash bank0 - bank127*/
14-
FLASH (rx) : ORIGIN = 0x00000800, LENGTH = 256k - 0x800
21+
/* The first 0x800 bytes of flash */
22+
FLASH0 (rx) : ORIGIN = MBED_APP_START, LENGTH = ADUCM_SECTOR_SIZE
23+
/* The rest of the flash */
24+
FLASH (rx) : ORIGIN = MBED_APP_START + ADUCM_SECTOR_SIZE, LENGTH = MBED_APP_SIZE - ADUCM_SECTOR_SIZE
1525
/* SRAM bank 0+1 */
1626
DSRAM_V (rwx) : ORIGIN = 0x20000000, LENGTH = 0x200
1727
DSRAM_A (rwx) : ORIGIN = 0x20000200, LENGTH = 16k - 0x200

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/TOOLCHAIN_IAR/ADuCM3029.icf

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* ILINK Configuration File for Analog Devices ADuCM3029 processor
44
*
55
* Copyright (c) 2011 - 2014 ARM LIMITED
6-
* Copyright (c) 2016 - 2017 Analog Devices, Inc.
6+
* Copyright (c) 2016 - 2018 Analog Devices, Inc.
77
*
88
* All rights reserved.
99
* Redistribution and use in source and binary forms, with or without
@@ -29,10 +29,23 @@
2929
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030
* POSSIBILITY OF SUCH DAMAGE.
3131
******************************************************************************/
32+
33+
if (!isdefinedsymbol(MBED_APP_START)) {
34+
define symbol MBED_APP_START = 0;
35+
}
36+
37+
if (!isdefinedsymbol(MBED_APP_SIZE)) {
38+
define symbol MBED_APP_SIZE = 0x40000;
39+
}
40+
41+
define symbol ADUCM_SECTOR_SIZE = 0x800;
42+
43+
define symbol ADUCM_VECTOR_SIZE = 0x1A0;
44+
3245
define memory mem with size = 4G;
33-
define region ROM_PAGE0_INTVEC = mem:[from 0x00000000 size 0x000001A0];
34-
define region ROM_PAGE0_CHECKSUM = mem:[from 0x000001A0 size 0x00000660];
35-
define region ROM_REGION = mem:[from 0x00000800 size 254K];
46+
define region ROM_PAGE0_INTVEC = mem:[from MBED_APP_START size ADUCM_VECTOR_SIZE];
47+
define region ROM_PAGE0_CHECKSUM = mem:[from MBED_APP_START+ADUCM_VECTOR_SIZE size ADUCM_SECTOR_SIZE-ADUCM_VECTOR_SIZE];
48+
define region ROM_REGION = mem:[from MBED_APP_START+ADUCM_SECTOR_SIZE size MBED_APP_SIZE-ADUCM_SECTOR_SIZE];
3649
define region RAM_bank1_region = mem:[from 0x20000200 size 0x00003E00];
3750
define region RAM_bank2_region = mem:[from 0x20004000 size 0x00004000]
3851
| mem:[from 0x20040000 size 0x00008000];

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/cmsis_nvic.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010-2017 Analog Devices, Inc.
2+
* Copyright (c) 2010-2018 Analog Devices, Inc.
33
*
44
* All rights reserved.
55
*
@@ -48,7 +48,6 @@
4848
#define NVIC_NUM_VECTORS (NVIC_USER_IRQ_OFFSET + NVIC_USER_IRQ_NUMBER)
4949

5050
#define NVIC_RAM_VECTOR_ADDRESS 0x20000000
51-
#define NVIC_FLASH_VECTOR_ADDRESS 0x0
5251

5352
#ifdef __cplusplus
5453
extern "C" {

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/flash_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010-2017 Analog Devices, Inc.
2+
* Copyright (c) 2010-2018 Analog Devices, Inc.
33
*
44
* All rights reserved.
55
*
@@ -68,7 +68,7 @@ static const flash_algo_t flash_algo_config = {
6868
.erase_sector = 0x0000006F,
6969
.program_page = 0x000000AB,
7070
.static_base = 0x0000017C,
71-
.algo_blob = FLASH_ALGO
71+
.algo_blob = (uint32_t *)FLASH_ALGO
7272
};
7373

7474
static const sector_info_t sectors_info[] = {

0 commit comments

Comments
 (0)