You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more info, visit: https://mbed.com/s/error?error=0x80FF013D&mbedos=999999&core=0x410FC241&compile=1&ver=5060528
97
+
For more info, visit: https://mbed.com/s/error?error=0x80FF013D
98
98
-- MbedOS Error Info --
99
99
```
100
100
@@ -130,6 +130,37 @@ Mbed OS application and system developers may need to define error codes specifi
130
130
131
131
Some applications may want to do custom error handling when an error is reported using `MBED_ERROR()` or `MBED_WARNING()`. Applications can accomplish this by registering an error hook function with the Mbed OS error handling system using the **mbed_set_error_hook()** API. This function is called with error context information whenever the system handles an **MBED_ERROR()** or **MBED_WARNING()** invocation. This function should be implemented for re-entrancy because multiple threads may invoke `MBED_ERROR()` or `MBED_WARNING()`, which may cause the error hook to be called in parallel.
132
132
133
+
### Crash reporting and auto-reboot
134
+
Whenever a fatal error happens in the system, MbedOS error handling system collects key information such as error code, error location, register context(in the case of fault exceptions) etc. and stores them in a special area in RAM region called Crash-data-RAM. The error information stored in Crash-data-RAM is in binary format and follows the `mbed_error_ctx` structure defined in `mbed_error.h`. The system then triggers a warm-reset without losing the RAM contents where we have the error information collected. After the system reboots, during MbedOS initialization the Crash-data-RAM region is checked to find if there is valid error information captured. This is done by using a CRC value calculated over the stored error information and is appended as part of information stored in Crash-data-RAM. If the system detects that the reboot was triggered by a fatal error, it will invoke a callback function with a pointer to the error context structure stored in Crash-data-RAM. The default callback function is defined with `WEAK` attribute, which can be overridden by the application if required. Below is the signature for the callback:
Note that this callback will be invoked before the system starts executing application `main()`. So the implementation of callback should be aware any resource limitations or availability of resources which are yet to be initialized by application `main()`. Also note that the callback is invoked only when there is a new error.
139
+
140
+
#### Enabling crash reporting
141
+
As mentioned above, the crash reporting feature requires a special memory region, called Crash-data-RAM to work. This region is 256 bytes in size and is allocated using linker scripts for the target for each toolchain. Although all platforms support crash reporting feature, not all targets are currently modified to allocate this Crash-data-RAM region.
142
+
See `mbed_lib.json` in platform directory to see which targts currently enabled with crash reporting. In order to enable crash reporting in other targets, you must modify the linker scripts for those targets to allocate the Crash-data-RAM region. You may refer the linker scripts for one of the targets already enabled with crash reporting to understand how the Crash-data-RAM region is allocated. Below are some guidelines to make the linker script changes.
143
+
144
+
* The region size should be 256 bytes and aligned at 8-byte offset.
145
+
* If you are enabling the Crash-data-RAM for *ARM compiler*, linker script must export the following symbols:
146
+
__Image$$RW_m_crash_data$$ZI$$Base__ - Indicates start address of Crash-data-RAM region.
147
+
__Image$$RW_m_crash_data$$ZI$$Size__ - Indicates size of Crash-data-RAM region.
148
+
* If you are enabling the Crash-data-RAM for *GCC ARM compiler* or *IAR Compiler*, linker script must export the following symbols:
149
+
__CRASH_DATA_RAM_START__ - Indicates start address of Crash-data-RAM region.
150
+
__CRASH_DATA_RAM_END__ - Indicates end address of Crash-data-RAM region.
151
+
152
+
It's important that these regions should be marked with appropriate attributes(based on toolchain) to mark them as uninitialized region. For example, for ARM Compiler Crash-data-RAM can be marked with attribute *EMPTY*. There is no hard requirement about the placement of this region. The only requirement is that it should be placed such that no other entity is overwriting this region when rebooted or at runtime. But in order to avoid fragmentation its best placed just after the vector table region, or if there is no vector table region, it can be placed at the bottom of RAM(lowest address).
153
+
See [memory model](memory.html) for more info on the placement of this region.
154
+
155
+
#### Configuring crash reporting and auto-reboot
156
+
MbedOS crash reporting implementation provides many options to configure the crash reporting behavior.
157
+
Below is the list of new configuration options available to configure crash reporting functionality. These configuration options are defined in `mbed_lib.json` under platform directory.
158
+
159
+
`crash-capture-enabled` - Enables crash context capture when the system enters a fatal error/crash. When this is disabled it also disables other dependent options mentioned below.
160
+
`fatal-error-auto-reboot-enabled` - Setting this to true enables auto-reboot on fatal errors.
161
+
`reboot-crash-report-enabled` - Enables crash report printing over terminal when the system reboots after a fatal error.
162
+
`error-reboot-max` - Maximum number of auto-reboots permitted on fatal errors. The system will stop auto-rebooting once the maximum limit is reached. Setting this to value 0 will disable auto-reboot.
163
+
133
164
### Error handling functions reference
134
165
135
166
The below link provides the documentation for all the APIs that Mbed OS provides for error definitions and handling:
@@ -298,12 +329,98 @@ void save_all_errors() {
298
329
mbed_clear_all_errors();
299
330
}
300
331
```
332
+
333
+
#### Using `mbed_get_reboot_error_info()` to retrieve the reboot error info
334
+
The error context captured by the error handling system can be retrieved using mbed_get_reboot_error_info() API. See the below code for example usage of that API.
335
+
In the example below, a status variable reboot_error_detected has been used to track the presence of error context capture.
if (MBED_SUCCESS == mbed_get_reboot_error_info(&error_ctx)) {
353
+
printf("\nSuccessfully read error context\n");
354
+
}
355
+
//main continues...
356
+
}
357
+
```
358
+
359
+
#### Using `mbed_get_reboot_fault_context()` to retrieve the fault context info
360
+
The fault context captured can be retrieved using mbed_get_reboot_fault_context() API. See the below code for example usage of that API. The example code below checks for error_status using the error context and then retrieves the fault context using mbed_get_reboot_fault_context() API.
0 commit comments