mirror of https://github.com/ARMmbed/mbed-os.git
Fixes for targets with invalid HardFault_Handler implementation and review/other fixes
parent
29348d823d
commit
96d900c99f
|
@ -21,11 +21,12 @@
|
|||
; *
|
||||
; * -----------------------------------------------------------------------------
|
||||
; */
|
||||
|
||||
IF :LNOT::DEF:__DOMAIN_NS
|
||||
__DOMAIN_NS EQU 1
|
||||
ENDIF
|
||||
|
||||
#ifndef MBED_FAULT_HANDLER_DISABLED
|
||||
|
||||
#ifndef __DOMAIN_NS
|
||||
#define __DOMAIN_NS 1
|
||||
#endif
|
||||
|
||||
FAULT_TYPE_HARD_FAULT EQU 0x10
|
||||
FAULT_TYPE_MEMMANAGE_FAULT EQU 0x20
|
||||
FAULT_TYPE_BUS_FAULT EQU 0x30
|
||||
|
@ -66,7 +67,7 @@ UsageFault_Handler\
|
|||
|
||||
Fault_Handler PROC
|
||||
EXPORT Fault_Handler
|
||||
IF __DOMAIN_NS = 1
|
||||
#if (__DOMAIN_NS == 1)
|
||||
IMPORT osRtxInfo
|
||||
IMPORT mbed_fault_handler
|
||||
IMPORT mbed_fault_context
|
||||
|
@ -148,8 +149,10 @@ Fault_Handler_Continue2
|
|||
LDR R1,=mbed_fault_context
|
||||
LDR R2,=osRtxInfo
|
||||
BLX R3
|
||||
ENDIF
|
||||
#endif
|
||||
B . ; Just in case we come back here
|
||||
ENDP
|
||||
|
||||
#endif
|
||||
|
||||
END
|
||||
|
|
|
@ -21,15 +21,15 @@
|
|||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef MBED_FAULT_HANDLER_DISABLED
|
||||
|
||||
|
||||
.file "except_cm0.S"
|
||||
.file "except.S"
|
||||
.syntax unified
|
||||
|
||||
.ifndef __DOMAIN_NS
|
||||
.equ __DOMAIN_NS, 1
|
||||
.endif
|
||||
|
||||
|
||||
#ifndef __DOMAIN_NS
|
||||
#define __DOMAIN_NS 1
|
||||
#endif
|
||||
|
||||
.equ FAULT_TYPE_HARD_FAULT, 0x10
|
||||
.equ FAULT_TYPE_MEMMANAGE_FAULT, 0x20
|
||||
.equ FAULT_TYPE_BUS_FAULT, 0x30
|
||||
|
@ -103,7 +103,7 @@ UsageFault_Handler:
|
|||
.cantunwind
|
||||
|
||||
Fault_Handler:
|
||||
.if __DOMAIN_NS == 1
|
||||
#if (__DOMAIN_NS == 1)
|
||||
MRS R0,MSP
|
||||
LDR R1,=0x4
|
||||
MOV R2,LR
|
||||
|
@ -181,10 +181,14 @@ Fault_Handler_Continue2:
|
|||
LDR R1,=mbed_fault_context
|
||||
LDR R2,=osRtxInfo
|
||||
BLX R3
|
||||
.endif
|
||||
#endif
|
||||
B . // Just in case we come back here
|
||||
|
||||
.fnend
|
||||
.size Fault_Handler, .-Fault_Handler
|
||||
|
||||
#endif
|
||||
|
||||
.end
|
||||
|
||||
|
||||
|
|
|
@ -22,25 +22,24 @@
|
|||
; * -----------------------------------------------------------------------------
|
||||
; */
|
||||
|
||||
|
||||
NAME except_cm0.s
|
||||
NAME except.S
|
||||
|
||||
#ifndef __DOMAIN_NS
|
||||
#define __DOMAIN_NS 1
|
||||
#endif
|
||||
|
||||
FAULT_TYPE_HARD_FAULT EQU 0x10
|
||||
FAULT_TYPE_MEMMANAGE_FAULT EQU 0x20
|
||||
FAULT_TYPE_BUS_FAULT EQU 0x30
|
||||
FAULT_TYPE_USAGE_FAULT EQU 0x40
|
||||
|
||||
#ifndef MBED_FAULT_HANDLER_DISABLED
|
||||
|
||||
#ifndef __DOMAIN_NS
|
||||
#define __DOMAIN_NS 1
|
||||
#endif
|
||||
PRESERVE8
|
||||
SECTION .rodata:DATA:NOROOT(2)
|
||||
|
||||
THUMB
|
||||
SECTION .text:CODE:NOROOT(2)
|
||||
|
||||
|
||||
HardFault_Handler
|
||||
EXPORT HardFault_Handler
|
||||
LDR R3,=FAULT_TYPE_HARD_FAULT
|
||||
|
@ -147,5 +146,6 @@ Fault_Handler_Continue2
|
|||
BLX R3
|
||||
#endif
|
||||
B . ; Just in case we come back here
|
||||
#endif ; #if (MBED_FAULT_HANDLER_SUPPORT == 1)
|
||||
|
||||
END
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "mbed_rtx_fault_handler.h"
|
||||
#include "hal/serial_api.h"
|
||||
|
||||
#ifndef MBED_FAULT_HANDLER_DISABLED
|
||||
//Global for populating the context in exception handler
|
||||
mbed_fault_context_t mbed_fault_context;
|
||||
|
||||
|
@ -36,17 +37,29 @@ extern int stdio_uart_inited;
|
|||
extern serial_t stdio_uart;
|
||||
#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.
|
||||
__NO_RETURN void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in, void *osRtxInfoIn)
|
||||
{
|
||||
fault_print_init();
|
||||
fault_print_str("\n++ MbedOS Fault Handler ++\n\nFaultType: ",NULL);
|
||||
|
||||
switch( fault_type ) {
|
||||
case HARD_FAULT_EXCEPTION: fault_print_str("HardFault",NULL); break;
|
||||
case MEMMANAGE_FAULT_EXCEPTION: fault_print_str("MemManageFault",NULL); break;
|
||||
case BUS_FAULT_EXCEPTION: fault_print_str("BusFault",NULL); break;
|
||||
case USAGE_FAULT_EXCEPTION: fault_print_str("UsageFault",NULL); break;
|
||||
default: fault_print_str("Unknown Fault",NULL); break;
|
||||
case HARD_FAULT_EXCEPTION:
|
||||
fault_print_str("HardFault",NULL);
|
||||
break;
|
||||
case MEMMANAGE_FAULT_EXCEPTION:
|
||||
fault_print_str("MemManageFault",NULL);
|
||||
break;
|
||||
case BUS_FAULT_EXCEPTION:
|
||||
fault_print_str("BusFault",NULL);
|
||||
break;
|
||||
case USAGE_FAULT_EXCEPTION:
|
||||
fault_print_str("UsageFault",NULL);
|
||||
break;
|
||||
default:
|
||||
fault_print_str("Unknown Fault",NULL);
|
||||
break;
|
||||
}
|
||||
fault_print_str("\n\nContext:",NULL);
|
||||
print_context_info();
|
||||
|
@ -71,7 +84,7 @@ __NO_RETURN void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_conte
|
|||
|
||||
fault_print_str("\n\n-- MbedOS Fault Handler --\n\n",NULL);
|
||||
|
||||
/* Just spin here, we have alrady crashed */
|
||||
/* Just spin here, we have already crashed */
|
||||
for (;;) {}
|
||||
}
|
||||
|
||||
|
@ -211,3 +224,5 @@ void hex_to_str(uint32_t value, char *hex_str)
|
|||
hex_str[i] = hex_char_map[(value & (0xf << (i * 4))) >> (i * 4)];
|
||||
}
|
||||
}
|
||||
|
||||
#endif //MBED_FAULT_HANDLER_SUPPORT
|
|
@ -46,5 +46,7 @@ typedef struct {
|
|||
#define BUS_FAULT_EXCEPTION (0x30)
|
||||
#define USAGE_FAULT_EXCEPTION (0x40)
|
||||
|
||||
//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.
|
||||
__NO_RETURN void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in, void *osRtxInfoIn);
|
||||
|
|
@ -68,12 +68,6 @@ void NotImplemented_Handler(void)
|
|||
while (1) {};
|
||||
}
|
||||
|
||||
/** Hardware fault interrupt handler */
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
while (1) {};
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
* *
|
||||
* Functions *
|
||||
|
|
|
@ -236,11 +236,3 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
return 1; // OK
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Hard Fault Handler */
|
||||
/******************************************************************************/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
debug("Hard Fault\n");
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
|
|
@ -236,11 +236,3 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
return 1; // OK
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Hard Fault Handler */
|
||||
/******************************************************************************/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
debug("Hard Fault\n");
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
|
|
@ -238,11 +238,3 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
return 1; // OK
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Hard Fault Handler */
|
||||
/******************************************************************************/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
debug("Hard Fault\n");
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
|
|
@ -249,12 +249,4 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
return 1; // OK
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Hard Fault Handler */
|
||||
/******************************************************************************/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
debug("Hard Fault\n");
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
|
|
|
@ -3718,7 +3718,7 @@
|
|||
}
|
||||
},
|
||||
"inherits": ["Target"],
|
||||
"macros": ["CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""],
|
||||
"macros": ["CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\"","MBED_FAULT_HANDLER_DISABLED"],
|
||||
"device_has": ["ANALOGIN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "STDIO_MESSAGES", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH"],
|
||||
"release_versions": ["5"],
|
||||
"device_name": "NANO130KE3BN"
|
||||
|
@ -3756,7 +3756,7 @@
|
|||
"inherits": ["Target"],
|
||||
"detect_code": ["4600"],
|
||||
"extra_labels": ["Realtek", "AMEBA", "RTL8195A"],
|
||||
"macros": ["__RTL8195A__","CONFIG_PLATFORM_8195A","CONFIG_MBED_ENABLED","PLATFORM_CMSIS_RTOS"],
|
||||
"macros": ["__RTL8195A__","CONFIG_PLATFORM_8195A","CONFIG_MBED_ENABLED","PLATFORM_CMSIS_RTOS","MBED_FAULT_HANDLER_DISABLED"],
|
||||
"supported_toolchains": ["GCC_ARM", "ARM", "IAR"],
|
||||
"device_has": ["ANALOGIN", "ANALOGOUT", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SPI", "TRNG", "EMAC", "FLASH"],
|
||||
"features": ["LWIP"],
|
||||
|
|
|
@ -1,4 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2017-2019 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.
|
||||
|
||||
LIBRARIES BUILD
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
from os import path
|
||||
|
@ -25,8 +43,7 @@ class ElfHelper(object):
|
|||
self.maplines = map_file.readlines()
|
||||
self.matches = ptn.findall(op)
|
||||
self.addrs = [int(x[0],16) for x in self.matches]
|
||||
#print(self.maplines)
|
||||
|
||||
|
||||
def function_addrs(self):
|
||||
return self.addrs
|
||||
|
||||
|
@ -37,18 +54,14 @@ class ElfHelper(object):
|
|||
|
||||
def file_name_for_function_name(self, funcname):
|
||||
for eachline in self.maplines:
|
||||
#print("%s:%s"%(eachline,funcname))
|
||||
result = eachline.find(funcname)
|
||||
if(result != -1):
|
||||
break
|
||||
toks = eachline.split()
|
||||
#print("%s:%s"%(str(funcname),str(toks)))
|
||||
if(len(toks) <= 0):
|
||||
print("WARN: Unable to find %s in map file"%(str(funcname)))
|
||||
#return funcname
|
||||
return ("%s [FUNCTION]"%(str(funcname)))
|
||||
else:
|
||||
#return toks[-1].replace("./BUILD/","").replace("/","\\")
|
||||
return toks[-1]
|
||||
|
||||
def parseHFSR(hfsr):
|
||||
|
@ -143,7 +156,6 @@ def main(input):
|
|||
eachline=lines[i]
|
||||
if(-1 != eachline.find("--- MbedOS Fault Handler ---")):
|
||||
break
|
||||
#print(eachline)
|
||||
|
||||
if(eachline.startswith("PC")):
|
||||
l = re.findall(r"[\w']+", eachline)
|
||||
|
|
Loading…
Reference in New Issue