How to configure application properly?

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

Reply to
janii
Loading thread data ...

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 
 Click to see the full signature
Reply to
Tim Wescott

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

Reply to
janii

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...

Reply to
FreeRTOS info

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 
 Click to see the full signature
Reply to
Tim Wescott

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

Reply to
janii

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.

Reply to
Rich Webb

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

Reply to
janii

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 
 Click to see the full signature
Reply to
Tim Wescott

for

file.

your help!

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

formatting link

Reply to
janii

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 
 Click to see the full signature
Reply to
Tim Wescott

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.