Once you have mastered writing and running a small program, you'll want to check out some of the more advanced techniques required to write and run real application programs. In this chapter, we cover the following topics:
Customizing the start file and linker script file
Checking for stack overflow
Generating PROM programming files
Using the debugger
Using optimizations
Working on the target
The boot PROM
Temic revisions CBA and CCA
On a real project you will almost certainly need to customize the start file and the linker script file. These contain details of the target hardware configuration and project options such as running in user mode or supervisor mode.
The run-time system file arto.S is known as the "start file". It contains instructions to initialize the arithmetic unit, floating point unit and system registers and is responsible for interrupt and fault handling. On the ERC32, arto.S is approximately 5K bytes ins size, and contains several
The start file art0.S contains instructions to initialize the arithmetic unit, floating point unit and system registers. The default start file may be suitable for your requirements. You can see the source code in file /opt/erc32-ada-1.7/erc-coff/src/libc/art0.S. If it is not suitable, make a copy in a working directory, then edit it as necessary.
Example 2-1. Creating a Custom Start File
$ mkdir work $ cd work $ cp /opt/erc32-ada-1.7/erc-coff/src/libc/art0.S . $ vi art0.S
One of the configuration parameters you may wish to change is the clock speed. The default speed is 20 MHz, which is the clock frequency of the Temic Starter Kit. If your clock runs at (say) 35 MHz, then you should modify the statement in art0.S that defines the clock frequency.
Once you have completed the changes, you must compile
art0.S to generate an object code file called
art0.o. This is the file that the default linker
script will look for. Note that the compiler will select Temic TSC695E by
default. If your target is a Temic Revision CBA, then use the compile-time
option -mcba
.
The following example gives the command you need:
If you now rebuild your application program, the local file art0.0 will be used in preference to the library file. In the following example we use the linker's -t option to list the files that are included in the link.
Example 2-3. Rebuilding with a Custom art0.S
$ erc-coff-gnatmake -f hello -largs -Wl,-t erc-coff-gcc -c hello.adb erc-coff-gnatbind -x hello.ali erc-coff-gnatlink -Wl,-t hello.ali /opt/erc32-ada-1.7/erc-coff/bin/ld: mode erc_ram art0.o b~hello.o ./hello.o ... and more files ...
Note: If you run a program built for 35 MHz on the simulator, be sure to specify a clock frequency of 35 MHz. The default is 20 MHz.