m3dev

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit a15e2092bf15556a0fcf354952944d0d0cede77a
parent deab0abef44cb4d541aa33789445a703c7ff8ddc
Author: Brian Swetland <swetland@frotz.net>
Date:   Mon, 15 Jun 2015 04:43:24 -0700

debugger: ensure processor is happy before invoke()ing agents

Targets with garbage at 0 may be in an exceptions-pending
state after reset-stop, so clear exceptions and make sure
PSR is sane, in addition to PC, SP, and friends.

A more sure way to avoid this would be to hold the target's
SYSRESETn asserted while setting up, but that's target-
specific.

See this ARM KB article:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka16214.html

Diffstat:
Mtools/debugger-commands.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/debugger-commands.c b/tools/debugger-commands.c @@ -523,6 +523,12 @@ int invoke(u32 agent, u32 func, u32 r0, u32 r1, u32 r2, u32 r3) { swdp_core_write(14, agent | 1); // include T bit swdp_core_write(15, func | 1); // include T bit + // if the target has bogus data at 0, the processor may be in + // pending-exception state after reset-stop, so we will clear + // any exceptions and then set the PSR to something reasonable + swdp_ahb_write(0xe000ed0c, 0x05fa0002); + swdp_core_write(16, 0x01000000); + // todo: readback and verify? xprintf("invoke <func@%08x>(0x%x,0x%x,0x%x,0x%x)\n", func, r0, r1, r2, r3);