Skip to content

Commit

Permalink
CortexM: added SecureFault vector catch.
Browse files Browse the repository at this point in the history
  • Loading branch information
flit committed Aug 9, 2020
1 parent eb2c729 commit c1bdff9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/options.md
Expand Up @@ -360,6 +360,7 @@ The source letters are:
- `h`=hard fault
- `b`=bus fault
- `m`=mem fault
- `e`=secure fault
- `i`=irq err
- `s`=state err
- `c`=check err
Expand Down
7 changes: 5 additions & 2 deletions pyocd/core/target.py
Expand Up @@ -103,8 +103,11 @@ class VectorCatch:
COPROCESSOR_ERR = (1 << 6)
## Trap on local reset.
CORE_RESET = (1 << 7)
ALL = (HARD_FAULT | BUS_FAULT | MEM_FAULT | INTERRUPT_ERR \
| STATE_ERR | CHECK_ERR | COPROCESSOR_ERR | CORE_RESET)
## Trap SecureFault.
SECURE_FAULT = (1 << 8)
ALL = (HARD_FAULT | BUS_FAULT | MEM_FAULT | INTERRUPT_ERR
| STATE_ERR | CHECK_ERR | COPROCESSOR_ERR | CORE_RESET
| SECURE_FAULT)

class Event(Enum):
"""! Target notification events."""
Expand Down
5 changes: 5 additions & 0 deletions pyocd/coresight/cortex_m.py
Expand Up @@ -208,6 +208,7 @@ class CortexM(Target, CoreSightCoreComponent):
DEMCR = 0xE000EDFC
# DWTENA in armv6 architecture reference manual
DEMCR_TRCENA = (1 << 24)
DEMCR_VC_SFERR = (1 << 11)
DEMCR_VC_HARDERR = (1 << 10)
DEMCR_VC_INTERR = (1 << 9)
DEMCR_VC_BUSERR = (1 << 8)
Expand Down Expand Up @@ -1289,6 +1290,8 @@ def _map_to_vector_catch_mask(mask):
result |= CortexM.DEMCR_VC_NOCPERR
if mask & Target.VectorCatch.CORE_RESET:
result |= CortexM.DEMCR_VC_CORERESET
if mask & Target.VectorCatch.SECURE_FAULT:
result |= CortexM.DEMCR_VC_SFERR
return result

@staticmethod
Expand All @@ -1310,6 +1313,8 @@ def _map_from_vector_catch_mask(mask):
result |= Target.VectorCatch.COPROCESSOR_ERR
if mask & CortexM.DEMCR_VC_CORERESET:
result |= Target.VectorCatch.CORE_RESET
if mask & CortexM.DEMCR_VC_SFERR:
result |= Target.VectorCatch.SECURE_FAULT
return result

def set_vector_catch(self, enableMask):
Expand Down
1 change: 1 addition & 0 deletions pyocd/tools/pyocd.py
Expand Up @@ -81,6 +81,7 @@
Target.VectorCatch.CHECK_ERR : "check error",
Target.VectorCatch.COPROCESSOR_ERR : "coprocessor error",
Target.VectorCatch.CORE_RESET : "core reset",
Target.VectorCatch.SECURE_FAULT : "secure fault",
}

HPROT_BIT_DESC = {
Expand Down
1 change: 1 addition & 0 deletions pyocd/utility/cmdline.py
Expand Up @@ -56,6 +56,7 @@ def split_command_line(cmd_line):

## Map of vector char characters to masks.
VECTOR_CATCH_CHAR_MAP = {
'e': Target.VectorCatch.SECURE_FAULT,
'h': Target.VectorCatch.HARD_FAULT,
'b': Target.VectorCatch.BUS_FAULT,
'm': Target.VectorCatch.MEM_FAULT,
Expand Down

0 comments on commit c1bdff9

Please sign in to comment.