Merge pull request #8702 from SenRamakri/sen_CrashReportingImpl

Crash Reporting implementation
pull/8863/head
Martin Kojtal 2018-11-23 20:24:53 +01:00 committed by GitHub
commit 52aea31655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 1036 additions and 60 deletions

View File

@ -0,0 +1,73 @@
"""
Copyright (c) 2018 ARM Limited
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.
"""
import time
from mbed_host_tests import BaseHostTest
from mbed_host_tests.host_tests_runner.host_test_default import DefaultTestSelector
DEFAULT_CYCLE_PERIOD = 10.0
MSG_VALUE_DUMMY = '0'
MSG_KEY_DEVICE_READY = 'crash_reporting_ready'
MSG_KEY_DEVICE_ERROR = 'crash_reporting_inject_error'
MSG_KEY_SYNC = '__sync'
class CrashReportingTest(BaseHostTest):
"""Test for the crash reporting feature.
"""
def __init__(self):
super(CrashReportingTest, self).__init__()
self.reset = False
self.test_steps_sequence = self.test_steps()
# Advance the coroutine to it's first yield statement.
self.test_steps_sequence.send(None)
def setup(self):
self.register_callback(MSG_KEY_DEVICE_READY, self.cb_device_ready)
def cb_device_ready(self, key, value, timestamp):
"""Acknowledge device rebooted correctly and feed the test execution
"""
self.reset = True
try:
if self.test_steps_sequence.send(value):
self.notify_complete(True)
except (StopIteration, RuntimeError) as exc:
self.notify_complete(False)
def test_steps(self):
"""Reset the device and check the status
"""
system_reset = yield
self.reset = False
wait_after_reset = self.get_config_item('forced_reset_timeout')
wait_after_reset = wait_after_reset if wait_after_reset is not None else DEFAULT_CYCLE_PERIOD
#Wait 2 seconds for system to init
time.sleep(2.0)
#self.send_kv(MSG_KEY_SYNC, MSG_VALUE_DUMMY)
self.send_kv(MSG_KEY_DEVICE_ERROR, MSG_VALUE_DUMMY)
time.sleep(5.0)
system_reset = yield
if self.reset == False:
raise RuntimeError('Platform did not auto-reboot as expected.')
# The sequence is correct -- test passed.
yield True

View File

@ -0,0 +1,75 @@
/* mbed Microcontroller Library
* Copyright (c) 2018 ARM Limited
*
* 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.
*/
#include "mbed.h"
#include "mbed_error.h"
#include "mbed_crash_data_offsets.h"
#include "greentea-client/test_env.h"
#include "unity/unity.h"
#if !MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
#error [NOT_SUPPORTED] crash_reporting test not supported
#endif
#define MSG_VALUE_DUMMY "0"
#define MSG_VALUE_LEN 32
#define MSG_KEY_LEN 64
#define MSG_KEY_DEVICE_READY "crash_reporting_ready"
#define MSG_KEY_DEVICE_ERROR "crash_reporting_inject_error"
static mbed_error_ctx saved_error_ctx = {0};
void mbed_error_reboot_callback(mbed_error_ctx *error_context)
{
TEST_ASSERT_EQUAL_UINT((uint32_t)error_context, ERROR_CONTEXT_LOCATION);
memcpy(&saved_error_ctx, error_context, sizeof(mbed_error_ctx));
mbed_reset_reboot_error_info();
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_OUT_OF_MEMORY, saved_error_ctx.error_status);
TEST_ASSERT_EQUAL_UINT(1, saved_error_ctx.error_reboot_count);
//Send the ready msg to host to indicate test pass
greentea_send_kv(MSG_KEY_DEVICE_READY, MSG_VALUE_DUMMY);
}
void test_crash_reporting()
{
//Clear any previous status
mbed_reset_reboot_error_info();
// Report readiness
greentea_send_kv(MSG_KEY_DEVICE_READY, MSG_VALUE_DUMMY);
static char _key[MSG_KEY_LEN + 1] = { };
static char _value[MSG_VALUE_LEN + 1] = { };
greentea_parse_kv(_key, _value, MSG_KEY_LEN, MSG_VALUE_LEN);
if (strcmp(_key, MSG_KEY_DEVICE_ERROR) == 0) {
MBED_ERROR1(MBED_ERROR_OUT_OF_MEMORY, "Executing crash reporting test.", 0xDEADBAD);
TEST_ASSERT_MESSAGE(0, "crash_reporting() error call failed.");
}
TEST_ASSERT_MESSAGE(0, "Unexpected message received.");
}
int main(void)
{
GREENTEA_SETUP(30, "crash_reporting");
test_crash_reporting();
GREENTEA_TESTSUITE_RESULT(0);
return 0;
}

View File

@ -80,7 +80,8 @@ Fault_Handler PROC
Fault_Handler_Continue
MOV R12,R3
LDR R1,=mbed_fault_context
LDR R3,=mbed_fault_context
LDR R1,[R3]
LDR R2,[R0] ; Capture R0
STR R2,[R1]
ADDS R1,#4

View File

@ -113,7 +113,8 @@ Fault_Handler:
Fault_Handler_Continue:
MOV R12,R3
LDR R1,=mbed_fault_context
LDR R3,=mbed_fault_context
LDR R1,[R3]
LDR R2,[R0] // Capture R0
STR R2,[R1]
ADDS R1,#4

View File

@ -75,7 +75,8 @@ Fault_Handler
Fault_Handler_Continue
MOV R12,R3
LDR R1,=mbed_fault_context
LDR R3,=mbed_fault_context
LDR R1,[R3]
LDR R2,[R0] ; Capture R0
STR R2,[R1]
ADDS R1,#4

View File

@ -20,8 +20,9 @@
#include <inttypes.h>
#include "device.h"
#include "platform/mbed_error.h"
#include "platform/mbed_interface.h"
#include "mbed_error.h"
#include "mbed_interface.h"
#include "mbed_crash_data_offsets.h"
#ifndef MBED_FAULT_HANDLER_DISABLED
#include "mbed_fault_handler.h"
@ -29,8 +30,13 @@
//Functions Prototypes
void print_context_info(void);
//Global for populating the context in exception handler
mbed_fault_context_t mbed_fault_context;
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
//Global for populating the context in exception handler
mbed_fault_context_t *const mbed_fault_context=(mbed_fault_context_t *)(FAULT_CONTEXT_LOCATION);
#else
mbed_fault_context_t fault_context;
mbed_fault_context_t *const mbed_fault_context=(mbed_fault_context_t *)&fault_context;
#endif
//This is a handler function called from Fault handler to print the error information out.
//This runs in fault context and uses special functions(defined in mbed_rtx_fault_handler.c) to print the information without using C-lib support.
@ -69,7 +75,7 @@ void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in)
mbed_error_printf("\n\n-- MbedOS Fault Handler --\n\n");
//Now call mbed_error, to log the error and halt the system
mbed_error( faultStatus, "Fault exception", mbed_fault_context.PC_reg, NULL, 0 );
mbed_error( faultStatus, "Fault exception", mbed_fault_context->PC_reg, NULL, 0 );
}
@ -77,7 +83,7 @@ MBED_NOINLINE void print_context_info(void)
{
//Context Regs
for(int i=0;i<13;i++) {
mbed_error_printf("\nR%-4d: %08" PRIX32, i, ((uint32_t *)&mbed_fault_context)[i]);
mbed_error_printf("\nR%-4d: %08" PRIX32, i, ((uint32_t *)(mbed_fault_context))[i]);
}
mbed_error_printf("\nSP : %08" PRIX32
@ -85,8 +91,8 @@ MBED_NOINLINE void print_context_info(void)
"\nPC : %08" PRIX32
"\nxPSR : %08" PRIX32
"\nPSP : %08" PRIX32
"\nMSP : %08" PRIX32, mbed_fault_context.SP_reg, mbed_fault_context.LR_reg, mbed_fault_context.PC_reg,
mbed_fault_context.xPSR, mbed_fault_context.PSP, mbed_fault_context.MSP );
"\nMSP : %08" PRIX32, mbed_fault_context->SP_reg, mbed_fault_context->LR_reg, mbed_fault_context->PC_reg,
mbed_fault_context->xPSR, mbed_fault_context->PSP, mbed_fault_context->MSP );
//Capture CPUID to get core/cpu info
mbed_error_printf("\nCPUID: %08" PRIX32, SCB->CPUID);
@ -112,12 +118,12 @@ MBED_NOINLINE void print_context_info(void)
#endif
//Print Mode
if (mbed_fault_context.EXC_RETURN & 0x8) {
if (mbed_fault_context->EXC_RETURN & 0x8) {
mbed_error_printf("\nMode : Thread");
//Print Priv level in Thread mode - We capture CONTROL reg which reflects the privilege.
//Note that the CONTROL register captured still reflects the privilege status of the
//thread mode eventhough we are in Handler mode by the time we capture it.
if(mbed_fault_context.CONTROL & 0x1) {
if(mbed_fault_context->CONTROL & 0x1) {
mbed_error_printf("\nPriv : User");
} else {
mbed_error_printf("\nPriv : Privileged");
@ -127,11 +133,23 @@ MBED_NOINLINE void print_context_info(void)
mbed_error_printf("\nPriv : Privileged");
}
//Print Return Stack
if (mbed_fault_context.EXC_RETURN & 0x4) {
if (mbed_fault_context->EXC_RETURN & 0x4) {
mbed_error_printf("\nStack: PSP");
} else {
mbed_error_printf("\nStack: MSP");
}
}
mbed_error_status_t mbed_get_reboot_fault_context (mbed_fault_context_t *fault_context)
{
mbed_error_status_t status = MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_ITEM_NOT_FOUND);
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
if(fault_context == NULL)
return MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INVALID_ARGUMENT);
memcpy(fault_context, mbed_fault_context, sizeof(mbed_fault_context_t));
status = MBED_SUCCESS;
#endif
return status;
}
#endif //MBED_FAULT_HANDLER_SUPPORT

View File

@ -15,7 +15,11 @@
*/
#ifndef MBED_FAULT_HANDLER_H
#define MBED_FAULT_HANDLER_H
#define MBED_FAULT_HANDLER_H
#ifdef __cplusplus
extern "C" {
#endif
//Fault context struct
//WARNING: DO NOT CHANGE THIS STRUCT WITHOUT MAKING CORRESPONDING CHANGES in except.S files.
@ -55,4 +59,18 @@ typedef struct {
//This runs in fault context and uses special functions(defined in mbed_fault_handler.c) to print the information without using C-lib support.
void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in);
/**
* Call this function to retrieve the fault context after a fatal exception which triggered a system reboot. The function retrieves the fault context stored in crash-report ram area which is preserved over reboot.
* @param fault_context Pointer to mbed_fault_context_t struct allocated by the caller. This is the mbed_fault_context_t info captured as part of the fatal exception which triggered the reboot.
* @return 0 or MBED_SUCCESS on success.
* MBED_ERROR_INVALID_ARGUMENT in case of invalid error_info pointer
* MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by teh system
*
*/
mbed_error_status_t mbed_get_reboot_fault_context (mbed_fault_context_t *fault_context);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,58 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* 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 MBED_CRASH_DATA_INFO_H
#define MBED_CRASH_DATA_INFO_H
#include "platform/mbed_retarget.h"
#include "platform/mbed_toolchain.h"
#ifdef __cplusplus
extern "C" {
#endif
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
extern uint32_t Image$$RW_m_crash_data$$ZI$$Base[];
extern uint32_t Image$$RW_m_crash_data$$ZI$$Size;
#define __CRASH_DATA_RAM_START__ Image$$RW_m_crash_data$$ZI$$Base
#define __CRASH_DATA_RAM_SIZE__ Image$$RW_m_crash_data$$ZI$$Size
#elif defined(__ICCARM__)
extern uint32_t __CRASH_DATA_RAM_START__[];
extern uint32_t __CRASH_DATA_RAM_END__[];
#define __CRASH_DATA_RAM_SIZE__ (__CRASH_DATA_RAM_END__ - __CRASH_DATA_RAM_START__)
#elif defined(__GNUC__)
extern uint32_t __CRASH_DATA_RAM_START__[];
extern uint32_t __CRASH_DATA_RAM_END__[];
#define __CRASH_DATA_RAM_SIZE__ (__CRASH_DATA_RAM_END__ - __CRASH_DATA_RAM_START__)
#endif /* defined(__CC_ARM) */
/* Offset definitions for context capture */
#define FAULT_CONTEXT_OFFSET (0x0)
#define FAULT_CONTEXT_SIZE (0x80 / 4) //32 words(128 bytes) for Fault Context
#define ERROR_CONTEXT_OFFSET (FAULT_CONTEXT_OFFSET + FAULT_CONTEXT_SIZE)
#define ERROR_CONTEXT_SIZE (0x80 / 4) //32 words(128 bytes) bytes for Error Context
#define FAULT_CONTEXT_LOCATION (__CRASH_DATA_RAM_START__ + FAULT_CONTEXT_OFFSET)
#define ERROR_CONTEXT_LOCATION (__CRASH_DATA_RAM_START__ + ERROR_CONTEXT_OFFSET)
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -17,10 +17,13 @@
#include <stdarg.h>
#include <string.h>
#include "device.h"
#include "platform/mbed_crash_data_offsets.h"
#include "platform/mbed_retarget.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_error.h"
#include "platform/mbed_error_hist.h"
#include "platform/mbed_interface.h"
#include "platform/mbed_power_mgmt.h"
#ifdef MBED_CONF_RTOS_PRESENT
#include "rtx_os.h"
#endif
@ -44,10 +47,47 @@ static core_util_atomic_flag error_in_progress = CORE_UTIL_ATOMIC_FLAG_INIT;
static core_util_atomic_flag halt_in_progress = CORE_UTIL_ATOMIC_FLAG_INIT;
static int error_count = 0;
static mbed_error_ctx first_error_ctx = {0};
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
//Global for populating the context in exception handler
static mbed_error_ctx *const report_error_ctx = (mbed_error_ctx *)(ERROR_CONTEXT_LOCATION);
static bool is_reboot_error_valid = false;
#endif
static mbed_error_ctx last_error_ctx = {0};
static mbed_error_hook_t error_hook = NULL;
static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsigned int error_value, const char *filename, int line_number, void *caller);
//Helper function to calculate CRC
//NOTE: It would have been better to use MbedCRC implementation. But
//MbedCRC uses table based calculation and we dont want to keep that table memory
//used up for this purpose. Also we cannot force bitwise calculation in MbedCRC
//and it also requires a new wrapper to be called from C implementation. Since
//we dont have many uses cases to create a C wrapper for MbedCRC and the data
//we calculate CRC on in this context is very less we will use a local
//implementation here.
static unsigned int compute_crc32(const void *data, int datalen)
{
const unsigned int polynomial = 0x04C11DB7; /* divisor is 32bit */
unsigned int crc = 0; /* CRC value is 32bit */
unsigned char *buf = (unsigned char *)data;//use a temp variable to make code readable and to avoid typecasting issues.
for (; datalen > 0; datalen--) {
unsigned char b = *buf++;
crc ^= (unsigned int)(b << 24); /* move byte into upper 8bit */
for (int i = 0; i < 8; i++) {
/* is MSB 1 */
if ((crc & 0x80000000) != 0) {
crc = (unsigned int)((crc << 1) ^ polynomial);
} else {
crc <<= 1;
}
}
}
return crc;
}
//Helper function to halt the system
static MBED_NORETURN void mbed_halt_system(void)
{
@ -129,7 +169,7 @@ static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsign
//Increment error count
error_count++;
//Capture the fist system error and store it
//Capture the first system error and store it
if (error_count == 1) { //first error
memcpy(&first_error_ctx, &current_error_ctx, sizeof(mbed_error_ctx));
}
@ -152,6 +192,50 @@ static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsign
return MBED_SUCCESS;
}
WEAK void mbed_error_reboot_callback(mbed_error_ctx *error_context)
{
//Dont do anything here, let application override this if required.
}
//Initialize Error handling system and report any errors detected on rebooted
mbed_error_status_t mbed_error_initialize(void)
{
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
uint32_t crc_val = 0;
//Just check if we have valid value for error_status, if error_status is positive(which is not valid), no need to check crc
if (report_error_ctx->error_status < 0) {
crc_val = compute_crc32(report_error_ctx, offsetof(mbed_error_ctx, crc_error_ctx));
//Read report_error_ctx and check if CRC is correct, and with valid status code
if ((report_error_ctx->crc_error_ctx == crc_val) && (report_error_ctx->is_error_processed == 0)) {
is_reboot_error_valid = true;
//Report the error info
printf("\n== The system has been rebooted due to a fatal error. ==\n");
//Call the mbed_error_reboot_callback, this enables applications to do some handling before we do the handling
mbed_error_reboot_callback(report_error_ctx);
//We let the callback reset the error info, so check if its still valid and do the rest only if its still valid.
if (report_error_ctx->error_reboot_count < 0) {
//Enforce max-reboot only if auto reboot is enabled
#if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED
if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) {
//We have rebooted more than enough, hold the system here.
printf("\n== Reboot count(=%ld) exceeded maximum, system halting ==\n", report_error_ctx->error_reboot_count);
mbed_halt_system();
}
#endif
report_error_ctx->is_error_processed = 1;//Set the flag that we already processed this error
crc_val = compute_crc32(report_error_ctx, offsetof(mbed_error_ctx, crc_error_ctx));
report_error_ctx->crc_error_ctx = crc_val;
}
}
}
#endif
return MBED_SUCCESS;
}
//Return the first error
mbed_error_status_t mbed_get_first_error(void)
{
@ -191,6 +275,28 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat
ERROR_REPORT(&last_error_ctx, error_msg, filename, line_number);
}
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
uint32_t crc_val = 0;
crc_val = compute_crc32(report_error_ctx, offsetof(mbed_error_ctx, crc_error_ctx));
//Read report_error_ctx and check if CRC is correct for report_error_ctx
if (report_error_ctx->crc_error_ctx == crc_val) {
uint32_t current_reboot_count = report_error_ctx->error_reboot_count;
last_error_ctx.error_reboot_count = current_reboot_count + 1;
} else {
last_error_ctx.error_reboot_count = 1;
}
last_error_ctx.is_error_processed = 0;//Set the flag that this is a new error
//Update the struct with crc
last_error_ctx.crc_error_ctx = compute_crc32(&last_error_ctx, offsetof(mbed_error_ctx, crc_error_ctx));
//Protect report_error_ctx while we update it
core_util_critical_section_enter();
memcpy(report_error_ctx, &last_error_ctx, sizeof(mbed_error_ctx));
core_util_critical_section_exit();
//We need not call delete_mbed_crc(crc_obj) here as we are going to reset the system anyway, and calling delete while handling a fatal error may cause nested exception
#if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED && (MBED_CONF_PLATFORM_ERROR_REBOOT_MAX > 0)
system_reset();//do a system reset to get the system rebooted
#endif
#endif
mbed_halt_system();
}
@ -198,7 +304,7 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat
mbed_error_status_t mbed_set_error_hook(mbed_error_hook_t error_hook_in)
{
//register the new hook/callback
if (error_hook_in != NULL) {
if (error_hook_in != NULL) {
error_hook = error_hook_in;
return MBED_SUCCESS;
}
@ -206,6 +312,53 @@ mbed_error_status_t mbed_set_error_hook(mbed_error_hook_t error_hook_in)
return MBED_ERROR_INVALID_ARGUMENT;
}
//Reset the reboot error context
mbed_error_status_t mbed_reset_reboot_error_info()
{
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
//Protect for thread safety
core_util_critical_section_enter();
memset(report_error_ctx, 0, sizeof(mbed_error_ctx));
core_util_critical_section_exit();
#endif
return MBED_SUCCESS;
}
//Reset the reboot error context
mbed_error_status_t mbed_reset_reboot_count()
{
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
if (is_reboot_error_valid) {
uint32_t crc_val = 0;
core_util_critical_section_enter();
report_error_ctx->error_reboot_count = 0;//Set reboot count to 0
//Update CRC
crc_val = compute_crc32(report_error_ctx, offsetof(mbed_error_ctx, crc_error_ctx));
report_error_ctx->crc_error_ctx = crc_val;
core_util_critical_section_exit();
return MBED_SUCCESS;
}
#endif
return MBED_ERROR_ITEM_NOT_FOUND;
}
//Retrieve the reboot error context
mbed_error_status_t mbed_get_reboot_error_info(mbed_error_ctx *error_info)
{
mbed_error_status_t status = MBED_ERROR_ITEM_NOT_FOUND;
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
if (is_reboot_error_valid) {
if (error_info != NULL) {
memcpy(error_info, report_error_ctx, sizeof(mbed_error_ctx));
status = MBED_SUCCESS;
} else {
status = MBED_ERROR_INVALID_ARGUMENT;
}
}
#endif
return status;
}
//Retrieve the first error context from error log
mbed_error_status_t mbed_get_first_error_info(mbed_error_ctx *error_info)
{

View File

@ -827,6 +827,11 @@ typedef struct _mbed_error_ctx {
char error_filename[MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN];
uint32_t error_line_number;
#endif
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
int32_t error_reboot_count;//everytime we write this struct we increment this value by 1, irrespective of time between reboots. Note that the data itself might change, but everytime we reboot due to error we update this count by 1
int32_t is_error_processed;//once this error is processed set this value to 1
uint32_t crc_error_ctx;//crc_error_ctx should always be the last member in this struct
#endif
} mbed_error_ctx;
/** To generate a fatal compile-time error, you can use the pre-processor #error directive.
@ -928,6 +933,57 @@ MBED_NORETURN void error(const char *format, ...) MBED_PRINTF(1, 2);
*/
typedef void (*mbed_error_hook_t)(const mbed_error_ctx *error_ctx);
/**
* Callback function for reporting error context during boot up. When MbedOS error handling system detects a fatal error
* it will auto-reboot the system(if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED is enabled) after capturing the
* error info in special crash data RAM region. Once rebooted, MbedOS initialization routines will call this function with a pointer to
* the captured mbed_error_ctx structure. If application implementation needs to receive this callback, mbed_error_reboot_callback
* function should be overriden with custom implementation. By default it's defined as a WEAK function in mbed_error.c.
* Note that this callback will be invoked before the system starts executing main() function. So the implementation of
* the callback should be aware any resource limitations/availability of resources which are yet to be initialized by application main().
*
* @param error_ctx Error context structure associated with this error.
* @return void
*
*/
void mbed_error_reboot_callback(mbed_error_ctx *error_context);
/**
* Initialize error handling system, this is called by the mbed-os boot sequence. This is not required to be called by Application unless the boot sequence is overridden by the system implementation.
* NOTE: If MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED is enabled and if the current reboot count exceeds MBED_CONF_PLATFORM_ERROR_REBOOT_MAX the system will halt when this function is called,
* and in such cases the caller will not get the control back. Also note that calling this function may trigger mbed_error_reboot_callback() if application side overides mbed_error_reboot_callback().
* @return MBED_SUCCESS on success.
*
*/
mbed_error_status_t mbed_error_initialize(void);
/**
* Call this function to retrieve the error context after a fatal error which triggered a system reboot. The function retrieves the error context stored in crash-report ram area which is preserved over reboot.
* @param error_info Pointer to mbed_error_ctx struct allocated by the caller. This is the mbed_error_ctx info captured as part of the fatal error which triggered the reboot.
* @return 0 or MBED_SUCCESS on success.
* MBED_ERROR_INVALID_ARGUMENT in case of invalid error_info pointer
* MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by the system
*
*/
mbed_error_status_t mbed_get_reboot_error_info(mbed_error_ctx *error_info);
/**
* Calling this function resets the current reboot context captured by the system(stored in special crash data RAM region).
* @return MBED_SUCCESS on success.
* MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by the system
*/
mbed_error_status_t mbed_reset_reboot_error_info(void);
/**
* Calling this function resets the current reboot count stored as part of error context captured in special crash data RAM region.
* The function will also update the CRC value stored as part of error context accordingly.
* @return MBED_SUCCESS on success.
* MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by the system
*/
mbed_error_status_t mbed_reset_reboot_count(void);
/**
* Call this function to set a system error/warning. This function will log the error status with the context info and return to caller.
*

View File

@ -109,6 +109,18 @@
"cthunk_count_max": {
"help": "The maximum CThunk objects used at the same time. This must be greater than 0 and less 256",
"value": 8
},
"crash-capture-enabled": {
"help": "Enables crash context capture when the system enters a fatal error/crash.",
"value": false
},
"error-reboot-max": {
"help": "Maximum number of auto reboots permitted when an error happens.",
"value": 1
},
"fatal-error-auto-reboot-enabled": {
"help": "Setting this to true enables auto-reboot on a fatal error.",
"value": false
}
},
"target_overrides": {
@ -120,6 +132,58 @@
},
"UNO_91H": {
"stdio-baud-rate": 115200
},
"DISCO_L475VG_IOT01A": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"K64F": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"K66F": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"NUCLEO_F429ZI": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"NUCLEO_F746ZG": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"NUCLEO_F767ZI": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"NUCLEO_F439ZI": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"UBLOX_EVK_ODIN_W2": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"UBLOX_C030_U201": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"NUMAKER_PFM_M487": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"NRF52840_DK": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"NUCLEO_L476RG": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
},
"NUCLEO_F411RE": {
"crash-capture-enabled": true,
"fatal-error-auto-reboot-enabled": true
}
}
}

View File

@ -75,6 +75,7 @@
#include "cmsis.h"
#include "mbed_toolchain.h"
#include "mbed_boot.h"
#include "mbed_error.h"
int main(void);
static void mbed_cpy_nvic(void);
@ -94,6 +95,7 @@ void mbed_start(void)
{
mbed_toolchain_init();
mbed_main();
mbed_error_initialize();
main();
}

View File

@ -72,8 +72,11 @@
#define m_interrupts_ram_start 0x1FFF0000
#define m_interrupts_ram_size __ram_vector_table_size__
#define m_data_start (m_interrupts_ram_start + m_interrupts_ram_size)
#define m_data_size (0x00010000 - m_interrupts_ram_size)
#define m_crash_report_ram_start (m_interrupts_ram_start + m_interrupts_ram_size)
#define m_crash_report_ram_size (0x100)
#define m_data_start (m_crash_report_ram_start + m_crash_report_ram_size)
#define m_data_size (0x00010000 - (m_interrupts_ram_size+m_crash_report_ram_size))
#define m_data_2_start 0x20000000
#define m_data_2_size 0x00030000
@ -110,6 +113,8 @@ LR_IROM1 m_interrupts_start m_text_start+m_text_size-m_interrupts_start { ; lo
VECTOR_RAM m_interrupts_start EMPTY 0 {
}
#endif
RW_m_crash_data m_crash_report_ram_start EMPTY m_crash_report_ram_size { ; RW data
}
RW_m_data m_data_start m_data_size { ; RW data
.ANY (+RW +ZI)
}

View File

@ -66,6 +66,7 @@ __heap_size__ = 0x6000;
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0400 : 0x0;
M_CRASH_DATA_RAM_SIZE = 0x100;
/* Specify the memory areas */
MEMORY
@ -195,6 +196,18 @@ SECTIONS
. = ALIGN(8);
__interrupts_ram_end__ = .; /* Define a global symbol at data end */
} > m_data
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > m_data
__VECTOR_RAM = DEFINED(__ram_vector_table__) ? __VECTOR_RAM__ : ORIGIN(m_interrupts);
__RAM_VECTOR_TABLE_SIZE_BYTES = DEFINED(__ram_vector_table__) ? (__interrupts_ram_end__ - __interrupts_ram_start__) : 0x0;

View File

@ -72,7 +72,10 @@ define symbol m_text_end = MBED_APP_START + MBED_APP_SIZE - 1;
define symbol m_interrupts_ram_start = 0x1FFF0000;
define symbol m_interrupts_ram_end = 0x1FFF0000 + __ram_vector_table_offset__;
define symbol m_data_start = m_interrupts_ram_start + __ram_vector_table_size__;
define symbol m_crash_data_start = m_interrupts_ram_start + __ram_vector_table_size__;
define symbol m_crash_data_size = 0x100;
define symbol m_data_start = m_interrupts_ram_start + __ram_vector_table_size__ + m_crash_data_size;
define symbol m_data_end = 0x1FFFFFFF;
define symbol m_data_2_start = 0x20000000;
@ -94,6 +97,8 @@ if (isdefinedsymbol(__heap_size__)) {
define exported symbol __VECTOR_TABLE = m_interrupts_start;
define exported symbol __VECTOR_RAM = isdefinedsymbol(__ram_vector_table__) ? m_interrupts_ram_start : m_interrupts_start;
define exported symbol __RAM_VECTOR_TABLE_SIZE = __ram_vector_table_size__;
define exported symbol __CRASH_DATA_RAM_START__ = m_crash_data_start;
define exported symbol __CRASH_DATA_RAM_END__ = m_crash_data_start + m_crash_data_size;
define memory mem with size = 4G;
define region m_flash_config_region = mem:[from m_flash_config_start to m_flash_config_end];

View File

@ -80,8 +80,11 @@
#define m_interrupts_ram_start 0x1FFF0000
#define m_interrupts_ram_size __ram_vector_table_size__
#define m_data_start (m_interrupts_ram_start + m_interrupts_ram_size)
#define m_data_size (0x00010000 - m_interrupts_ram_size)
#define m_crash_report_ram_start (m_interrupts_ram_start + m_interrupts_ram_size)
#define m_crash_report_ram_size (0x100)
#define m_data_start (m_crash_report_ram_start + m_crash_report_ram_size)
#define m_data_size (0x00010000 - (m_interrupts_ram_size+m_crash_report_ram_size))
#define m_data_2_start 0x20000000
#define m_data_2_size 0x00030000
@ -118,6 +121,8 @@ LR_IROM1 m_interrupts_start m_text_start+m_text_size-m_interrupts_start { ; lo
VECTOR_RAM m_interrupts_start EMPTY 0 {
}
#endif
RW_m_crash_data m_crash_report_ram_start EMPTY m_crash_report_ram_size { ; RW data
}
RW_m_data m_data_start m_data_size { ; RW data
.ANY (+RW +ZI)
}

View File

@ -74,6 +74,7 @@ __heap_size__ = 0x6000;
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0400 : 0x0;
M_CRASH_DATA_RAM_SIZE = 0x100;
/* Specify the memory areas */
MEMORY
@ -200,6 +201,18 @@ SECTIONS
. = ALIGN(8);
__interrupts_ram_end__ = .; /* Define a global symbol at data end */
} > m_data
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > m_data
__VECTOR_RAM = DEFINED(__ram_vector_table__) ? __VECTOR_RAM__ : ORIGIN(m_interrupts);

View File

@ -79,7 +79,10 @@ define symbol m_text_end = MBED_APP_START + MBED_APP_SIZE - 1;
define symbol m_interrupts_ram_start = 0x1FFF0000;
define symbol m_interrupts_ram_end = 0x1FFF0000 + __ram_vector_table_offset__;
define symbol m_data_start = m_interrupts_ram_start + __ram_vector_table_size__;
define symbol m_crash_data_start = m_interrupts_ram_start + __ram_vector_table_size__;
define symbol m_crash_data_size = 0x100;
define symbol m_data_start = m_interrupts_ram_start + __ram_vector_table_size__ + m_crash_data_size;
define symbol m_data_end = 0x1FFFFFFF;
define symbol m_data_2_start = 0x20000000;
@ -101,6 +104,8 @@ if (isdefinedsymbol(__heap_size__)) {
define exported symbol __VECTOR_TABLE = m_interrupts_start;
define exported symbol __VECTOR_RAM = isdefinedsymbol(__ram_vector_table__) ? m_interrupts_ram_start : m_interrupts_start;
define exported symbol __RAM_VECTOR_TABLE_SIZE = __ram_vector_table_size__;
define exported symbol __CRASH_DATA_RAM_START__ = m_crash_data_start;
define exported symbol __CRASH_DATA_RAM_END__ = m_crash_data_start + m_crash_data_size;
define memory mem with size = 4G;
define region m_flash_config_region = mem:[from m_flash_config_start to m_flash_config_end];

View File

@ -22,8 +22,12 @@
#define MBED_RAM0_START MBED_RAM_START
#define MBED_RAM0_SIZE 0x100
#define MBED_RAM1_START (MBED_RAM_START + MBED_RAM0_SIZE)
#define MBED_RAM1_SIZE (MBED_RAM_SIZE - MBED_RAM0_SIZE)
#define MBED_CRASH_REPORT_RAM_START (MBED_RAM0_START + MBED_RAM0_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM1_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM1_SIZE (MBED_RAM_SIZE - (MBED_RAM0_SIZE + MBED_CRASH_REPORT_RAM_SIZE))
LR_IROM1 MBED_APP_START MBED_APP_SIZE {
ER_IROM1 MBED_APP_START MBED_APP_SIZE {
@ -34,6 +38,8 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
RW_IRAM0 MBED_RAM0_START UNINIT MBED_RAM0_SIZE { ;no init section
*(*nvictable)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
RW_IRAM1 MBED_RAM1_START MBED_RAM1_SIZE {
.ANY (+RW +ZI)
}

View File

@ -38,13 +38,18 @@
#define MBED_RAM0_START MBED_RAM_START
#define MBED_RAM0_SIZE 0x100
#define MBED_RAM1_START (MBED_RAM_START + MBED_RAM0_SIZE)
#define MBED_RAM1_SIZE (MBED_RAM_SIZE - MBED_RAM0_SIZE)
#define MBED_CRASH_REPORT_RAM_START (MBED_RAM0_START + MBED_RAM0_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM1_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM1_SIZE (MBED_RAM_SIZE - (MBED_RAM0_SIZE + MBED_CRASH_REPORT_RAM_SIZE))
MEMORY
{
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
RAM_NVIC (rwx) : ORIGIN = MBED_RAM0_START, LENGTH = MBED_RAM0_SIZE
RAM_CRASH_DATA (rwx) : ORIGIN = MBED_CRASH_REPORT_RAM_START, LENGTH = MBED_CRASH_REPORT_RAM_SIZE
RAM (rwx) : ORIGIN = MBED_RAM1_START, LENGTH = MBED_RAM1_SIZE
}
@ -206,6 +211,18 @@ SECTIONS
KEEP(*(.nvictable))
PROVIDE(__stop_nvictable = .);
} > RAM_NVIC
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += MBED_CRASH_REPORT_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > RAM_CRASH_DATA
.noinit (NOLOAD) :
{

View File

@ -24,8 +24,12 @@ if (!isdefinedsymbol(MBED_RAM_START)) {
define symbol MBED_RAM0_START = MBED_RAM_START;
define symbol MBED_RAM0_SIZE = 0x100;
define symbol MBED_RAM1_START = (MBED_RAM_START + MBED_RAM0_SIZE);
define symbol MBED_RAM1_SIZE = (MBED_RAM_SIZE - MBED_RAM0_SIZE);
define symbol MBED_CRASH_REPORT_RAM_START = (MBED_RAM_START + MBED_RAM0_SIZE);
define symbol MBED_CRASH_REPORT_RAM_SIZE = 0x100;
define symbol MBED_RAM1_START = (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE);
define symbol MBED_RAM1_SIZE = (MBED_RAM_SIZE - (MBED_RAM0_SIZE + MBED_CRASH_REPORT_RAM_SIZE));
define exported symbol __CRASH_DATA_RAM_START__ = MBED_CRASH_REPORT_RAM_START;
define exported symbol __CRASH_DATA_RAM_END__ = MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE;
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = MBED_APP_START;

View File

@ -11,6 +11,15 @@
#define SPIM_CCM_START 0x20020000
#define SPIM_CCM_END 0x20028000
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x20000
#define MBED_STACK_RAM_START (MBED_RAM_START)
#define MBED_STACK_RAM_SIZE 0x800
#define MBED_VECTTABLE_RAM_START (MBED_STACK_RAM_START + MBED_STACK_RAM_SIZE)
#define MBED_VECTTABLE_RAM_SIZE (4*(16 + 96))
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
LR_IROM1 MBED_APP_START {
ER_IROM1 MBED_APP_START { ; load address = execution address
*(RESET, +First)
@ -19,10 +28,13 @@ LR_IROM1 MBED_APP_START {
}
ARM_LIB_STACK 0x20000000 EMPTY 0x800 {
ARM_LIB_STACK MBED_STACK_RAM_START EMPTY MBED_STACK_RAM_SIZE {
}
ER_IRAMVEC 0x20000800 EMPTY (4*(16 + 96)) { ; Reserve for vectors
ER_IRAMVEC MBED_VECTTABLE_RAM_START EMPTY MBED_VECTTABLE_RAM_SIZE { ; Reserve for vectors
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; Reserve for crash data storage
}
RW_IRAM1 AlignExpr(+0, 16) { ; 16 byte-aligned

View File

@ -11,6 +11,15 @@
#define SPIM_CCM_START 0x20020000
#define SPIM_CCM_END 0x20028000
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x20000
#define MBED_STACK_RAM_START (MBED_RAM_START)
#define MBED_STACK_RAM_SIZE 0x800
#define MBED_VECTTABLE_RAM_START (MBED_STACK_RAM_START + MBED_STACK_RAM_SIZE)
#define MBED_VECTTABLE_RAM_SIZE (4*(16 + 96))
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
LR_IROM1 MBED_APP_START {
ER_IROM1 MBED_APP_START { ; load address = execution address
*(RESET, +First)
@ -19,10 +28,13 @@ LR_IROM1 MBED_APP_START {
}
ARM_LIB_STACK 0x20000000 EMPTY 0x800 {
ARM_LIB_STACK MBED_STACK_RAM_START EMPTY MBED_STACK_RAM_SIZE {
}
ER_IRAMVEC 0x20000800 EMPTY (4*(16 + 96)) { ; Reserve for vectors
ER_IRAMVEC MBED_VECTTABLE_RAM_START EMPTY MBED_VECTTABLE_RAM_SIZE { ; Reserve for vectors
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; Reserve for crash data storage
}
RW_IRAM1 AlignExpr(+0, 16) { ; 16 byte-aligned

View File

@ -10,6 +10,7 @@
#define MBED_APP_SIZE 0x00080000
#endif
M_CRASH_DATA_RAM_SIZE = 0x100;
StackSize = 0x800;
SPIM_CCM_START = 0x20020000;
SPIM_CCM_END = 0x20028000;
@ -130,6 +131,18 @@ SECTIONS
PROVIDE(__end_vector_table__ = .);
} > RAM_INTERN
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > RAM_INTERN
.data :
{
PROVIDE( __etext = LOADADDR(.data) );

View File

@ -12,6 +12,8 @@ define symbol __ICFEDIT_region_IRAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_IRAM_end__ = 0x20028000 - 1;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x800;
define symbol __ICFEDIT_size_crash_data__ = 0x100;
define symbol __ICFEDIT_size_intvec__ = (4 * (16 + 96));
define symbol __ICFEDIT_size_heap__ = 0x10000;
/**** End of ICF editor section. ###ICF###*/
@ -23,8 +25,12 @@ define region IRAM_region = mem:[from __ICFEDIT_region_IRAM_start__ to __ICFED
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
/* NOTE: Vector table base requires to be aligned to the power of vector table size. Give a safe value here. */
define block IRAMVEC with alignment = 1024, size = 4 * (16 + 96) { };
define block IRAMVEC with alignment = 1024, size = __ICFEDIT_size_intvec__ { };
define block CRASH_DATA_RAM with alignment = 8, size = __ICFEDIT_size_crash_data__ { };
/* Define Crash Data Symbols */
define exported symbol __CRASH_DATA_RAM_START__ = __ICFEDIT_region_IRAM_start__ + __ICFEDIT_size_cstack__ + __ICFEDIT_size_intvec__;
define exported symbol __CRASH_DATA_RAM_END__ = __ICFEDIT_region_IRAM_start__ + __ICFEDIT_size_cstack__ + __ICFEDIT_size_intvec__ + __ICFEDIT_size_crash_data__;
initialize by copy { readwrite };
do not initialize { section .noinit };
@ -34,5 +40,6 @@ place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of IRAM_region { block CSTACK };
place in IRAM_region { block IRAMVEC };
place in IRAM_region { block CRASH_DATA_RAM };
place in IRAM_region { readwrite };
place in IRAM_region { block HEAP };

View File

@ -27,6 +27,15 @@
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x20000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x198
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; STM32F411RE: 512 KB FLASH (0x80000) + 128 KB SRAM (0x20000)
LR_IROM1 0x08000000 0x80000 { ; load region size_region
@ -35,9 +44,12 @@ LR_IROM1 0x08000000 0x80000 { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 102 vectors = 408 bytes (0x198) to be reserved in RAM
RW_IRAM1 (0x20000000+0x198) (0x20000-0x198) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -36,6 +36,15 @@
#define MBED_APP_SIZE 0x80000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x20000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x198
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; STM32F411RE: 512 KB FLASH (0x80000) + 128 KB SRAM (0x20000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,9 +53,12 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 102 vectors = 408 bytes (0x198) to be reserved in RAM
RW_IRAM1 (0x20000000+0x198) (0x20000-0x198) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -6,6 +6,8 @@
#define MBED_APP_SIZE 512K
#endif
M_CRASH_DATA_RAM_SIZE = 0x100;
/* Linker script to configure memory regions. */
MEMORY
{
@ -84,6 +86,18 @@ SECTIONS
__etext = .;
_sidata = .;
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > RAM
.data : AT (__etext)
{

View File

@ -9,14 +9,21 @@ define symbol __region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
/* [RAM = 128kb = 0x20000] Vector table dynamic copy: 102 vectors = 408 bytes (0x198) to be reserved in RAM */
define symbol __NVIC_start__ = 0x20000000;
define symbol __NVIC_end__ = 0x20000197; /* Aligned on 8 bytes */
define symbol __region_RAM_start__ = 0x20000198;
define symbol __region_CRASH_DATA_RAM_start__ = 0x20000198;
define symbol __region_CRASH_DATA_RAM_end__ = 0x20000297;
define symbol __region_RAM_start__ = 0x20000298;
define symbol __region_RAM_end__ = 0x2001FFFF;
/* Memory regions */
define memory mem with size = 4G;
define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM_end__];
define region CRASH_DATA_RAM_region = mem:[from __region_CRASH_DATA_RAM_start__ to __region_CRASH_DATA_RAM_end__];
define region RAM_region = mem:[from __region_RAM_start__ to __region_RAM_end__];
/* Define Crash Data Symbols */
define exported symbol __CRASH_DATA_RAM_START__ = __region_CRASH_DATA_RAM_start__;
define exported symbol __CRASH_DATA_RAM_END__ = __region_CRASH_DATA_RAM_end__;
/* Stack and Heap */
/*Heap 84kB and stack 1kB */
define symbol __size_cstack__ = 0x400;

View File

@ -36,6 +36,15 @@
#define MBED_APP_SIZE 0x200000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x20000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x1B0
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; 2 MB FLASH (0x200000) + 256 KB SRAM (0x40000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,9 +53,12 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 107 vectors = 428 bytes (0x1AC) 8-byte aligned = 0x1B0 (0x1AC + 0x4) to be reserved in RAM
RW_IRAM1 (0x20000000+0x1B0) (0x20000-0x1B0) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -36,6 +36,15 @@
#define MBED_APP_SIZE 0x200000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x30000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x1B0
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; 2 MB FLASH (0x200000) + 192 KB SRAM (0x30000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,9 +53,12 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 107 vectors = 428 bytes (0x1AC) 8-byte aligned = 0x1B0 (0x1AC + 0x4) to be reserved in RAM
RW_IRAM1 (0x20000000+0x1B0) (0x30000-0x1B0) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -14,6 +14,8 @@ HEAP_SIZE = 0x6000;
#define MBED_APP_SIZE 2048k
#endif
M_CRASH_DATA_RAM_SIZE = 0x100;
/* Specify the memory areas */
MEMORY
{
@ -114,7 +116,18 @@ SECTIONS
. = ALIGN(8);
__interrupts_ram_end__ = .; /* Define a global symbol at data end */
} > RAM
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > RAM
.data :
{

View File

@ -10,7 +10,9 @@ define symbol __ICFEDIT_region_ROM_start__ = MBED_APP_START;
define symbol __ICFEDIT_region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
define symbol __ICFEDIT_region_NVIC_start__ = 0x20000000;
define symbol __ICFEDIT_region_NVIC_end__ = 0x200001AF;
define symbol __ICFEDIT_region_RAM_start__ = 0x200001B0;
define symbol __region_CRASH_DATA_RAM_start__ = 0x200001B0;
define symbol __region_CRASH_DATA_RAM_end__ = 0x200002AF;
define symbol __ICFEDIT_region_RAM_start__ = 0x200002B0;
define symbol __ICFEDIT_region_RAM_end__ = 0x2002FFFF;
define symbol __ICFEDIT_region_CCMRAM_start__ = 0x10000000;
define symbol __ICFEDIT_region_CCMRAM_end__ = 0x1000FFFF;
@ -24,8 +26,13 @@ define symbol __ICFEDIT_size_heap__ = 0x10000;
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define region CRASH_DATA_RAM_region = mem:[from __region_CRASH_DATA_RAM_start__ to __region_CRASH_DATA_RAM_end__];
define region CCMRAM_region = mem:[from __ICFEDIT_region_CCMRAM_start__ to __ICFEDIT_region_CCMRAM_end__];
/* Define Crash Data Symbols */
define exported symbol __CRASH_DATA_RAM_START__ = __region_CRASH_DATA_RAM_start__;
define exported symbol __CRASH_DATA_RAM_END__ = __region_CRASH_DATA_RAM_end__;
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };

View File

@ -38,6 +38,15 @@
#define MBED_APP_SIZE 0x100000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x30000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x1B0
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address
@ -47,7 +56,7 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
}
; Total: 107 vectors = 428 bytes (0x1AC) 8-byte aligned = 0x1B0 (0x1AC + 0x4) to be reserved in RAM
RW_IRAM1 (0x20000000+0x1B0) (0x30000-0x1B0) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}
@ -55,6 +64,9 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
.ANY (CCMRAM)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
RW_IRAM3 0x40024000 4096 { ; 4 kbytes of Backup SRAM
.ANY (BKPSRAM)
}

View File

@ -6,6 +6,8 @@
#define MBED_APP_SIZE 1024k
#endif
M_CRASH_DATA_RAM_SIZE = 0x100;
/* Linker script to configure memory regions. */
/* 0x1AC resevered for vectors; 8-byte aligned = 0x1B0 (0x1AC + 0x4)*/
MEMORY
@ -87,6 +89,18 @@ SECTIONS
__etext = .;
_sidata = .;
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > RAM
.data : AT (__etext)
{

View File

@ -10,7 +10,9 @@ define symbol __ICFEDIT_region_ROM_start__ = MBED_APP_START;
define symbol __ICFEDIT_region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
define symbol __ICFEDIT_region_NVIC_start__ = 0x20000000;
define symbol __ICFEDIT_region_NVIC_end__ = 0x200001AF;
define symbol __ICFEDIT_region_RAM_start__ = 0x200001B0;
define symbol __region_CRASH_DATA_RAM_start__ = 0x200001B0;
define symbol __region_CRASH_DATA_RAM_end__ = 0x200002AF;
define symbol __ICFEDIT_region_RAM_start__ = 0x200002B0;
define symbol __ICFEDIT_region_RAM_end__ = 0x2002FFFF;
define symbol __ICFEDIT_region_CCMRAM_start__ = 0x10000000;
define symbol __ICFEDIT_region_CCMRAM_end__ = 0x1000FFFF;
@ -25,10 +27,15 @@ define symbol __ICFEDIT_size_heap__ = 0x18000;
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region CRASH_DATA_RAM_region = mem:[from __region_CRASH_DATA_RAM_start__ to __region_CRASH_DATA_RAM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define region CCMRAM_region = mem:[from __ICFEDIT_region_CCMRAM_start__ to __ICFEDIT_region_CCMRAM_end__];
define region BKPSRAM_region = mem:[from __ICFEDIT_region_BKPSRAM_start__ to __ICFEDIT_region_BKPSRAM_end__];
/* Define Crash Data Symbols */
define exported symbol __CRASH_DATA_RAM_START__ = __region_CRASH_DATA_RAM_start__;
define exported symbol __CRASH_DATA_RAM_END__ = __region_CRASH_DATA_RAM_end__;
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };

View File

@ -36,6 +36,15 @@
#define MBED_APP_SIZE 0x200000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x30000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x1B0
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; STM32F439xI: 2048 KB FLASH (0x200000) + 256 KB SRAM (0x30000 + 0x10000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,10 +53,13 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 107 vectors = 428 bytes (0x1AC) 8-byte aligned = 0x1B0 (0x1AC + 0x4) to be used
; should match ER_IROM1::RESET/4 and cmsis_nvic.h::NVIC_NUM_VECTORS
RW_IRAM1 (0x20000000 + 0x1B0) (0x30000 - 0x1B0) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}
RW_IRAM2 (0x10000000) 0x10000 {

View File

@ -36,6 +36,15 @@
#define MBED_APP_SIZE 0x200000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x30000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x1B0
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; 2 MB FLASH (0x200000) + 256 KB SRAM (0x30000 + 0x10000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,9 +53,12 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 107 vectors = 428 bytes(0x1AC) 8-byte aligned = 0x1B0 (0x1AC + 0x4) to be reserved in RAM
RW_IRAM1 (0x20000000+0x1B0) (0x30000-0x1B0) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -6,6 +6,8 @@
#define MBED_APP_SIZE 2048k
#endif
M_CRASH_DATA_RAM_SIZE = 0x100;
/* Linker script to configure memory regions. */
/* 0x1AC resevered for vectors; 8-byte aligned = 0x1B0 (0x1AC + 0x4)*/
MEMORY
@ -86,6 +88,18 @@ SECTIONS
__etext = .;
_sidata = .;
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > RAM
.data : AT (__etext)
{

View File

@ -10,7 +10,9 @@ define symbol __ICFEDIT_region_ROM_start__ = MBED_APP_START;
define symbol __ICFEDIT_region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
define symbol __ICFEDIT_region_NVIC_start__ = 0x20000000;
define symbol __ICFEDIT_region_NVIC_end__ = 0x200001AF;
define symbol __ICFEDIT_region_RAM_start__ = 0x200001B0;
define symbol __region_CRASH_DATA_RAM_start__ = 0x200001B0;
define symbol __region_CRASH_DATA_RAM_end__ = 0x200002AF;
define symbol __ICFEDIT_region_RAM_start__ = 0x200002B0;
define symbol __ICFEDIT_region_RAM_end__ = 0x2002FFFF;
define symbol __ICFEDIT_region_CCMRAM_start__ = 0x10000000;
define symbol __ICFEDIT_region_CCMRAM_end__ = 0x1000FFFF;
@ -23,9 +25,14 @@ define symbol __ICFEDIT_size_heap__ = 0x15C00;
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region CRASH_DATA_RAM_region = mem:[from __region_CRASH_DATA_RAM_start__ to __region_CRASH_DATA_RAM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define region CCMRAM_region = mem:[from __ICFEDIT_region_CCMRAM_start__ to __ICFEDIT_region_CCMRAM_end__];
/* Define Crash Data Symbols */
define exported symbol __CRASH_DATA_RAM_START__ = __region_CRASH_DATA_RAM_start__;
define exported symbol __CRASH_DATA_RAM_END__ = __region_CRASH_DATA_RAM_end__;
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };

View File

@ -36,6 +36,15 @@
#define MBED_APP_SIZE 0x100000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x50000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x1C8
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; STM32F746NG: 1024 KB FLASH (0x100000) + 320 KB SRAM (0x50000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,9 +53,12 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 114 vectors = 456 bytes (0x1C8) to be reserved in RAM
RW_IRAM1 (0x20000000+0x1C8) (0x50000-0x1C8) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -36,6 +36,15 @@
#define MBED_APP_SIZE 0x100000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x50000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x1C8
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; STM32F746NG: 1024 KB FLASH (0x100000) + 320 KB SRAM (0x50000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,9 +53,12 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 114 vectors = 456 bytes (0x1C8) to be reserved in RAM
RW_IRAM1 (0x20000000+0x1C8) (0x50000-0x1C8) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -8,6 +8,8 @@
#define MBED_APP_SIZE 1024K
#endif
M_CRASH_DATA_RAM_SIZE = 0x100;
MEMORY
{
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
@ -85,6 +87,18 @@ SECTIONS
__etext = .;
_sidata = .;
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > RAM
.data : AT (__etext)
{

View File

@ -9,7 +9,9 @@ define symbol __region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
/* [RAM = 320kb = 0x50000] Vector table dynamic copy: 114 vectors = 456 bytes (0x1C8) to be reserved in RAM */
define symbol __NVIC_start__ = 0x20000000;
define symbol __NVIC_end__ = 0x200001C7; /* Aligned on 8 bytes */
define symbol __region_RAM_start__ = 0x200001C8;
define symbol __region_CRASH_DATA_RAM_start__ = 0x200001C8;
define symbol __region_CRASH_DATA_RAM_end__ = 0x200002C7;
define symbol __region_RAM_start__ = 0x200002C8;
define symbol __region_RAM_end__ = 0x2004FFFF;
define symbol __region_ITCMRAM_start__ = 0x00000000;
@ -19,8 +21,13 @@ define symbol __region_ITCMRAM_end__ = 0x00003FFF;
define memory mem with size = 4G;
define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM_end__];
define region RAM_region = mem:[from __region_RAM_start__ to __region_RAM_end__];
define region CRASH_DATA_RAM_region = mem:[from __region_CRASH_DATA_RAM_start__ to __region_CRASH_DATA_RAM_end__];
define region ITCMRAM_region = mem:[from __region_ITCMRAM_start__ to __region_ITCMRAM_end__];
/* Define Crash Data Symbols */
define exported symbol __CRASH_DATA_RAM_START__ = __region_CRASH_DATA_RAM_start__;
define exported symbol __CRASH_DATA_RAM_END__ = __region_CRASH_DATA_RAM_end__;
/* Stack and Heap */
/*Heap 1/4 of ram and stack 1/12 */
define symbol __size_cstack__ = 0x4000;

View File

@ -36,6 +36,15 @@
#define MBED_APP_SIZE 0x200000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x80000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x1F8
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; STM32F767ZI: 2048 KB FLASH (0x200000) + 512 KB SRAM (0x80000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,9 +53,12 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 126 vectors = 504 bytes (0x1F8) to be reserved in RAM
RW_IRAM1 (0x20000000+0x1F8) (0x80000-0x1F8) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -36,6 +36,15 @@
#define MBED_APP_SIZE 0x200000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x80000
#define MBED_VECTTABLE_RAM_START (MBED_RAM_START)
#define MBED_VECTTABLE_RAM_SIZE 0x1F8
#define MBED_CRASH_REPORT_RAM_START (MBED_VECTTABLE_RAM_START + MBED_VECTTABLE_RAM_SIZE)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_VECTTABLE_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; STM32F767ZI: 2048 KB FLASH (0x200000) + 512 KB SRAM (0x80000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,9 +53,12 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
; Total: 126 vectors = 504 bytes (0x1F8) to be reserved in RAM
RW_IRAM1 (0x20000000+0x1F8) (0x80000-0x1F8) { ; RW data
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -8,6 +8,8 @@
#define MBED_APP_SIZE 2048K
#endif
M_CRASH_DATA_RAM_SIZE = 0x100;
MEMORY
{
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
@ -85,6 +87,18 @@ SECTIONS
__etext = .;
_sidata = .;
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > RAM
.data : AT (__etext)
{

View File

@ -9,7 +9,9 @@ define symbol __region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
/* [RAM = 512kb = 0x80000] Vector table dynamic copy: 126 vectors = 504 bytes (0x1F8) to be reserved in RAM */
define symbol __NVIC_start__ = 0x20000000;
define symbol __NVIC_end__ = 0x200001F7; /* Aligned on 8 bytes */
define symbol __region_RAM_start__ = 0x200001F8;
define symbol __region_CRASH_DATA_RAM_start__ = 0x200001F8;
define symbol __region_CRASH_DATA_RAM_end__ = 0x200002F7;
define symbol __region_RAM_start__ = 0x200002F8;
define symbol __region_RAM_end__ = 0x2007FFFF;
define symbol __region_ITCMRAM_start__ = 0x00000000;
@ -18,9 +20,14 @@ define symbol __region_ITCMRAM_end__ = 0x00003FFF;
/* Memory regions */
define memory mem with size = 4G;
define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM_end__];
define region CRASH_DATA_RAM_region = mem:[from __region_CRASH_DATA_RAM_start__ to __region_CRASH_DATA_RAM_end__];
define region RAM_region = mem:[from __region_RAM_start__ to __region_RAM_end__];
define region ITCMRAM_region = mem:[from __region_ITCMRAM_start__ to __region_ITCMRAM_end__];
/* Define Crash Data Symbols */
define exported symbol __CRASH_DATA_RAM_START__ = __region_CRASH_DATA_RAM_start__;
define exported symbol __CRASH_DATA_RAM_END__ = __region_CRASH_DATA_RAM_end__;
/* Stack and Heap */
define symbol __size_cstack__ = 0x8000;
define symbol __size_heap__ = 0x10000;

View File

@ -36,6 +36,13 @@
#define MBED_APP_SIZE 0x100000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x00018000
#define MBED_CRASH_REPORT_RAM_START (MBED_RAM_START)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; 1MB FLASH (0x100000) + 128KB SRAM (0x20000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -45,7 +52,9 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00018000 { ; RW data 96k L4-SRAM1
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
RW_IRAM1 MBED_RAM0_START MBED_RAM0_SIZE { ; RW data 96k L4-SRAM1
.ANY (+RW +ZI)
}
; Total: 98 vectors = 392 bytes (0x188) to be reserved in RAM

View File

@ -36,6 +36,14 @@
#define MBED_APP_SIZE 0x100000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x00018000
#define MBED_CRASH_REPORT_RAM_START (MBED_RAM_START)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; 1MB FLASH (0x100000) + 128KB SRAM (0x20000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -44,8 +52,9 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00018000 { ; RW data 96k L4-SRAM1
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
RW_IRAM1 MBED_RAM0_START MBED_RAM0_SIZE { ; RW data 96k L4-SRAM1
.ANY (+RW +ZI)
}
; Total: 98 vectors = 392 bytes (0x188) to be reserved in RAM

View File

@ -6,6 +6,8 @@
#define MBED_APP_SIZE 1024k
#endif
M_CRASH_DATA_RAM_SIZE = 0x100;
/* Linker script to configure memory regions. */
MEMORY
{
@ -85,6 +87,18 @@ SECTIONS
__etext = .;
_sidata = .;
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > SRAM1
.data : AT (__etext)
{

View File

@ -12,15 +12,22 @@ define symbol __NVIC_start__ = 0x10000000;
define symbol __NVIC_end__ = 0x10000187;
define symbol __region_SRAM2_start__ = 0x10000188;
define symbol __region_SRAM2_end__ = 0x10007FFF;
define symbol __region_SRAM1_start__ = 0x20000000;
define symbol __region_CRASH_DATA_RAM_start__ = 0x20000000;
define symbol __region_CRASH_DATA_RAM_end__ = 0x200000FF;
define symbol __region_SRAM1_start__ = 0x20000100;
define symbol __region_SRAM1_end__ = 0x20017FFF;
/* Memory regions */
define memory mem with size = 4G;
define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM_end__];
define region SRAM2_region = mem:[from __region_SRAM2_start__ to __region_SRAM2_end__];
define region CRASH_DATA_RAM_region = mem:[from __region_CRASH_DATA_RAM_start__ to __region_CRASH_DATA_RAM_end__];
define region SRAM1_region = mem:[from __region_SRAM1_start__ to __region_SRAM1_end__];
/* Define Crash Data Symbols */
define exported symbol __CRASH_DATA_RAM_START__ = __region_CRASH_DATA_RAM_start__;
define exported symbol __CRASH_DATA_RAM_END__ = __region_CRASH_DATA_RAM_end__;
/* Stack complete SRAM2 and Heap 2/3 of SRAM1 */
define symbol __size_cstack__ = 0x7e00;
define symbol __size_heap__ = 0x10000;

View File

@ -36,6 +36,13 @@
#define MBED_APP_SIZE 0x100000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x00018000
#define MBED_CRASH_REPORT_RAM_START (MBED_RAM_START)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; 1MB FLASH (0x100000) + 128KB SRAM (0x20000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -45,9 +52,13 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00018000 { ; RW data 96k L4-SRAM1
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
RW_IRAM1 MBED_RAM0_START MBED_RAM0_SIZE { ; RW data 96k L4-SRAM1
.ANY (+RW +ZI)
}
; Total: 98 vectors = 392 bytes (0x188) to be reserved in RAM
RW_IRAM2 (0x10000000+0x188) (0x08000-0x188) { ; RW data 32k L4-ECC-SRAM2 retained in standby
.ANY (+RW +ZI)

View File

@ -36,6 +36,13 @@
#define MBED_APP_SIZE 0x100000
#endif
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x00018000
#define MBED_CRASH_REPORT_RAM_START (MBED_RAM_START)
#define MBED_CRASH_REPORT_RAM_SIZE 0x100
#define MBED_RAM0_START (MBED_CRASH_REPORT_RAM_START + MBED_CRASH_REPORT_RAM_SIZE)
#define MBED_RAM0_SIZE (MBED_RAM_SIZE - MBED_CRASH_REPORT_RAM_SIZE)
; 1MB FLASH (0x100000) + 128KB SRAM (0x20000)
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
@ -45,9 +52,13 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00018000 { ; RW data 96k L4-SRAM1
RW_m_crash_data MBED_CRASH_REPORT_RAM_START EMPTY MBED_CRASH_REPORT_RAM_SIZE { ; RW data
}
RW_IRAM1 MBED_RAM0_START MBED_RAM0_SIZE { ; RW data 96k L4-SRAM1
.ANY (+RW +ZI)
}
; Total: 98 vectors = 392 bytes (0x188) to be reserved in RAM
RW_IRAM2 (0x10000000+0x188) (0x08000-0x188) { ; RW data 32k L4-ECC-SRAM2 retained in standby
.ANY (+RW +ZI)

View File

@ -6,6 +6,8 @@
#define MBED_APP_SIZE 1024k
#endif
M_CRASH_DATA_RAM_SIZE = 0x100;
/* Linker script to configure memory regions. */
MEMORY
{
@ -85,6 +87,18 @@ SECTIONS
__etext = .;
_sidata = .;
.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > SRAM1
.data : AT (__etext)
{

View File

@ -12,15 +12,22 @@ define symbol __NVIC_start__ = 0x10000000;
define symbol __NVIC_end__ = 0x10000187;
define symbol __region_SRAM2_start__ = 0x10000188;
define symbol __region_SRAM2_end__ = 0x10007FFF;
define symbol __region_SRAM1_start__ = 0x20000000;
define symbol __region_CRASH_DATA_RAM_start__ = 0x20000000;
define symbol __region_CRASH_DATA_RAM_end__ = 0x200000FF;
define symbol __region_SRAM1_start__ = 0x20000100;
define symbol __region_SRAM1_end__ = 0x20017FFF;
/* Memory regions */
define memory mem with size = 4G;
define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM_end__];
define region SRAM2_region = mem:[from __region_SRAM2_start__ to __region_SRAM2_end__];
define region CRASH_DATA_RAM_region = mem:[from __region_CRASH_DATA_RAM_start__ to __region_CRASH_DATA_RAM_end__];
define region SRAM1_region = mem:[from __region_SRAM1_start__ to __region_SRAM1_end__];
/* Define Crash Data Symbols */
define exported symbol __CRASH_DATA_RAM_START__ = __region_CRASH_DATA_RAM_start__;
define exported symbol __CRASH_DATA_RAM_END__ = __region_CRASH_DATA_RAM_end__;
/* Stack complete SRAM2 and Heap 2/3 of SRAM1 */
define symbol __size_cstack__ = 0x7e00;
define symbol __size_heap__ = 0x10000;