0

I'm trying to dynamically analyze the firmware of a NXP LPC1752 (Cortex-M3) based USB device. This firmware contains a WFI instruction which seems to interfere my attempts in that the device sometimes can't be accessed by the JTAG-probe anymore. The probes used for testing are a Segger JLink-Edu v9.3 using Seggers own or OpenOCD as GDB-server, and a BusBlaster v2.5 with OpenOCD.

I tried to remove the WFI by replacing it with a NOP or an empty infinite loop. Either way the device does not enumerate anymore.

As this WFI instruction is accompanied with a couple NOP's I'm asking if there is a code sequence that can do what WFI does, just without entering sleep mode?

user2011659
  • 847
  • 1
  • 7
  • 15
  • What actual MCU is it, and does your debug probe/software have specific support for that or just generic support for the Cortex-M3 core? There's typically some device-specific configuration necessary to put the debug logic into a mode where it stays powered and clocked independently from the core, to prevent exactly the problem you're seeing. – Notlikethat Nov 29 '15 at 21:29
  • I updated the initial question with more info. – user2011659 Nov 29 '15 at 21:38

1 Answers1

0

WFI has nothing to do with your problem. Processor can enter and exit sleep modes and you still should be able to have debugger session active. See also this sentence from infocenter.arm:

debug operation wakes up the processor

As Notlikethat mentioned - most probably you're losing power or clock source. It depends on your hardware how it's exactly implemented. Maybe you need to keep "power on" button or change some kind of jumpers before connecting debugger? I don't know what exactly board your're using.

Regarding replacing WFI: in theory you can just insert NOP in a loop and handle interrupts manually, but there is no single instruction for it. Also, have in mind, that if you have some OS running, the WFI instruction can be issued from many places (for instance delay loops).

Good luck.

mkmk88
  • 271
  • 1
  • 4