Other Parts Discussed in Thread: CONTROLSUITE
Hi there,
I experienced a couple of strange crashes in the simulator (CCS 3.3) trying to use malloc(). Then I realized various pointers had not been initialized. The debugger was at the entry into main() after loading / restart. I am using the large memory model library with exception handling.
I finally stumbled across c_int00() in the documentation. I noticed that this wasn't linked or called. I never did anything explicitly to circumvent this code from linking or executing, however, I do have to use a linker command file fairly closely based on the one used in this project, which I will attach below for inspection.
Out of curiosity I put the following code into my main.cpp source just before main():
extern "C" {
void c_int00(void);
void (*dummy)() = c_int00;
}
Low and behold, the function is now linked and the debugger starts at at the entry to c_int00() after a reset. Also, SP and other initializations now seem to be as expected. My program (a unit test, written in a mixture of C and C++ and based on CppUTest) still does not run without problems, but the apparent problems caused by uninitialized code at least are gone.
My questions are this:
- Why did c_int00() not get linked? Of course there was no reference to it in the code, since it is supposed to be linked and executed "behind the scenes". Surely one should not have to resort to weird tricks like the above?
- Now that it does get linked and executed, is it normal for the Debugger to start at c_int00(), so that I first need to issue a "Go Main" command?
- Is there any way of using a simple, no-frills memory map for simulator runs? What would be the simplest possible memory map to use on the actual device?
- Currently, the stack has a size of 0x0800. This should be plenty, unless things go wrong. Where in the memory map could I allocate a larger space for the stack, should this be necessary?
- What is the point of the -farheap0x10000 -heap0x1000 -stack0x800 linker options when I need to specify in the linker command file exactly where and how large each of these sections should be? My idea would be to use these options and leave it to the linker where exactly it wants to place each. Conversely, when I do have to use .cmd files, what are the options for? Must I use both?
I built this same unit test (identical code except for the deviation mentioned above) for ARM using the IAR Embedded Workbench. On that platform, I could simply compile and link, using pretty much the default options, then load the binary in the simulator and execute it without a hitch, so it's not like there is anything inherently wrong with CppUTest or my code.
http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/171/0624.Example.7z