Skip to content

Commit 7c6c718

Browse files
committed
Fixed entity reporting and comments
1 parent 839fef0 commit 7c6c718

File tree

2 files changed

+56
-14
lines changed

2 files changed

+56
-14
lines changed

platform/mbed_error.h

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,48 @@ typedef enum _MbedErrorType
190190

191191
//Entity type/id definitions
192192
/** MbedEntityType definition
193-
* @note
194-
* This enumeration defines the Entity types. The value of these enum values will be encoded into MbedErrorStatus ENTITY field.\n\n
193+
* @note
194+
* This enumeration defines the Entity types. The value of these enum values will be encoded into MbedErrorStatus ENTITY field.\n\n
195195
* See MbedErrorStatus description for more info.\n
196196
* ENTITY_UNKNOWN - This entity type can be used if caller of the set_error/set_error_fatal doesn't know who is the actual originator of the error.\n
197197
* Other entity values can be used to provide more info on who/where the error originated from.\n\n
198198
* For example, if I2C driver is the component originating the error you can use ENTITY_DRIVER_I2C to provide more info.\n
199199
* Its used in call to MAKE_ERROR/MAKE_SYSTEM_ERROR/MAKE_CUSTOM_ERROR macros.\n
200+
*
200201
* @code
201-
* MbedErrorStatus i2c_driver_error = MAKE_ERROR( ENTITY_DRIVER_I2C, ERROR_CONFIG_UNSUPPORTED );
202+
* Example: MbedErrorStatus i2c_driver_error = MAKE_ERROR( ENTITY_DRIVER_I2C, ERROR_CONFIG_UNSUPPORTED );
202203
* @endcode
204+
*
205+
* @note
206+
* \n Below are the entity code mappings:\n
207+
\verbatim
208+
ENTITY_APPLICATION 0 Application
209+
ENTITY_PLATFORM 1 Platform
210+
ENTITY_KERNEL 2 RTX Kernel
211+
ENTITY_NETWORK_STACK 3 Network stack
212+
ENTITY_HAL 4 HAL - Hardware Abstraction Layer
213+
ENTITY_MEMORY_SUBSYSTEM 5 Memory Subsystem
214+
ENTITY_FILESYSTEM 6 Filesystem
215+
ENTITY_BLOCK_DEVICE 7 Block device
216+
ENTITY_DRIVER 8 Driver
217+
ENTITY_DRIVER_SERIAL 9 Serial Driver
218+
ENTITY_DRIVER_RTC 10 RTC Driver
219+
ENTITY_DRIVER_I2C 11 I2C Driver
220+
ENTITY_DRIVER_SPI 12 SPI Driver
221+
ENTITY_DRIVER_GPIO 13 GPIO Driver
222+
ENTITY_DRIVER_ANALOG 14 Analog Driver
223+
ENTITY_DRIVER_DIGITAL 15 DigitalIO Driver
224+
ENTITY_DRIVER_CAN 16 CAN Driver
225+
ENTITY_DRIVER_ETHERNET 17 Ethernet Driver
226+
ENTITY_DRIVER_CRC 18 CRC Module
227+
ENTITY_DRIVER_PWM 19 PWM Driver
228+
ENTITY_DRIVER_QSPI 20 QSPI Driver
229+
ENTITY_DRIVER_USB 21 USB Driver
230+
ENTITY_TARGET_SDK 22 SDK
231+
232+
ENTITY_UNKNOWN 255 Unknown entity
233+
\endverbatim
234+
*
203235
*/
204236
typedef enum _MbedEntityType
205237
{
@@ -485,18 +517,22 @@ typedef enum _MbedEntityType
485517
*
486518
*
487519
* @note
488-
* Searching for error codes in mbed-os source tree. \n
489-
* If you get an error report as below which you want to search for mbed-os source tree first take note of "Error Code" number. \n
520+
* **Searching for error codes in mbed-os source tree:** \n
521+
* If you get an error report as below which you want to search for in mbed-os source tree, first take note of "Error Code" number. \n
490522
* For example, the below error report has an error code of \b 259. Find the error name associated with the error code and in this case its \b INVALID_FORMAT. \n
491523
* Use that error name(\b INVALID_FORMAT) to search the source tree for code locations setting that specific error code. \n
492-
\verbatim
524+
* If the Error Entity reported is not 255(which indicates unknown entity), you can also use that to narrow down to the specific component reporting the error.
525+
* See MbedEntityType enum above for entity mapping. \n
526+
*
527+
* \verbatim
493528
++ MbedOS Error Info ++
494-
Error Status: 0x80FF0103
495-
Error Code: 259
496-
Error Message: Invalid format error
497-
Error Location: 0x00002CFF
498-
Error Value: 0x00000008
499-
Current Thread: Id: 0x200025AC EntryFn: 0x00009681 StackSize: 0x00001000 StackMem: 0x200025F8 SP: 0x2002FFD8
529+
Error Status: 0x80040103
530+
Error Code: 259
531+
Error Entity: 04
532+
Error Message: HAL Entity error
533+
Error Location: 0x000067C7
534+
Error Value: 0x00005566
535+
Current Thread: Id: 0x200024A8 EntryFn: 0x0000FB0D StackSize: 0x00001000 StackMem: 0x200014A8 SP: 0x2002FFD8
500536
-- MbedOS Error Info --
501537
\endverbatim
502538
*/

platform/mbed_error_report.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,20 @@ void mbed_error_print(char *fmtstr, uint32_t *values)
8181
if(fmtstr[i]=='%') {
8282
i++;
8383
if(fmtstr[i]=='x') {
84+
memset(num_str, '0', sizeof(num_str));
8485
//print the number in hex format
8586
value_to_hex_str(values[vidx++],num_str);
8687
for(idx=7; idx>=0; idx--) {
8788
serial_putc(&stdio_uart, num_str[idx]);
8889
}
8990
}
9091
else if(fmtstr[i]=='d') {
92+
memset(num_str, '0', sizeof(num_str));
9193
//print the number in dec format
9294
value_to_dec_str(values[vidx++],num_str);
93-
for(idx=5; idx>=0; idx--) {
95+
idx=7;
96+
while(num_str[idx--]=='0' && idx > 0);//Dont print zeros at front
97+
for(idx++;idx>=0; idx--) {
9498
serial_putc(&stdio_uart, num_str[idx]);
9599
}
96100
}
@@ -140,9 +144,11 @@ void print_thread(osRtxThread_t *thread)
140144
void mbed_report_error(const mbed_error_ctx *error_ctx, char *error_msg)
141145
{
142146
int error_code = GET_MBED_ERROR_CODE(error_ctx->error_status);
147+
int error_entity = GET_MBED_ERROR_ENTITY(error_ctx->error_status);
143148

144149
mbed_error_print("\n\n++ MbedOS Error Info ++\nError Status: 0x%x", (uint32_t *)&error_ctx->error_status);
145-
mbed_error_print("\nError Code: %d\nError Message: ", (uint32_t *)&error_code);
150+
mbed_error_print("\nError Code: %d", (uint32_t *)&error_code);
151+
mbed_error_print("\nError Entity: %d\nError Message: ", (uint32_t *)&error_entity);
146152

147153
//Report error info based on error code, some errors require different info
148154
if(error_code == ERROR_CODE_HARDFAULT_EXCEPTION ||

0 commit comments

Comments
 (0)