Fixed entity reporting and comments

pull/6983/head
Senthil Ramakrishnan 2018-05-09 17:51:35 -05:00
parent 839fef0ad1
commit 7c6c718f75
2 changed files with 56 additions and 14 deletions

View File

@ -197,9 +197,41 @@ typedef enum _MbedErrorType
* Other entity values can be used to provide more info on who/where the error originated from.\n\n * Other entity values can be used to provide more info on who/where the error originated from.\n\n
* For example, if I2C driver is the component originating the error you can use ENTITY_DRIVER_I2C to provide more info.\n * For example, if I2C driver is the component originating the error you can use ENTITY_DRIVER_I2C to provide more info.\n
* Its used in call to MAKE_ERROR/MAKE_SYSTEM_ERROR/MAKE_CUSTOM_ERROR macros.\n * Its used in call to MAKE_ERROR/MAKE_SYSTEM_ERROR/MAKE_CUSTOM_ERROR macros.\n
*
* @code * @code
* MbedErrorStatus i2c_driver_error = MAKE_ERROR( ENTITY_DRIVER_I2C, ERROR_CONFIG_UNSUPPORTED ); * Example: MbedErrorStatus i2c_driver_error = MAKE_ERROR( ENTITY_DRIVER_I2C, ERROR_CONFIG_UNSUPPORTED );
* @endcode * @endcode
*
* @note
* \n Below are the entity code mappings:\n
\verbatim
ENTITY_APPLICATION 0 Application
ENTITY_PLATFORM 1 Platform
ENTITY_KERNEL 2 RTX Kernel
ENTITY_NETWORK_STACK 3 Network stack
ENTITY_HAL 4 HAL - Hardware Abstraction Layer
ENTITY_MEMORY_SUBSYSTEM 5 Memory Subsystem
ENTITY_FILESYSTEM 6 Filesystem
ENTITY_BLOCK_DEVICE 7 Block device
ENTITY_DRIVER 8 Driver
ENTITY_DRIVER_SERIAL 9 Serial Driver
ENTITY_DRIVER_RTC 10 RTC Driver
ENTITY_DRIVER_I2C 11 I2C Driver
ENTITY_DRIVER_SPI 12 SPI Driver
ENTITY_DRIVER_GPIO 13 GPIO Driver
ENTITY_DRIVER_ANALOG 14 Analog Driver
ENTITY_DRIVER_DIGITAL 15 DigitalIO Driver
ENTITY_DRIVER_CAN 16 CAN Driver
ENTITY_DRIVER_ETHERNET 17 Ethernet Driver
ENTITY_DRIVER_CRC 18 CRC Module
ENTITY_DRIVER_PWM 19 PWM Driver
ENTITY_DRIVER_QSPI 20 QSPI Driver
ENTITY_DRIVER_USB 21 USB Driver
ENTITY_TARGET_SDK 22 SDK
ENTITY_UNKNOWN 255 Unknown entity
\endverbatim
*
*/ */
typedef enum _MbedEntityType typedef enum _MbedEntityType
{ {
@ -485,18 +517,22 @@ typedef enum _MbedEntityType
* *
* *
* @note * @note
* Searching for error codes in mbed-os source tree. \n * **Searching for error codes in mbed-os source tree:** \n
* 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 * 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
* 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 * 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
* Use that error name(\b INVALID_FORMAT) to search the source tree for code locations setting that specific error code. \n * Use that error name(\b INVALID_FORMAT) to search the source tree for code locations setting that specific error code. \n
\verbatim * 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.
* See MbedEntityType enum above for entity mapping. \n
*
* \verbatim
++ MbedOS Error Info ++ ++ MbedOS Error Info ++
Error Status: 0x80FF0103 Error Status: 0x80040103
Error Code: 259 Error Code: 259
Error Message: Invalid format error Error Entity: 04
Error Location: 0x00002CFF Error Message: HAL Entity error
Error Value: 0x00000008 Error Location: 0x000067C7
Current Thread: Id: 0x200025AC EntryFn: 0x00009681 StackSize: 0x00001000 StackMem: 0x200025F8 SP: 0x2002FFD8 Error Value: 0x00005566
Current Thread: Id: 0x200024A8 EntryFn: 0x0000FB0D StackSize: 0x00001000 StackMem: 0x200014A8 SP: 0x2002FFD8
-- MbedOS Error Info -- -- MbedOS Error Info --
\endverbatim \endverbatim
*/ */

View File

@ -81,6 +81,7 @@ void mbed_error_print(char *fmtstr, uint32_t *values)
if(fmtstr[i]=='%') { if(fmtstr[i]=='%') {
i++; i++;
if(fmtstr[i]=='x') { if(fmtstr[i]=='x') {
memset(num_str, '0', sizeof(num_str));
//print the number in hex format //print the number in hex format
value_to_hex_str(values[vidx++],num_str); value_to_hex_str(values[vidx++],num_str);
for(idx=7; idx>=0; idx--) { for(idx=7; idx>=0; idx--) {
@ -88,9 +89,12 @@ void mbed_error_print(char *fmtstr, uint32_t *values)
} }
} }
else if(fmtstr[i]=='d') { else if(fmtstr[i]=='d') {
memset(num_str, '0', sizeof(num_str));
//print the number in dec format //print the number in dec format
value_to_dec_str(values[vidx++],num_str); value_to_dec_str(values[vidx++],num_str);
for(idx=5; idx>=0; idx--) { idx=7;
while(num_str[idx--]=='0' && idx > 0);//Dont print zeros at front
for(idx++;idx>=0; idx--) {
serial_putc(&stdio_uart, num_str[idx]); serial_putc(&stdio_uart, num_str[idx]);
} }
} }
@ -140,9 +144,11 @@ void print_thread(osRtxThread_t *thread)
void mbed_report_error(const mbed_error_ctx *error_ctx, char *error_msg) void mbed_report_error(const mbed_error_ctx *error_ctx, char *error_msg)
{ {
int error_code = GET_MBED_ERROR_CODE(error_ctx->error_status); int error_code = GET_MBED_ERROR_CODE(error_ctx->error_status);
int error_entity = GET_MBED_ERROR_ENTITY(error_ctx->error_status);
mbed_error_print("\n\n++ MbedOS Error Info ++\nError Status: 0x%x", (uint32_t *)&error_ctx->error_status); mbed_error_print("\n\n++ MbedOS Error Info ++\nError Status: 0x%x", (uint32_t *)&error_ctx->error_status);
mbed_error_print("\nError Code: %d\nError Message: ", (uint32_t *)&error_code); mbed_error_print("\nError Code: %d", (uint32_t *)&error_code);
mbed_error_print("\nError Entity: %d\nError Message: ", (uint32_t *)&error_entity);
//Report error info based on error code, some errors require different info //Report error info based on error code, some errors require different info
if(error_code == ERROR_CODE_HARDFAULT_EXCEPTION || if(error_code == ERROR_CODE_HARDFAULT_EXCEPTION ||