Solved

How to configure application properly?

Posted on 2013-07-01
7
254 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
  • 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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
 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now