How to configure application properly?

Jul 01, 2013 10 Replies

Hello:



I am using Keil uVision version 5.40. I load the application in my target board using



Keil ULINK2 Debugger. I can jump to my startup code. When I get to the following instruction:


bx __main()



I cannot single step into Keil's __main(). When I try stepping into it, code starts running.



When I hit stop execution, I end up in the following filename (RT_Agent.c):


void _sys_exit (int return_code) { /* Endless loop. */ while (1); }



My guess is I'm not configuring my application properly.



Please advise!



--------------------------------------- Posted through

formatting link


Does Keil provide source for their __main, or is it library code? If there's no debugging symbols for __main (as would be if they did not provide source) then you can't step into it with a symbolic debugger.

The debugger should let you single-step the processor (rather than going line-by-line through code). You might try that.

Tim Wescott Control system and signal processing consulting www.wescottdesign.com

code.

No, it's library code. I can't even step into __main(). The debugger does let

me single step until I get to following instruction:

bx __main()

When I try to step into __main(), the code starts running.

It could be problem with my installation of uVision version 5.4 or debugger firmware.

--------------------------------------- Posted through

formatting link

Yes it is the start up library code. If you open up the disassembly window, give the disassembly window focus, then single step you can step through its assembly code - you see it doing zeroing and scatter loading, and then bx'ing to main().

As far as how to configure the application - start with an example for your chip that comes with the tools, when that works, adapt or copy it.

Regards, Richard.

  • formatting link
    Designed for microcontrollers. More than 103000 downloads in 2012.

  • formatting link
    Trace, safety certification, FAT FS, TCP/IP, training, and more...

Single step THE PROCESSOR. If you're "single stepping" in the symbolic debugger then the behavior you'll see is exactly what you are seeing.

It sounds like Richard has already given you guidance, but it's wise to remember that ANY debugger worth its salt (which is nearly all that I have used) will have some sort of bare-metal mode that lets you look at the disassembled code in memory, and step through individual processor instructions, even when what's there is not tied to any code that the debugger can find.

If you haven't identified and used the debugger mode that lets you single step the processor itself, then the debugging problem is somewhere between the front of the monitor and the keyboard.

_sys_exit is what gets called when your main() exits, which it should never do in any normal embedded system.

Tim Wescott Wescott Design Services http://www.wescottdesign.com

it,

going

does

debugger

minutes but haven't reached my main(). If I run, I get stuck at while(1) mentioned earlier.

I'll try to find example for this chip and see if I can use it to get to my main().

--------------------------------------- Posted through

formatting link

What does your main() look like? If this is just a bare-bones main() for test/evaluation purposes, are you "falling off" the end of it? Stick in a "while (1) { Toggle_a_pin(); /* or something */ }" and see what happens.

Ten

while(1)

my

Now I just have bare-bones main() now. It has while(1), but I still can't break there. I end up in my initialization assembly startup file.

I can make it main() with an example application.

--------------------------------------- Posted through

formatting link

Something is happening within the startup code that is making it decide to bomb.

Finding startup code that is correct for your chip is probably best, if such exists.

Tim Wescott Wescott Design Services http://www.wescottdesign.com

for

file.

your help!

--------------------------------------- Posted through

formatting link

Something that I haven't seen anyone ask, but should have thought of myself:

Is there an evaluation board for this chip out there someplace, and does it come with a Keil tool chain? Often your best bet is to start with a demo application and go from there.

Tim Wescott Wescott Design Services http://www.wescottdesign.com

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required