-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arm: Support hardware debugging of ARM architecture #15616
base: master
Are you sure you want to change the base?
Conversation
[Experimental Bot, please feedback here] This PR template itself meets the NuttX requirements by providing sections for all the requested information. However, a user submitting a PR needs to fill out all the sections completely and accurately for the PR to truly meet the requirements. Simply including the template without filling it out is insufficient. Specifically, the template addresses the requirements by prompting for:
The inclusion of the contributing guidelines link further reinforces the importance of adhering to the broader project standards. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include commit message with more information
9d33530
to
4de7c4d
Compare
OK, I have improved the description |
0b152b2
to
bb1b94f
Compare
Support hardware debugging of ARM architecture, and support smp mode.We can use "up_debugpoint_add" or "up_debugpoint_remove" to add breakpoints, and the hardware will jump into the interrupt after detecting it. It will not affect our program. Registration callback is not supported yet,the debug of arm32 jumps into the exception vector table, and it is also necessary to develop the jump function of the exception vector table in debug mode TODO: Support singlestep Signed-off-by: wangmingrong1 <[email protected]>
@@ -43,7 +43,7 @@ CMN_ASRCS += arm_cpuhead.S arm_vectors.S arm_saveusercontext.S | |||
# Common C source files | |||
|
|||
CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_dataabort.c | |||
CMN_CSRCS += arm_doirq.c arm_gicv2.c arm_gicv2_dump.c | |||
CMN_CSRCS += arm_hwdebug.c arm_doirq.c arm_gicv2.c arm_gicv2_dump.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add CONFIG_ARCH_HAVE_DEBUG to control
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary because this file is in armv7a and it definitely supports debug functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or should we add select ARCH_HAVE_DEBUG for the ARMv7a arch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, need select ARCH_HAVE_DEBUG, since gdbstub depend on this.
@@ -43,7 +43,7 @@ CMN_ASRCS += arm_cpuhead.S arm_vectors.S arm_saveusercontext.S | |||
# Common C source files | |||
|
|||
CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_dataabort.c | |||
CMN_CSRCS += arm_doirq.c arm_gicv2.c arm_gicv2_dump.c | |||
CMN_CSRCS += arm_hwdebug.c arm_doirq.c arm_gicv2.c arm_gicv2_dump.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, need select ARCH_HAVE_DEBUG, since gdbstub depend on this.
#define ARM_ADDBRP_EVENT 0 | ||
#define ARM_ADDWRP_EVENT 1 | ||
|
||
/* Accessor macros for the debug registers. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add blank line after EACH comment
static int arm_get_num_brp_resources(void) | ||
{ | ||
uint32_t didr; | ||
ARM_DBG_READ(c0, c0, 0, didr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let' use cp15 approach which is more elegance:
https://github.com/apache/nuttx/blob/master/arch/arm/include/armv7-a/cp15.h#L71
static int arm_get_num_brps(void) | ||
{ | ||
int brps = arm_get_num_brp_resources(); | ||
return core_has_mismatch_brps() ? brps - 1 : brps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove one breakpoint if hardware suport more than one.
{ | ||
uint32_t didr; | ||
ARM_DBG_READ(c0, c0, 0, didr); | ||
return ((didr >> 28) & 0xf) + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's define macro like cp15.h instead using magic number
(bp->ctrl.len == ARM_BREAKPOINT_LEN_2) ? 2 : | ||
(bp->ctrl.len == ARM_BREAKPOINT_LEN_4) ? 4 : 8)); | ||
|
||
memcpy(p, bp, sizeof(struct arm_hw_breakpoint)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move beore line 329 and remove line 333-336
size = arm_get_num_wrps(); | ||
} | ||
|
||
for (i = 0; i < size; i++, p += sizeof(struct arm_hw_breakpoint)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
(bp->ctrl.len == ARM_BREAKPOINT_LEN_2) ? 2 : | ||
(bp->ctrl.len == ARM_BREAKPOINT_LEN_4) ? 4 : 8)); | ||
|
||
memset(p, 0, sizeof(struct arm_hw_breakpoint)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
||
bp->ctrl.enabled = 1; | ||
|
||
if (bp->ctrl.type == ARM_BREAKPOINT_EXECUTE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not reuse:
#define DEBUGPOINT_NONE 0x00
#define DEBUGPOINT_WATCHPOINT_RO 0x01
#define DEBUGPOINT_WATCHPOINT_WO 0x02
#define DEBUGPOINT_WATCHPOINT_RW 0x03
#define DEBUGPOINT_BREAKPOINT 0x04
#define DEBUGPOINT_STEPPOINT 0x05
{ | ||
memset(bp, 0, sizeof(struct arm_hw_breakpoint)); | ||
|
||
bp->addr = (uint32_t)addr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need mask the low 2bits
Note: Please adhere to Contributing Guidelines.
Summary
Support hardware debugging of ARM architecture, and support smp mode
We can use "up_debugpoint_add" or "up_debugpoint_remove" to add breakpoints, and the hardware will jump into the interrupt after detecting it.
TODO:
Support singlestep
Impact
It will not affect our program.
Registration callback is not supported yet,the debug of arm32 jumps into the exception vector table, and it is also necessary to develop the jump function of the exception vector table in debug mode
Testing
Use arm32 boards, call "up_debugpoint_add", "up_debugpoint_remove" api, and set the breakpoint address.
log:
DFSR: 00000002 indicates that the abnormal debugging mode is entered