Solved

How to configure application properly?

Posted on 2013-07-01
7
264 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
 
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

809 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