SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By davidbinar
#18410
My program "crashes" in Newlib's malloc, that is; I get an undefined instruction exception somwhere inside malloc. But when I then do a soft_reset_halt to OpenOCD my program starts up ok and malloc works fine.

What is it that makes my program run after a soft_reset_halt but not when starting up from a "real" reset or when i disconnetc/reconnect the power to the board?

I'm developing on an Olimex board with an LPC2294 using winarm/GCC with the precompiled newlib from winarm.

/David
By Dominic
#18413
"Use the source, luke" ;)

Sorry, I couldn't resist. But really, it's all in src/target/arm7_9_common.c, in a function called arm7_9_soft_reset_halt:

- if the target is running, request a halt
- wait till the target acknowledges debug entry
- mark all register content as invalid
- set I and F bits in the CPSR
- set the PC to 0x0
- set current mode to SVC
- set execution to ARM mode
(until here, that's what the architecture guarantess)
- additionally, the OpenOCD initializes all registers in SVC to 0xffffffff, making problems with uninitialized registers easier to spot

A "soft_reset_halt" doesn't initialize any system peripherals, like PLL, memory configuration registers, etc.

To debug your problem, I would place a (hw) breakpoint on 0x4, and see where r14_undef points at. It might be easier to work with the telnet interface rather than GDB, as it gives you closer control over what happens.

Regards,

Dominic