Solved

How to configure application properly?

Posted on 2013-07-01
7
271 Views
Last Modified: 2013-07-06
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!
0
Comment
Question by:naseeam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 32

Accepted Solution

by:
phoffric earned 500 total points
ID: 39293454
(Sorry I don't know ARM architecture.) Only suggestion I have is to put breakpoints everywhere you can especially if you are multithreaded. Be sure to put breakpoints on your main(), _sys_exit(), as well as in Keil's __main(). Instead of stepping, try run and see if you can stop on one of your breakpoints. If you are getting to Keil's __main(), but not to main(), then possibly an exception is being thrown by one of your constructors, so advise putting breakpoints in all of your constructors. In some debuggers, I have noticed that Next might fail whereas setting a breakpoint and then Continue will get over the problematic code with no problem.
0
 
LVL 1

Author Comment

by:naseeam
ID: 39294094
I commented out all my tasks and just inserted while(1) in my main().

I put breakpoint on all exception handlers but I don't break there.
0
 
LVL 32

Expert Comment

by:phoffric
ID: 39294244
You could have an uncaught exception from a constructor. Did you put breakpoints in all constructors of objects (and their base classes) that are created before you go to main()?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:naseeam
ID: 39296855
I put breakpoints in Three constructors.  Code didn't break in any of these constructors.

We are using Keil IDE which includes, makefile, debugger, real time OS, real time librarires, middleware libraries like TCP, USB.

I make it to Keil __main().  Then, there is strange software interrupt instruction as follows:

SWI #AB

#AB is a large number.  Usually these numbers are 1 through 12.  #AB seems questionable.
I think there is no handler for SWI and that's why I end up at while(1)?
0
 
LVL 32

Expert Comment

by:phoffric
ID: 39298021
As I mentioned, I don't have experience with ARM and Keil. I looked up SWI and I see it is a Software Interrupt Instruction (SWI).
     http://www.keil.com/support/man/docs/rlarm/rlarm_ar_swi_func.htm

Analogous to other systems, it looks like the argument is an index to SWI functions. The above link has the following:
SWI functions 0..7 are reserved for the RTX kernel.

Do not leave gaps when numbering SWI functions. They must occupy a continuous range of numbers starting from 8.
SWI functions can still be interrupted by FIQ interrupts.

So, I agree that #AB should not be a large number, especially since there should not be "gaps when numbering SWI functions".

I think you have at least narrowed down the source of your problem. Now you have to figure out how #AB got set to this large number. The above link has some configuration (programming) notes on what you have to do if you want to use SWI. It looks to me like the argument is a 5-bit number that you increment by 1 every time you add a new SWI function. Here are the instructions from that link on how to do this:
If you want to use SWI functions in your RTX kernel project, you need to:

1. Copy the SWI_Table.s file to your project folder and include it into your project.
 This file is located in the \Keil\ARM\RL\RTX\SRC\ARM folder. 

2. Declare a function with a __swi(x) attribute. Use the first SWI number, starting from 8, that is free. void __swi(8)  inc_5bit (U32 *cp);

3. Write a function implementation and convert the function name into a __SWI_x function name. This name is referenced later by the linker from SWI_Table.s module. void __SWI_8            (U32 *cp) {
  /* A protected function to increment a 5-bit counter. */
  *cp = (*cp + 1) & 0x1F;
}

4. Add the function __SWI_x to the SWI function table in the SWI_Table.s module.

 First import it from other modules: ; Import user SWI functions here.
                IMPORT  __SWI_8

then add a reference to it into the table: ; Insert user SWI functions here. SWI 0..7 are used by RTL Kernel.
                DCD     __SWI_8                 ; SWI 8  User Function

5. Your SWI function should now look like this: void __swi(8)  inc_5bit (U32 *cp);
void __SWI_8            (U32 *cp) {
  /* A protected function to increment a 5-bit counter. */
  *cp = (*cp + 1) & 0x1F;
}

Open in new window

Did you do follow this procedure? If not, hope this helps.
0
 
LVL 1

Author Closing Comment

by:naseeam
ID: 39304721
Thank you so much for all your help!  I reduced the code and disabled external RAM chip in my target board and now I can jump to main every time.  I replaced the board and now I can get to main() every time withe external RAM chip enabled.  The challenge will be to get to main after I slowly expand code to it's usual size.
0
 
LVL 32

Expert Comment

by:phoffric
ID: 39304900
Good that you can finally get to main(). I would check your mapping of the external RAM chip comparing what you have with examples in your documentation. Good luck adding in  more code and enabling the RAM chip.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question