Skip to content

Commit beb6a38

Browse files
author
Edmund Hsu
committed
EV_COG_AD4050LZ: Rework linker scripts to support bootloader
- fix compiler warning message of flash_api.c - fix compiler warning message of startup_ADuCM4050.c - eliminate absolute address of ROM tables - add MBED_APP_START and MBED_APP_SIZE to linker scripts
1 parent 42d77ec commit beb6a38

File tree

7 files changed

+88
-51
lines changed

7 files changed

+88
-51
lines changed

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/TARGET_EV_COG_AD4050LZ/device/startup_ADuCM4050.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @date: $Date: $
77
*-----------------------------------------------------------------------------
88
*
9-
Copyright (c) 2010-2017 Analog Devices, Inc.
9+
Copyright (c) 2010-2018 Analog Devices, Inc.
1010
1111
All rights reserved.
1212
@@ -45,32 +45,29 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4545
*
4646
*****************************************************************************/
4747
#ifdef __ARMCC_VERSION
48-
#include <stdint.h>
4948
#include <rt_misc.h>
5049
#endif
5150
#include <cmsis.h>
5251
#include <startup_ADuCM4050.h>
5352
#include <mbed_rtx.h>
5453

54+
/*----------------------------------------------------------------------------
55+
External function Declaration
56+
*----------------------------------------------------------------------------*/
57+
extern void SramInit(void);
58+
5559
/*----------------------------------------------------------------------------
5660
Checksum options
5761
*----------------------------------------------------------------------------*/
58-
#if defined (__ARMCC_VERSION)
59-
__attribute__((section(".ARM.__at_0x000001A0")))
60-
#elif defined(__ICCARM__)
62+
63+
#if defined(__ICCARM__)
6164
__root
6265
#endif
6366
const uint32_t SECTION_PLACE(blank_checksum[],".checksum") =
6467
{
6568
BLANKX60,BLANKX600
6669
};
6770

68-
69-
/*----------------------------------------------------------------------------
70-
External function Declaration
71-
*----------------------------------------------------------------------------*/
72-
extern void SramInit(void);
73-
7471
/*----------------------------------------------------------------------------
7572
Exception / Interrupt Handler
7673
*----------------------------------------------------------------------------*/

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/TARGET_EV_COG_AD4050LZ/device/startup_ADuCM4050.h

Lines changed: 25 additions & 15 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
@@ -63,6 +63,9 @@ RESET_EXCPT_HNDLR
6363

6464
#include <adi_types.h>
6565
#define VECTOR_SECTION ".vectors"
66+
/* IVT typedefs. */
67+
typedef void( *pFunc )( void );
68+
6669
#ifdef __ARMCC_VERSION
6770
void Default_Handler(void);
6871
#define SECTION_NAME(sectionname) __attribute__((section(sectionname)))
@@ -71,6 +74,9 @@ void Default_Handler(void);
7174
#define RESET_EXCPT_HNDLR __main
7275
#define COMPILER_NAME "ARMCC"
7376
#define WEAK_FUNCTION(x) void x (void) __attribute__((weak, alias("Default_Handler")));
77+
extern uint32_t Load$$LR$$LR_IROM1$$Base[];
78+
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)Load$$LR$$LR_IROM1$$Base)
79+
7480
#elif defined(__ICCARM__)
7581
/*
7682
* IAR MISRA C 2004 error suppressions:
@@ -89,17 +95,20 @@ void Default_Handler(void);
8995
#define RESET_EXCPT_HNDLR __iar_program_start
9096
#define COMPILER_NAME "ICCARM"
9197
#define WEAK_FUNCTION(x) WEAK_FUNC ( void x (void)) { while(1){} }
98+
#pragma section=VECTOR_SECTION
99+
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)__section_begin(VECTOR_SECTION))
100+
92101
#elif defined(__GNUC__)
93-
extern unsigned __etext;
94-
extern unsigned __data_start__;
95-
extern unsigned __data_end__;
96-
extern unsigned __copy_table_start__;
97-
extern unsigned __copy_table_end__;
98-
extern unsigned __zero_table_start__;
99-
extern unsigned __zero_table_end__;
100-
extern unsigned __bss_start__;
101-
extern unsigned __bss_end__;
102-
extern unsigned __StackTop;
102+
extern uint32_t __etext;
103+
extern uint32_t __data_start__;
104+
extern uint32_t __data_end__;
105+
extern uint32_t __copy_table_start__;
106+
extern uint32_t __copy_table_end__;
107+
extern uint32_t __zero_table_start__;
108+
extern uint32_t __zero_table_end__;
109+
extern uint32_t __bss_start__;
110+
extern uint32_t __bss_end__;
111+
extern uint32_t __StackTop;
103112
void Default_Handler(void);
104113
/*----------------------------------------------------------------------------
105114
External References
@@ -112,18 +121,21 @@ extern int __START(void) __attribute__((noreturn)); /* main entry point */
112121
#define RESET_EXCPT_HNDLR __START
113122
#endif
114123
#ifndef __STACK_SIZE
115-
#define __STACK_SIZE 0x00000400
124+
#define __STACK_SIZE 0x00000400
116125
#endif
117126
#if !defined(__HEAP_SIZE) || (__HEAP_SIZE <= 0)
118-
#define __HEAP_SIZE 0x00000C00
127+
#define __HEAP_SIZE 0x00000C00
119128
#endif
120129
#define SECTION_NAME(sectionname) __attribute__ ((section(sectionname)))
121130
#define SECTION_PLACE(def,sectionname) def __attribute__ ((section(sectionname)))
122131
#define IVT_NAME __Vectors
123132
#define COMPILER_NAME "GNUC"
124133
#define WEAK_FUNCTION(x) void x (void) __attribute__ ((weak, alias("Default_Handler")));
134+
extern const pFunc IVT_NAME[];
135+
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)IVT_NAME)
125136
#define __STARTUP_CLEAR_BSS_MULTIPLE
126137
#endif // __GNUC__
138+
127139
#define LASTCRCPAGE 0
128140
#define BLANKX4 0xFFFFFFFF
129141
#define BLANKX20 BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4,BLANKX4
@@ -132,8 +144,6 @@ extern int __START(void) __attribute__((noreturn)); /* main entry point */
132144
#define BLANKX60 BLANKX20,BLANKX20,BLANKX20
133145
void RESET_EXCPT_HNDLR(void);
134146
void Reset_Handler(void);
135-
/* IVT typedefs. */
136-
typedef void( *pFunc )( void );
137147

138148
#define ADUCM4050_VECTORS \
139149
/* Configure Initial Stack Pointer, using linker-generated symbols */\

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/TOOLCHAIN_ARM_STD/ADuCM4050.sct

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
#! armcc -E
12
;******************************************************************************
23
; File: ADuCM4050.sct
34
; Scatter loading file for Analog Devices ADuCM4050 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
@@ -29,14 +30,28 @@
2930
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3031
; POSSIBILITY OF SUCH DAMAGE.
3132
;******************************************************************************
32-
LR_IROM1 0x00000000 0x0007F000 {
33-
FLASH0 0x00000000 0x00000800 {
33+
#if !defined(MBED_APP_START)
34+
#define MBED_APP_START 0
35+
#endif
36+
37+
#if !defined(MBED_APP_SIZE)
38+
#define MBED_APP_SIZE 0x7F000
39+
#endif
40+
41+
#define ADUCM_SECTOR_SIZE 0x800
42+
43+
#define ADUCM_VECTOR_SIZE 0x1A0
44+
45+
LR_IROM1 MBED_APP_START MBED_APP_SIZE {
46+
FLASH0 MBED_APP_START ADUCM_VECTOR_SIZE {
3447
*(.vectors, +First)
35-
*(.checksum)
3648
}
3749

38-
ER_IROM1 AlignExpr(ImageLimit(FLASH0), 16) 0x0007E800 {
39-
; load address = execution address
50+
FLASH1 (MBED_APP_START + ADUCM_VECTOR_SIZE) (ADUCM_SECTOR_SIZE - ADUCM_VECTOR_SIZE) {
51+
*(.checksum, +Last)
52+
}
53+
54+
ER_IROM1 (MBED_APP_START + ADUCM_SECTOR_SIZE) (MBED_APP_SIZE - ADUCM_SECTOR_SIZE) {
4055
*(InRoot$$Sections)
4156
*(+RO)
4257
}

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/TOOLCHAIN_GCC_ARM/ADuCM4050.ld

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
/*
2-
* Portions Copyright (c) 2016 Analog Devices, Inc.
2+
* Portions Copyright (c) 2016 - 2018 Analog Devices, Inc.
33
*
44
* Based on Device/ARM/ARMCM4/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 0x7F000
14+
#endif
15+
16+
#define ADUCM_SECTOR_SIZE 0x800
17+
818
/* Linker script to configure memory regions. */
919
MEMORY
1020
{
1121
/* The first 0x800 bytes of flash */
12-
FLASH0 (rx) : ORIGIN = 0x00000000, LENGTH = 0x800
13-
/* The remaining bytes of flash minus 4KB Protected Key Storage */
14-
FLASH (rx) : ORIGIN = 0x00000800, LENGTH = 512k - 4k - 0x800
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 */
1626
DSRAM_A (rwx) : ORIGIN = 0x20000200, LENGTH = 32k - 0x200
1727
/* SRAM bank 3+4+5+6+7 */
@@ -76,13 +86,6 @@ SECTIONS
7686
KEEP(*(.checksum))
7787
} > FLASH0
7888

79-
.security_options :
80-
{
81-
. = ALIGN(4);
82-
KEEP(*(.security_options))
83-
. = ALIGN(4);
84-
} > FLASH0
85-
8689
.text :
8790
{
8891
*(.text*)

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/TOOLCHAIN_IAR/ADuCM4050.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 ADuCM4050 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 = 0x7F000;
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 506K];
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 0x20040000 size 0x00008000];
3750
define region RAM_bank2_region = mem:[from 0x20000200 size 0x00007E00]
3851
| mem:[from 0x20048000 size 0x00010000];

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/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_ADUCM4X50/TARGET_ADUCM4050/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
*
@@ -66,7 +66,7 @@ static const flash_algo_t flash_algo_config = {
6666
.erase_sector = 0x00000057,
6767
.program_page = 0x0000007F,
6868
.static_base = 0x0000013C,
69-
.algo_blob = FLASH_ALGO
69+
.algo_blob = (uint32_t *)FLASH_ALGO
7070
};
7171

7272
static const sector_info_t sectors_info[] = {

0 commit comments

Comments
 (0)