Skip to content

Commit ca5eaf2

Browse files
BabaYBIRISZZW
authored andcommitted
src: library mcuboot supports all boards and all version of mbedtls
Signed-off-by: Yiping Peng <yibingp@synopsys.com>
1 parent bd9495b commit ca5eaf2

File tree

20 files changed

+490
-473
lines changed

20 files changed

+490
-473
lines changed

board/axs/axs.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ include $(BOARD_AXS_DIR)/configs/core_compiler.mk
6868
# set board image information for MCUBoot
6969
##
7070
ifneq ($(findstring mcuboot, $(LIB_SEL)), )
71-
$(error MCUBoot is not support BOARD $(BOARD) now, please check it!)
71+
$(error MCUBoot does not support BOARD $(BOARD) now, please check it!)
7272
endif
7373

7474
## Build Rules

board/axs/configs/103/target_mem_config.h

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* ------------------------------------------
2-
* Copyright (c) 2017, Synopsys, Inc. All rights reserved.
2+
* Copyright (c) 2018, Synopsys, Inc. All rights reserved.
33
44
* Redistribution and use in source and binary forms, with or without modification,
55
* are permitted provided that the following conditions are met:
@@ -27,6 +27,16 @@
2727
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
*
2929
--------------------------------------------- */
30+
/**
31+
* \file
32+
* \ingroup BOARD_EMSK_COMMON_INIT
33+
* \brief axs memory resource definitions
34+
* \details
35+
* - This header file will contain the memory resources on the board
36+
* - User can select different region for applications by configuring
37+
REGION_ROM and REGION_RAM
38+
* - The unit of XXXX_SIZE is Byte
39+
*/
3040

3141
#ifndef _TARGET_MEM_CONFIG_H_
3242
#define _TARGET_MEM_CONFIG_H_
@@ -37,6 +47,11 @@
3747
#include "appl_mem_config.h"
3848
#endif
3949

50+
/**
51+
* DO NOT MODIFY THIS PART
52+
*
53+
* The information of memory devices on the board
54+
*/
4055
#define SRAM_CPU_START 0x0
4156
#define SRAM_CPU_LENGTH 0x20000
4257

@@ -46,11 +61,6 @@
4661
#define ROM_CPU_START 0x30000000
4762
#define ROM_CPU_LENGTH 0x8000
4863

49-
/**
50-
* The unit of XXXX_SIZE is Byte
51-
* For REGION_ROM, ICCM, EXT_ROM and EXT_RAM are available
52-
* For REGION_RAM, DCCM and EXT_RAM are available
53-
*/
5464
#ifdef ARC_FEATURE_ICCM_PRESENT
5565
#ifndef ICCM_SIZE
5666
#define ICCM_SIZE ARC_FEATURE_ICCM_SIZE
@@ -83,30 +93,72 @@
8393
#endif
8494
#endif
8595

96+
/* A fake ROM, assigned from RAM */
97+
#ifndef EXT_ROM_START
98+
#define EXT_ROM_START 0x80000000
99+
#endif
100+
101+
#ifndef EXT_ROM_SIZE
102+
#define EXT_ROM_SIZE 0x6000000
103+
#endif
104+
86105
#ifndef EXT_RAM_START
87-
#define EXT_RAM_START 0x80000000
106+
#define EXT_RAM_START 0x86000000
88107
#endif
89108

90109
#ifndef EXT_RAM_SIZE
91-
#define EXT_RAM_SIZE 0x8000000
110+
#define EXT_RAM_SIZE 0x2000000
92111
#endif
93112

113+
/**
114+
* The default regions assigned for application to use,
115+
by default, each region will use all the space
116+
of each memory device
117+
* User can config the start address and the size of
118+
the regions to limit the application using
119+
*/
120+
#ifndef REGION_ICCM_START
121+
#define REGION_ICCM_START ICCM_START
122+
#define REGION_ICCM_SIZE ICCM_SIZE
123+
#endif
124+
125+
#ifndef REGION_DCCM_START
126+
#define REGION_DCCM_START DCCM_START
127+
#define REGION_DCCM_SIZE DCCM_SIZE
128+
#endif
129+
130+
#ifndef REGION_EXT_ROM_START
131+
#define REGION_EXT_ROM_START EXT_ROM_START
132+
#define REGION_EXT_ROM_SIZE EXT_ROM_SIZE
133+
#endif
134+
135+
#ifndef REGION_EXT_RAM_START
136+
#define REGION_EXT_RAM_START EXT_RAM_START
137+
#define REGION_EXT_RAM_SIZE EXT_RAM_SIZE
138+
#endif
139+
140+
#define IMAGE_HEAD_SIZE 0x0
141+
142+
/**
143+
* The default regions used to generate link script
144+
* User can select region by configuring REGION_ROM and REGION_RAM
145+
* For REGION_ROM, REGION_ICCM, REGION_EXT_ROM are available
146+
* For REGION_RAM, REGION_DCCM and REGION_EXT_RAM are available
147+
*/
94148
#ifndef REGION_ROM
95149
#ifdef ARC_FEATURE_ICACHE_PRESENT
96-
#define REGION_ROM EXT_RAM
150+
#define REGION_ROM REGION_EXT_ROM
97151
#else
98-
#define REGION_ROM ICCM
152+
#define REGION_ROM REGION_ICCM
99153
#endif
100154
#endif
101155

102156
#ifndef REGION_RAM
103157
#ifdef ARC_FEATURE_DCACHE_PRESENT
104-
#define REGION_RAM EXT_RAM
158+
#define REGION_RAM REGION_EXT_RAM
105159
#else
106-
#define REGION_RAM DCCM
160+
#define REGION_RAM REGION_DCCM
107161
#endif
108162
#endif
109163

110-
#define IMAGE_HEAD_SIZE 0x0
111-
112164
#endif /* _TARGET_MEM_CONFIG_H_ */

board/emsk/configs/11/target_mem_config.h

Lines changed: 78 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
*
2929
--------------------------------------------- */
30+
/**
31+
* \file
32+
* \ingroup BOARD_EMSK_COMMON_INIT
33+
* \brief emsk memory resource definitions
34+
* \details
35+
* - This header file will contain the memory resources on the board
36+
* - User can select different region for applications by configuring
37+
REGION_ROM and REGION_RAM
38+
* - The unit of XXXX_SIZE is Byte
39+
*/
40+
3041
#ifndef _TARGET_MEM_CONFIG_H_
3142
#define _TARGET_MEM_CONFIG_H_
3243

@@ -37,9 +48,9 @@
3748
#endif
3849

3950
/**
40-
* The unit of XXXX_SIZE is Byte
41-
* For REGION_ROM, ICCM, EXT_ROM and EXT_RAM are available
42-
* For REGION_RAM, DCCM and EXT_RAM are available
51+
* DO NOT MODIFY THIS PART
52+
*
53+
* The information of memory devices on the board
4354
*/
4455
#ifdef ARC_FEATURE_ICCM_PRESENT
4556
#ifndef ICCM_SIZE
@@ -73,19 +84,47 @@
7384
#endif
7485
#endif
7586

87+
/* A fake ROM, assigned from RAM */
88+
#ifndef EXT_ROM_START
89+
#define EXT_ROM_START 0x10000000
90+
#endif
91+
92+
#ifndef EXT_ROM_SIZE
93+
#define EXT_ROM_SIZE 0x6000000
94+
#endif
95+
7696
#ifndef EXT_RAM_START
77-
#define EXT_RAM_START 0x10000000
97+
#define EXT_RAM_START 0x16000000
7898
#endif
7999

80100
#ifndef EXT_RAM_SIZE
81-
#define EXT_RAM_SIZE 0x8000000
101+
#define EXT_RAM_SIZE 0x2000000
82102
#endif
83103

84104
/**
85-
* When the mcuboot used, set the specific memory layout
105+
* The default regions assigned for application to use,
106+
by default, each region will use all the space
107+
of each memory device
108+
* User can config the start address and the size of
109+
the regions to limit the application using
86110
*/
87-
#ifdef LIB_MCUBOOT
111+
#ifndef REGION_ICCM_START
112+
#define REGION_ICCM_START ICCM_START
113+
#define REGION_ICCM_SIZE ICCM_SIZE
114+
#endif
88115

116+
#ifndef REGION_DCCM_START
117+
#define REGION_DCCM_START DCCM_START
118+
#define REGION_DCCM_SIZE DCCM_SIZE
119+
#endif
120+
121+
#ifndef REGION_EXT_RAM_START
122+
#define REGION_EXT_RAM_START EXT_RAM_START
123+
#define REGION_EXT_RAM_SIZE EXT_RAM_SIZE
124+
#endif
125+
126+
/* When the mcuboot used, need to set the specific memory layout of ROM */
127+
#ifdef LIB_MCUBOOT
89128
#ifdef USE_APPL_MEM_CONFIG
90129
#error "Cannot use USE_APPL_MEM_CONFIG to modify memory when mcuboot is enabled."
91130
#endif
@@ -101,14 +140,14 @@
101140

102141
#define FLASH_DEV_ID EMSK_DDR_RAM_ID
103142
#define FLASH_DEV_NAME
104-
#define FLASH_AREA_IMAGE_0_OFFSET EXT_RAM_START
143+
#define FLASH_AREA_IMAGE_0_OFFSET EXT_ROM_START
105144
#define FLASH_AREA_IMAGE_0_SIZE (2 * FLASH_AREA_IMAGE_SECTOR_SIZE)
106145
#define FLASH_AREA_IMAGE_1_OFFSET (FLASH_AREA_IMAGE_0_OFFSET + FLASH_AREA_IMAGE_0_SIZE)
107146
#define FLASH_AREA_IMAGE_1_SIZE (2 * FLASH_AREA_IMAGE_SECTOR_SIZE)
108147
#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (FLASH_AREA_IMAGE_1_OFFSET + FLASH_AREA_IMAGE_1_SIZE)
109148
#define FLASH_AREA_IMAGE_SCRATCH_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
110149

111-
#define FLASH_AREA_IMAGE_MCUBOOT_OFFSET 0x17000000
150+
#define FLASH_AREA_IMAGE_MCUBOOT_OFFSET 0x15000000
112151
#define FLASH_AREA_IMAGE_MCUBOOT_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
113152

114153
#define CONFIG_FLASH_BASE_ADDRESS 0
@@ -117,53 +156,58 @@
117156
#define FLASH_DRIVER_NAME FLASH_DEV_NAME
118157
#endif
119158

120-
/*
121-
* Sanity check the target support.
122-
*/
123-
#if !defined(FLASH_DRIVER_NAME) || \
124-
!defined(FLASH_ALIGN) || \
125-
!defined(FLASH_AREA_IMAGE_0_OFFSET) || \
126-
!defined(FLASH_AREA_IMAGE_0_SIZE) || \
127-
!defined(FLASH_AREA_IMAGE_1_OFFSET) || \
128-
!defined(FLASH_AREA_IMAGE_1_SIZE) || \
129-
!defined(FLASH_AREA_IMAGE_SCRATCH_OFFSET) || \
130-
!defined(FLASH_AREA_IMAGE_SCRATCH_SIZE)
159+
/* Sanity check the target support */
160+
#if !defined(FLASH_DRIVER_NAME) || !defined(FLASH_ALIGN) || \
161+
!defined(FLASH_AREA_IMAGE_0_OFFSET) || !defined(FLASH_AREA_IMAGE_0_SIZE) || \
162+
!defined(FLASH_AREA_IMAGE_1_OFFSET) || !defined(FLASH_AREA_IMAGE_1_SIZE) || \
163+
!defined(FLASH_AREA_IMAGE_SCRATCH_OFFSET) || !defined(FLASH_AREA_IMAGE_SCRATCH_SIZE)
131164
#warning "Target support is incomplete; cannot build mcuboot."
132165
#endif
133166

134167
#ifdef EMBARC_USE_MCUBOOT
135-
#define BL_RAM_START FLASH_AREA_IMAGE_MCUBOOT_OFFSET
136-
#define BL_RAM_SIZE FLASH_AREA_IMAGE_MCUBOOT_SIZE
168+
#define REGION_EXT_ROM_START FLASH_AREA_IMAGE_MCUBOOT_OFFSET
169+
#define REGION_EXT_ROM_SIZE FLASH_AREA_IMAGE_MCUBOOT_SIZE
137170
#define IMAGE_HEAD_SIZE 0x0
138171
#else
139-
#define BL_RAM_START FLASH_AREA_IMAGE_0_OFFSET
140-
#define BL_RAM_SIZE FLASH_AREA_IMAGE_0_SIZE
172+
#define REGION_EXT_ROM_START FLASH_AREA_IMAGE_0_OFFSET
173+
#define REGION_EXT_ROM_SIZE FLASH_AREA_IMAGE_0_SIZE
141174
#define IMAGE_HEAD_SIZE 0x400
142175
#endif
143176

144-
#define REGION_ROM BL_RAM
145-
#define REGION_RAM BL_RAM
177+
/* select region to generate link script */
178+
#define REGION_ROM REGION_EXT_ROM
179+
#define REGION_RAM REGION_EXT_RAM
146180

147181
#else /* !defined(LIB_MCUBOOT) */
148182

183+
#ifndef REGION_EXT_ROM_START
184+
#define REGION_EXT_ROM_START EXT_ROM_START
185+
#define REGION_EXT_ROM_SIZE EXT_ROM_SIZE
186+
#endif
187+
188+
#define IMAGE_HEAD_SIZE 0x0
189+
#endif /* LIB_MCUBOOT */
190+
191+
/**
192+
* The default regions used to generate link script
193+
* User can select region by configuring REGION_ROM and REGION_RAM
194+
* For REGION_ROM, REGION_ICCM, REGION_EXT_ROM are available
195+
* For REGION_RAM, REGION_DCCM and REGION_EXT_RAM are available
196+
*/
149197
#ifndef REGION_ROM
150198
#ifdef ARC_FEATURE_ICACHE_PRESENT
151-
#define REGION_ROM EXT_RAM
199+
#define REGION_ROM REGION_EXT_ROM
152200
#else
153-
#define REGION_ROM ICCM
201+
#define REGION_ROM REGION_ICCM
154202
#endif
155203
#endif
156204

157205
#ifndef REGION_RAM
158206
#ifdef ARC_FEATURE_DCACHE_PRESENT
159-
#define REGION_RAM EXT_RAM
207+
#define REGION_RAM REGION_EXT_ROM
160208
#else
161-
#define REGION_RAM DCCM
209+
#define REGION_RAM REGION_DCCM
162210
#endif
163211
#endif
164212

165-
#define IMAGE_HEAD_SIZE 0x0
166-
167-
#endif /* !defined(LIB_MCUBOOT) */
168-
169213
#endif /* _TARGET_MEM_CONFIG_H_ */

0 commit comments

Comments
 (0)