Skip to content

Commit 12b69ce

Browse files
BabaYBIRISZZW
authored andcommitted
src: modify simple bootloader fits more boot cases
Signed-off-by: Yiping Peng <yibingp@synopsys.com>
1 parent 01bf812 commit 12b69ce

File tree

20 files changed

+518
-443
lines changed

20 files changed

+518
-443
lines changed

board/emsk/configs/11/target_mem_config.h

Lines changed: 66 additions & 87 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:
@@ -30,92 +30,6 @@
3030
#ifndef _TARGET_MEM_CONFIG_H_
3131
#define _TARGET_MEM_CONFIG_H_
3232

33-
#ifdef LIB_MCUBOOT
34-
35-
#ifdef USE_APPL_MEM_CONFIG
36-
#error "Cannot use USE_APPL_MEM_CONFIG to modify memory when mcuboot is enabled."
37-
#endif
38-
39-
#if defined(MCUBOOT_TARGET_CONFIG)
40-
/*
41-
* Target-specific definitions are permitted in legacy cases that
42-
* don't provide the information via DTS, etc.
43-
*/
44-
#include MCUBOOT_TARGET_CONFIG
45-
#else
46-
/*
47-
* Otherwise, the Zephyr SoC header and the DTS provide most
48-
* everything we need.
49-
*/
50-
#ifndef FLASH_ALIGN
51-
#define FLASH_ALIGNMENT 8
52-
#define FLASH_ALIGN FLASH_ALIGNMENT
53-
#endif
54-
55-
#define FLASH_DEV_ID EMSK_DDR_RAM_ID
56-
#define FLASH_DEV_NAME
57-
#define FLASH_AREA_IMAGE_0_OFFSET 0x10000000
58-
#define FLASH_AREA_IMAGE_0_SIZE 0x00400000
59-
#define FLASH_AREA_IMAGE_1_OFFSET 0x10400000
60-
#define FLASH_AREA_IMAGE_1_SIZE 0x00400000
61-
#define FLASH_AREA_IMAGE_SCRATCH_OFFSET 0x10800000
62-
#define FLASH_AREA_IMAGE_SCRATCH_SIZE 0x00200000
63-
#define FLASH_AREA_IMAGE_MCUBOOT_OFFSET 0x17000000
64-
#define FLASH_AREA_IMAGE_MCUBOOT_SIZE 0x00200000
65-
66-
67-
#if !defined(FLASH_AREA_IMAGE_SECTOR_SIZE)
68-
#define FLASH_AREA_IMAGE_SECTOR_SIZE FLASH_AREA_IMAGE_SCRATCH_SIZE
69-
#endif
70-
71-
#define CONFIG_FLASH_BASE_ADDRESS 0
72-
73-
74-
/*
75-
* TODO: remove soc_family_kinetis.h once its flash driver supports
76-
* FLASH_PAGE_LAYOUT.
77-
*/
78-
#endif /* !defined(MCUBOOT_TARGET_CONFIG) */
79-
80-
/*
81-
* Upstream Zephyr changed the name from FLASH_DRIVER_NAME to
82-
* FLASH_DEV_NAME. For now, let's just convert the Zephyr name to the
83-
* one expected by MCUboot. This can be cleaned up after the upstream
84-
* Zephyr tree has been released and settled down.
85-
*/
86-
#if !defined(FLASH_DRIVER_NAME) && defined(FLASH_DEV_NAME)
87-
#define FLASH_DRIVER_NAME FLASH_DEV_NAME
88-
#endif
89-
90-
/*
91-
* Sanity check the target support.
92-
*/
93-
#if !defined(FLASH_DRIVER_NAME) || \
94-
!defined(FLASH_ALIGN) || \
95-
!defined(FLASH_AREA_IMAGE_0_OFFSET) || \
96-
!defined(FLASH_AREA_IMAGE_0_SIZE) || \
97-
!defined(FLASH_AREA_IMAGE_1_OFFSET) || \
98-
!defined(FLASH_AREA_IMAGE_1_SIZE) || \
99-
!defined(FLASH_AREA_IMAGE_SCRATCH_OFFSET) || \
100-
!defined(FLASH_AREA_IMAGE_SCRATCH_SIZE)
101-
#warning "Target support is incomplete; cannot build mcuboot."
102-
#endif
103-
104-
#ifdef EMBARC_USE_MCUBOOT
105-
#define EXT_RAM_START FLASH_AREA_IMAGE_MCUBOOT_OFFSET
106-
#define EXT_RAM_SIZE FLASH_AREA_IMAGE_MCUBOOT_SIZE
107-
#define IMAGE_HEAD_SIZE 0x0
108-
#else
109-
#define EXT_RAM_START FLASH_AREA_IMAGE_0_OFFSET
110-
#define EXT_RAM_SIZE FLASH_AREA_IMAGE_0_SIZE
111-
#define IMAGE_HEAD_SIZE 0x400
112-
#endif
113-
114-
#define REGION_ROM EXT_RAM
115-
#define REGION_RAM EXT_RAM
116-
117-
#else /* !defined(LIB_MCUBOOT) */
118-
11933
#include "arc_feature_config.h"
12034

12135
#ifdef USE_APPL_MEM_CONFIG
@@ -167,6 +81,71 @@
16781
#define EXT_RAM_SIZE 0x8000000
16882
#endif
16983

84+
/**
85+
* When the mcuboot used, set the specific memory layout
86+
*/
87+
#ifdef LIB_MCUBOOT
88+
89+
#ifdef USE_APPL_MEM_CONFIG
90+
#error "Cannot use USE_APPL_MEM_CONFIG to modify memory when mcuboot is enabled."
91+
#endif
92+
93+
#ifndef FLASH_ALIGN
94+
#define FLASH_ALIGNMENT 8
95+
#define FLASH_ALIGN FLASH_ALIGNMENT
96+
#endif
97+
98+
#if !defined(FLASH_AREA_IMAGE_SECTOR_SIZE)
99+
#define FLASH_AREA_IMAGE_SECTOR_SIZE 0x00200000
100+
#endif
101+
102+
#define FLASH_DEV_ID EMSK_DDR_RAM_ID
103+
#define FLASH_DEV_NAME
104+
#define FLASH_AREA_IMAGE_0_OFFSET EXT_RAM_START
105+
#define FLASH_AREA_IMAGE_0_SIZE (2 * FLASH_AREA_IMAGE_SECTOR_SIZE)
106+
#define FLASH_AREA_IMAGE_1_OFFSET (FLASH_AREA_IMAGE_0_OFFSET + FLASH_AREA_IMAGE_0_SIZE)
107+
#define FLASH_AREA_IMAGE_1_SIZE (2 * FLASH_AREA_IMAGE_SECTOR_SIZE)
108+
#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (FLASH_AREA_IMAGE_1_OFFSET + FLASH_AREA_IMAGE_1_SIZE)
109+
#define FLASH_AREA_IMAGE_SCRATCH_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
110+
111+
#define FLASH_AREA_IMAGE_MCUBOOT_OFFSET 0x17000000
112+
#define FLASH_AREA_IMAGE_MCUBOOT_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
113+
114+
#define CONFIG_FLASH_BASE_ADDRESS 0
115+
116+
#if !defined(FLASH_DRIVER_NAME) && defined(FLASH_DEV_NAME)
117+
#define FLASH_DRIVER_NAME FLASH_DEV_NAME
118+
#endif
119+
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)
131+
#warning "Target support is incomplete; cannot build mcuboot."
132+
#endif
133+
134+
#ifdef EMBARC_USE_MCUBOOT
135+
#define BL_RAM_START FLASH_AREA_IMAGE_MCUBOOT_OFFSET
136+
#define BL_RAM_SIZE FLASH_AREA_IMAGE_MCUBOOT_SIZE
137+
#define IMAGE_HEAD_SIZE 0x0
138+
#else
139+
#define BL_RAM_START FLASH_AREA_IMAGE_0_OFFSET
140+
#define BL_RAM_SIZE FLASH_AREA_IMAGE_0_SIZE
141+
#define IMAGE_HEAD_SIZE 0x400
142+
#endif
143+
144+
#define REGION_ROM BL_RAM
145+
#define REGION_RAM BL_RAM
146+
147+
#else /* !defined(LIB_MCUBOOT) */
148+
170149
#ifndef REGION_ROM
171150
#ifdef ARC_FEATURE_ICACHE_PRESENT
172151
#define REGION_ROM EXT_RAM

board/emsk/configs/22/target_mem_config.h

Lines changed: 66 additions & 87 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:
@@ -30,92 +30,6 @@
3030
#ifndef _TARGET_MEM_CONFIG_H_
3131
#define _TARGET_MEM_CONFIG_H_
3232

33-
#ifdef LIB_MCUBOOT
34-
35-
#ifdef USE_APPL_MEM_CONFIG
36-
#error "Cannot use USE_APPL_MEM_CONFIG to modify memory when mcuboot is enabled."
37-
#endif
38-
39-
#if defined(MCUBOOT_TARGET_CONFIG)
40-
/*
41-
* Target-specific definitions are permitted in legacy cases that
42-
* don't provide the information via DTS, etc.
43-
*/
44-
#include MCUBOOT_TARGET_CONFIG
45-
#else
46-
/*
47-
* Otherwise, the Zephyr SoC header and the DTS provide most
48-
* everything we need.
49-
*/
50-
#ifndef FLASH_ALIGN
51-
#define FLASH_ALIGNMENT 8
52-
#define FLASH_ALIGN FLASH_ALIGNMENT
53-
#endif
54-
55-
#define FLASH_DEV_ID EMSK_DDR_RAM_ID
56-
#define FLASH_DEV_NAME
57-
#define FLASH_AREA_IMAGE_0_OFFSET 0x10000000
58-
#define FLASH_AREA_IMAGE_0_SIZE 0x00400000
59-
#define FLASH_AREA_IMAGE_1_OFFSET 0x10400000
60-
#define FLASH_AREA_IMAGE_1_SIZE 0x00400000
61-
#define FLASH_AREA_IMAGE_SCRATCH_OFFSET 0x10800000
62-
#define FLASH_AREA_IMAGE_SCRATCH_SIZE 0x00200000
63-
#define FLASH_AREA_IMAGE_MCUBOOT_OFFSET 0x17000000
64-
#define FLASH_AREA_IMAGE_MCUBOOT_SIZE 0x00200000
65-
66-
67-
#if !defined(FLASH_AREA_IMAGE_SECTOR_SIZE)
68-
#define FLASH_AREA_IMAGE_SECTOR_SIZE FLASH_AREA_IMAGE_SCRATCH_SIZE
69-
#endif
70-
71-
#define CONFIG_FLASH_BASE_ADDRESS 0
72-
73-
74-
/*
75-
* TODO: remove soc_family_kinetis.h once its flash driver supports
76-
* FLASH_PAGE_LAYOUT.
77-
*/
78-
#endif /* !defined(MCUBOOT_TARGET_CONFIG) */
79-
80-
/*
81-
* Upstream Zephyr changed the name from FLASH_DRIVER_NAME to
82-
* FLASH_DEV_NAME. For now, let's just convert the Zephyr name to the
83-
* one expected by MCUboot. This can be cleaned up after the upstream
84-
* Zephyr tree has been released and settled down.
85-
*/
86-
#if !defined(FLASH_DRIVER_NAME) && defined(FLASH_DEV_NAME)
87-
#define FLASH_DRIVER_NAME FLASH_DEV_NAME
88-
#endif
89-
90-
/*
91-
* Sanity check the target support.
92-
*/
93-
#if !defined(FLASH_DRIVER_NAME) || \
94-
!defined(FLASH_ALIGN) || \
95-
!defined(FLASH_AREA_IMAGE_0_OFFSET) || \
96-
!defined(FLASH_AREA_IMAGE_0_SIZE) || \
97-
!defined(FLASH_AREA_IMAGE_1_OFFSET) || \
98-
!defined(FLASH_AREA_IMAGE_1_SIZE) || \
99-
!defined(FLASH_AREA_IMAGE_SCRATCH_OFFSET) || \
100-
!defined(FLASH_AREA_IMAGE_SCRATCH_SIZE)
101-
#warning "Target support is incomplete; cannot build mcuboot."
102-
#endif
103-
104-
#ifdef EMBARC_USE_MCUBOOT
105-
#define EXT_RAM_START FLASH_AREA_IMAGE_MCUBOOT_OFFSET
106-
#define EXT_RAM_SIZE FLASH_AREA_IMAGE_MCUBOOT_SIZE
107-
#define IMAGE_HEAD_SIZE 0x0
108-
#else
109-
#define EXT_RAM_START FLASH_AREA_IMAGE_0_OFFSET
110-
#define EXT_RAM_SIZE FLASH_AREA_IMAGE_0_SIZE
111-
#define IMAGE_HEAD_SIZE 0x400
112-
#endif
113-
114-
#define REGION_ROM EXT_RAM
115-
#define REGION_RAM EXT_RAM
116-
117-
#else /* !defined(LIB_MCUBOOT) */
118-
11933
#include "arc_feature_config.h"
12034

12135
#ifdef USE_APPL_MEM_CONFIG
@@ -167,6 +81,71 @@
16781
#define EXT_RAM_SIZE 0x8000000
16882
#endif
16983

84+
/**
85+
* When the mcuboot used, set the specific memory layout
86+
*/
87+
#ifdef LIB_MCUBOOT
88+
89+
#ifdef USE_APPL_MEM_CONFIG
90+
#error "Cannot use USE_APPL_MEM_CONFIG to modify memory when mcuboot is enabled."
91+
#endif
92+
93+
#ifndef FLASH_ALIGN
94+
#define FLASH_ALIGNMENT 8
95+
#define FLASH_ALIGN FLASH_ALIGNMENT
96+
#endif
97+
98+
#if !defined(FLASH_AREA_IMAGE_SECTOR_SIZE)
99+
#define FLASH_AREA_IMAGE_SECTOR_SIZE 0x00200000
100+
#endif
101+
102+
#define FLASH_DEV_ID EMSK_DDR_RAM_ID
103+
#define FLASH_DEV_NAME
104+
#define FLASH_AREA_IMAGE_0_OFFSET EXT_RAM_START
105+
#define FLASH_AREA_IMAGE_0_SIZE (2 * FLASH_AREA_IMAGE_SECTOR_SIZE)
106+
#define FLASH_AREA_IMAGE_1_OFFSET (FLASH_AREA_IMAGE_0_OFFSET + FLASH_AREA_IMAGE_0_SIZE)
107+
#define FLASH_AREA_IMAGE_1_SIZE (2 * FLASH_AREA_IMAGE_SECTOR_SIZE)
108+
#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (FLASH_AREA_IMAGE_1_OFFSET + FLASH_AREA_IMAGE_1_SIZE)
109+
#define FLASH_AREA_IMAGE_SCRATCH_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
110+
111+
#define FLASH_AREA_IMAGE_MCUBOOT_OFFSET 0x17000000
112+
#define FLASH_AREA_IMAGE_MCUBOOT_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
113+
114+
#define CONFIG_FLASH_BASE_ADDRESS 0
115+
116+
#if !defined(FLASH_DRIVER_NAME) && defined(FLASH_DEV_NAME)
117+
#define FLASH_DRIVER_NAME FLASH_DEV_NAME
118+
#endif
119+
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)
131+
#warning "Target support is incomplete; cannot build mcuboot."
132+
#endif
133+
134+
#ifdef EMBARC_USE_MCUBOOT
135+
#define BL_RAM_START FLASH_AREA_IMAGE_MCUBOOT_OFFSET
136+
#define BL_RAM_SIZE FLASH_AREA_IMAGE_MCUBOOT_SIZE
137+
#define IMAGE_HEAD_SIZE 0x0
138+
#else
139+
#define BL_RAM_START FLASH_AREA_IMAGE_0_OFFSET
140+
#define BL_RAM_SIZE FLASH_AREA_IMAGE_0_SIZE
141+
#define IMAGE_HEAD_SIZE 0x400
142+
#endif
143+
144+
#define REGION_ROM BL_RAM
145+
#define REGION_RAM BL_RAM
146+
147+
#else /* !defined(LIB_MCUBOOT) */
148+
170149
#ifndef REGION_ROM
171150
#ifdef ARC_FEATURE_ICACHE_PRESENT
172151
#define REGION_ROM EXT_RAM

0 commit comments

Comments
 (0)