mirror of https://github.com/ARMmbed/mbed-os.git
M252: Make memory specification configurable
This is to support all M251 series based targets.pull/13382/head
parent
1f70a3caa2
commit
f7e4a75041
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Nuvoton Technology Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __M251_MEM_H__
|
||||
#define __M251_MEM_H__
|
||||
|
||||
/* About M251_mem.h/M251_mem.icf.h
|
||||
*
|
||||
* 1. M251_mem.h is created for centralizing memory configuration. It will be included by C/C++ files
|
||||
* and linker files (except IAR linker file).
|
||||
* 2. IAR linker doesn't support preprocessor, so M251_mem.icf.h, duplicate of M251_mem.h
|
||||
* is created for IAR linker file.
|
||||
* 3. To continue above, we name M251_mem.icf.h instead of M251_mem.icf because:
|
||||
* (1) Mbed OS build tool may mis-regard M251_mem.icf as the main linker configuration file.
|
||||
* (2) *.icf files may not be present in search directories for "include" directive. Per observation,
|
||||
* the search directories are inconsistent among normal example build and test code build. To address
|
||||
* it, we name M251_mem.icf.h instead because *.h files are always present in these builds
|
||||
* (already there or via copy).
|
||||
*/
|
||||
|
||||
/* Default memory specification
|
||||
*
|
||||
* Flash size: 256KiB
|
||||
* SRAM size: 32KiB
|
||||
*/
|
||||
|
||||
/* Resolve ROM start */
|
||||
#ifndef MBED_ROM_START
|
||||
#define MBED_ROM_START (0x0)
|
||||
#endif
|
||||
|
||||
/* Resolve ROM size */
|
||||
#ifndef MBED_ROM_SIZE
|
||||
#define MBED_ROM_SIZE (0x40000)
|
||||
#endif
|
||||
|
||||
/* Resolve RAM start */
|
||||
#ifndef MBED_RAM_START
|
||||
#define MBED_RAM_START (0x20000000)
|
||||
#endif
|
||||
|
||||
/* Resolve RAM size */
|
||||
#ifndef MBED_RAM_SIZE
|
||||
#define MBED_RAM_SIZE (0x8000)
|
||||
#endif
|
||||
|
||||
|
||||
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
|
||||
* MBED_APP_xxx macros to linker files even though they mean the same thing.
|
||||
* Because this file is to include by both C/C++ files and linker files, we add
|
||||
* these macros according to the others for consistency when they are missing
|
||||
* in compile or link stage. */
|
||||
|
||||
#ifndef APPLICATION_ADDR
|
||||
#ifdef MBED_APP_START
|
||||
#define APPLICATION_ADDR MBED_APP_START
|
||||
#else
|
||||
#define APPLICATION_ADDR MBED_ROM_START
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef APPLICATION_SIZE
|
||||
#ifdef MBED_APP_SIZE
|
||||
#define APPLICATION_SIZE MBED_APP_SIZE
|
||||
#else
|
||||
#define APPLICATION_SIZE MBED_ROM_SIZE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef APPLICATION_RAM_ADDR
|
||||
#ifdef MBED_RAM_APP_START
|
||||
#define APPLICATION_RAM_ADDR MBED_RAM_APP_START
|
||||
#else
|
||||
#define APPLICATION_RAM_ADDR MBED_RAM_START
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef APPLICATION_RAM_SIZE
|
||||
#ifdef MBED_RAM_APP_SIZE
|
||||
#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE
|
||||
#else
|
||||
#define APPLICATION_RAM_SIZE MBED_RAM_SIZE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MBED_APP_START
|
||||
#define MBED_APP_START APPLICATION_ADDR
|
||||
#endif
|
||||
|
||||
#ifndef MBED_APP_SIZE
|
||||
#define MBED_APP_SIZE APPLICATION_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef MBED_RAM_APP_START
|
||||
#define MBED_RAM_APP_START APPLICATION_RAM_ADDR
|
||||
#endif
|
||||
|
||||
#ifndef MBED_RAM_APP_SIZE
|
||||
#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE
|
||||
#endif
|
||||
|
||||
#if (APPLICATION_ADDR != MBED_APP_START)
|
||||
#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!")
|
||||
#endif
|
||||
|
||||
#if (APPLICATION_SIZE != MBED_APP_SIZE)
|
||||
#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!")
|
||||
#endif
|
||||
|
||||
#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START)
|
||||
#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!")
|
||||
#endif
|
||||
|
||||
#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE)
|
||||
#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!")
|
||||
#endif
|
||||
|
||||
#endif /* __M251_MEM_H__ */
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Nuvoton Technology Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* See M251_mem.h for documentation */
|
||||
|
||||
/* Default memory specification
|
||||
*
|
||||
* Flash size: 256KiB
|
||||
* SRAM size: 32KiB
|
||||
*/
|
||||
|
||||
/* Resolve ROM start */
|
||||
if (!isdefinedsymbol(MBED_ROM_START)) {
|
||||
define symbol MBED_ROM_START = 0x0;
|
||||
}
|
||||
|
||||
/* Resolve ROM size */
|
||||
if (!isdefinedsymbol(MBED_ROM_SIZE)) {
|
||||
define symbol MBED_ROM_SIZE = 0x40000;
|
||||
}
|
||||
|
||||
/* Resolve RAM start */
|
||||
if (!isdefinedsymbol(MBED_RAM_START)) {
|
||||
define symbol MBED_RAM_START = 0x20000000;
|
||||
}
|
||||
|
||||
/* Resolve RAM size */
|
||||
if (!isdefinedsymbol(MBED_RAM_SIZE)) {
|
||||
define symbol MBED_RAM_SIZE = 0x8000;
|
||||
}
|
||||
|
||||
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
|
||||
* MBED_APP_xxx macros to linker files even though they mean the same thing.
|
||||
* Because this file is to include by both C/C++ files and linker files, we add
|
||||
* these macros according to the others for consistency when they are missing
|
||||
* in compile or link stage. */
|
||||
|
||||
if (!isdefinedsymbol(APPLICATION_ADDR)) {
|
||||
if (isdefinedsymbol(MBED_APP_START)) {
|
||||
define symbol APPLICATION_ADDR = MBED_APP_START;
|
||||
} else {
|
||||
define symbol APPLICATION_ADDR = MBED_ROM_START;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isdefinedsymbol(APPLICATION_SIZE)) {
|
||||
if (isdefinedsymbol(MBED_APP_SIZE)) {
|
||||
define symbol APPLICATION_SIZE = MBED_APP_SIZE;
|
||||
} else {
|
||||
define symbol APPLICATION_SIZE = MBED_ROM_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) {
|
||||
if (isdefinedsymbol(MBED_RAM_APP_START)) {
|
||||
define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START;
|
||||
} else {
|
||||
define symbol APPLICATION_RAM_ADDR = MBED_RAM_START;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) {
|
||||
if (isdefinedsymbol(MBED_RAM_APP_SIZE)) {
|
||||
define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE;
|
||||
} else {
|
||||
define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isdefinedsymbol(MBED_APP_START)) {
|
||||
define symbol MBED_APP_START = APPLICATION_ADDR;
|
||||
}
|
||||
|
||||
if (!isdefinedsymbol(MBED_APP_SIZE)) {
|
||||
define symbol MBED_APP_SIZE = APPLICATION_SIZE;
|
||||
}
|
||||
|
||||
if (!isdefinedsymbol(MBED_RAM_APP_START)) {
|
||||
define symbol MBED_RAM_APP_START = APPLICATION_RAM_ADDR;
|
||||
}
|
||||
|
||||
if (!isdefinedsymbol(MBED_RAM_APP_SIZE)) {
|
||||
define symbol MBED_RAM_APP_SIZE = APPLICATION_RAM_SIZE;
|
||||
}
|
||||
|
||||
if (APPLICATION_ADDR != MBED_APP_START) {
|
||||
error "APPLICATION_ADDR and MBED_APP_START are not the same!!!";
|
||||
}
|
||||
|
||||
if (APPLICATION_SIZE != MBED_APP_SIZE) {
|
||||
error "APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!";
|
||||
}
|
||||
|
||||
if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) {
|
||||
error "APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!";
|
||||
}
|
||||
|
||||
if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) {
|
||||
error "APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!";
|
||||
}
|
||||
|
|
@ -18,27 +18,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if !defined(MBED_APP_START)
|
||||
#define MBED_APP_START 0x00000000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_APP_SIZE)
|
||||
#define MBED_APP_SIZE 0x00040000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_RAM_APP_START)
|
||||
#define MBED_RAM_APP_START 0x20000000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_RAM_APP_SIZE)
|
||||
#define MBED_RAM_APP_SIZE 0x8000
|
||||
#endif
|
||||
#include "../M251_mem.h"
|
||||
|
||||
#if !defined(MBED_BOOT_STACK_SIZE)
|
||||
#define MBED_BOOT_STACK_SIZE 0x400
|
||||
#endif
|
||||
|
||||
LR_IROM1 MBED_APP_START
|
||||
#define VECTOR_SIZE (4*(16 + 64))
|
||||
|
||||
LR_IROM1 MBED_APP_START MBED_APP_SIZE
|
||||
{
|
||||
/* load address = execution address */
|
||||
ER_IROM1 +0
|
||||
|
|
@ -56,7 +44,7 @@ LR_IROM1 MBED_APP_START
|
|||
*
|
||||
* Vector table base address is required to be 128-byte aligned at a minimum.
|
||||
* A PE might impose further restrictions on it. */
|
||||
ER_IRAMVEC AlignExpr(+0, 128) EMPTY (4*(16 + 64))
|
||||
ER_IRAMVEC AlignExpr(+0, 128) EMPTY VECTOR_SIZE
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,21 +18,7 @@
|
|||
|
||||
/* Nuvoton M251 GCC linker script file */
|
||||
|
||||
#if !defined(MBED_APP_START)
|
||||
#define MBED_APP_START 0x00000000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_APP_SIZE)
|
||||
#define MBED_APP_SIZE 0x00040000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_RAM_APP_START)
|
||||
#define MBED_RAM_APP_START 0x20000000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_RAM_APP_SIZE)
|
||||
#define MBED_RAM_APP_SIZE 0x8000
|
||||
#endif
|
||||
#include "../M251_mem.h"
|
||||
|
||||
#if !defined(MBED_BOOT_STACK_SIZE)
|
||||
#define MBED_BOOT_STACK_SIZE 0x400
|
||||
|
|
|
|||
|
|
@ -20,22 +20,7 @@
|
|||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
|
||||
if (! isdefinedsymbol(MBED_APP_START)) {
|
||||
define symbol MBED_APP_START = 0x00000000;
|
||||
}
|
||||
|
||||
if (! isdefinedsymbol(MBED_APP_SIZE)) {
|
||||
define symbol MBED_APP_SIZE = 0x00040000;
|
||||
}
|
||||
|
||||
if (! isdefinedsymbol(MBED_RAM_APP_START)) {
|
||||
define symbol MBED_RAM_APP_START = 0x20000000;
|
||||
}
|
||||
|
||||
|
||||
if (! isdefinedsymbol(MBED_RAM_APP_SIZE)) {
|
||||
define symbol MBED_RAM_APP_SIZE = 0x8000;
|
||||
}
|
||||
include "../M251_mem.icf.h";
|
||||
|
||||
if (! isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
|
||||
define symbol MBED_BOOT_STACK_SIZE = 0x400;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "flash_data.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "M251_mem.h"
|
||||
|
||||
// This is a flash algo binary blob. It is PIC (position independent code) that should be stored in RAM
|
||||
// NOTE: On ARMv7-M/ARMv8-M, instruction fetches are always little-endian.
|
||||
|
|
@ -93,7 +94,7 @@ static const flash_algo_t flash_algo_config = {
|
|||
|
||||
/* Secure flash */
|
||||
static const sector_info_t sectors_info[] = {
|
||||
{0x0, 0x200}, // (start, sector size)
|
||||
{MBED_ROM_START, 0x200}, // (start, sector size)
|
||||
};
|
||||
|
||||
/* Secure flash */
|
||||
|
|
@ -101,8 +102,8 @@ static const flash_target_config_t flash_target_config = {
|
|||
.page_size = 4, // 4 bytes
|
||||
// Here page_size is program unit, which is different
|
||||
// than FMC definition.
|
||||
.flash_start = 0x0,
|
||||
.flash_size = 0x40000,
|
||||
.flash_start = MBED_ROM_START,
|
||||
.flash_size = MBED_ROM_SIZE,
|
||||
.sectors = sectors_info,
|
||||
.sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t)
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue