Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fadecandy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scanlime
Fadecandy
Commits
fd5c3edc
Commit
fd5c3edc
authored
11 years ago
by
Micah Elizabeth Scott
Browse files
Options
Downloads
Patches
Plain Diff
More ADI fault handling
parent
c54b259f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
testjig/production/arm_debug.cpp
+56
-0
56 additions, 0 deletions
testjig/production/arm_debug.cpp
testjig/production/arm_debug.h
+9
-3
9 additions, 3 deletions
testjig/production/arm_debug.h
testjig/production/production.ino
+4
-0
4 additions, 0 deletions
testjig/production/production.ino
with
69 additions
and
3 deletions
testjig/production/arm_debug.cpp
+
56
−
0
View file @
fd5c3edc
...
@@ -253,6 +253,8 @@ bool ARMDebug::dpWrite(unsigned addr, bool APnDP, uint32_t data)
...
@@ -253,6 +253,8 @@ bool ARMDebug::dpWrite(unsigned addr, bool APnDP, uint32_t data)
wireWriteIdle
();
wireWriteIdle
();
log
(
LOG_ERROR
,
"FAULT response during write (addr=%x APnDP=%d data=%08x)"
,
log
(
LOG_ERROR
,
"FAULT response during write (addr=%x APnDP=%d data=%08x)"
,
addr
,
APnDP
,
data
);
addr
,
APnDP
,
data
);
if
(
!
handleFault
())
log
(
LOG_ERROR
,
"Error during fault recovery!"
);
return
false
;
return
false
;
default:
default:
...
@@ -304,6 +306,8 @@ bool ARMDebug::dpRead(unsigned addr, bool APnDP, uint32_t &data)
...
@@ -304,6 +306,8 @@ bool ARMDebug::dpRead(unsigned addr, bool APnDP, uint32_t &data)
wireWriteTurnaround
();
wireWriteTurnaround
();
wireWriteIdle
();
wireWriteIdle
();
log
(
LOG_ERROR
,
"FAULT response during read (addr=%x APnDP=%d)"
,
addr
,
APnDP
);
log
(
LOG_ERROR
,
"FAULT response during read (addr=%x APnDP=%d)"
,
addr
,
APnDP
);
if
(
!
handleFault
())
log
(
LOG_ERROR
,
"Error during fault recovery!"
);
return
false
;
return
false
;
default
:
default
:
...
@@ -318,6 +322,39 @@ bool ARMDebug::dpRead(unsigned addr, bool APnDP, uint32_t &data)
...
@@ -318,6 +322,39 @@ bool ARMDebug::dpRead(unsigned addr, bool APnDP, uint32_t &data)
return
false
;
return
false
;
}
}
bool
ARMDebug
::
handleFault
()
{
// Read CTRLSTAT to see what the fault was, and set appropriate ABORT bits
uint32_t
ctrlstat
;
uint32_t
abortbits
=
0
;
if
(
!
dpRead
(
CTRLSTAT
,
false
,
ctrlstat
))
return
false
;
if
(
ctrlstat
&
(
1
<<
7
))
{
log
(
LOG_ERROR
,
"FAULT: Detected WDATAERR"
);
abortbits
|=
1
<<
3
;
}
if
(
ctrlstat
&
(
1
<<
5
))
{
log
(
LOG_ERROR
,
"FAULT: Detected STICKYERR"
);
abortbits
|=
1
<<
2
;
}
if
(
ctrlstat
&
(
1
<<
4
))
{
log
(
LOG_ERROR
,
"FAULT: Detected STICKCMP"
);
abortbits
|=
1
<<
1
;
}
if
(
ctrlstat
&
(
1
<<
1
))
{
log
(
LOG_ERROR
,
"FAULT: Detected STICKORUN"
);
abortbits
|=
1
<<
4
;
}
if
(
abortbits
&&
!
dpWrite
(
ABORT
,
false
,
abortbits
))
return
false
;
return
true
;
}
uint8_t
ARMDebug
::
packHeader
(
unsigned
addr
,
bool
APnDP
,
bool
RnW
)
uint8_t
ARMDebug
::
packHeader
(
unsigned
addr
,
bool
APnDP
,
bool
RnW
)
{
{
bool
a2
=
(
addr
>>
2
)
&
1
;
bool
a2
=
(
addr
>>
2
)
&
1
;
...
@@ -412,3 +449,22 @@ void ARMDebug::log(int level, const char *fmt, ...)
...
@@ -412,3 +449,22 @@ void ARMDebug::log(int level, const char *fmt, ...)
Serial
.
println
(
buffer
);
Serial
.
println
(
buffer
);
}
}
}
}
bool
ARMDebug
::
halt
()
{
// Write to DHCSR (Debug Halting Control and Status Register)
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337e/CEGCJAHJ.html
return
memStore
(
0xE000EDF0
,
0xA05F0003
);
}
bool
ARMDebug
::
unhalt
()
{
return
memStore
(
0xE000EDF0
,
0xA05F0000
);
}
bool
ARMDebug
::
sysReset
()
{
// Write to AIRCR (Application Interrupt and Reset Control Register)
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihehdge.html
return
memStore
(
0xE000ED0C
,
0x05FA0004
);
}
This diff is collapsed.
Click to expand it.
testjig/production/arm_debug.h
+
9
−
3
View file @
fd5c3edc
...
@@ -48,14 +48,17 @@ public:
...
@@ -48,14 +48,17 @@ public:
*/
*/
bool
begin
(
unsigned
clockPin
,
unsigned
dataPin
,
LogLevel
logLevel
=
LOG_NORMAL
);
bool
begin
(
unsigned
clockPin
,
unsigned
dataPin
,
LogLevel
logLevel
=
LOG_NORMAL
);
//
/
Memory
store
// Memory
operations (AHB bus)
bool
memStore
(
uint32_t
addr
,
uint32_t
data
);
bool
memStore
(
uint32_t
addr
,
uint32_t
data
);
bool
memStore
(
uint32_t
addr
,
uint32_t
*
data
,
unsigned
count
);
bool
memStore
(
uint32_t
addr
,
uint32_t
*
data
,
unsigned
count
);
/// Memory load
bool
memLoad
(
uint32_t
addr
,
uint32_t
&
data
);
bool
memLoad
(
uint32_t
addr
,
uint32_t
&
data
);
bool
memLoad
(
uint32_t
addr
,
uint32_t
*
data
,
unsigned
count
);
bool
memLoad
(
uint32_t
addr
,
uint32_t
*
data
,
unsigned
count
);
// CPU core operations
bool
halt
();
bool
unhalt
();
bool
sysReset
();
private
:
private
:
uint8_t
clockPin
,
dataPin
;
uint8_t
clockPin
,
dataPin
;
LogLevel
logLevel
;
LogLevel
logLevel
;
...
@@ -76,6 +79,9 @@ protected:
...
@@ -76,6 +79,9 @@ protected:
void
wireReadTurnaround
();
void
wireReadTurnaround
();
void
wireWriteIdle
();
void
wireWriteIdle
();
// Error diagnostics and recovert
bool
handleFault
();
// Packet assembly tools
// Packet assembly tools
uint8_t
packHeader
(
unsigned
addr
,
bool
APnDP
,
bool
RnW
);
uint8_t
packHeader
(
unsigned
addr
,
bool
APnDP
,
bool
RnW
);
bool
evenParity
(
uint32_t
word
);
bool
evenParity
(
uint32_t
word
);
...
...
This diff is collapsed.
Click to expand it.
testjig/production/production.ino
+
4
−
0
View file @
fd5c3edc
...
@@ -39,6 +39,10 @@ void loop()
...
@@ -39,6 +39,10 @@ void loop()
if
(
!
target
.
begin
(
swclkPin
,
swdioPin
,
target
.
LOG_TRACE_MEM
))
if
(
!
target
.
begin
(
swclkPin
,
swdioPin
,
target
.
LOG_TRACE_MEM
))
return
;
return
;
if
(
!
target
.
halt
())
return
;
if
(
!
target
.
sysReset
())
return
;
uint32_t
data
;
uint32_t
data
;
if
(
!
target
.
memLoad
(
0x00000000
,
data
))
if
(
!
target
.
memLoad
(
0x00000000
,
data
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment