Chapter 2. Advanced Techniques

Table of Contents
2.1. How to Customze the Start File
2.2. How to Customize the Linker Script File
2.3. How to Get a Map File
2.4. Checking for Stack Overflow
2.5. Generating PROM Programming Files
2.6. Using the Debugger
2.7. Using Optimizations
2.8. Working with the Target
2.9. The Boot PROM
2.10. Working with the EDAC
2.11. System Calls

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:

2.1. How to Customze the Start File

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 LEON, 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/leon-ada-1.8/leon-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/leon-ada-1.8/leon-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 Atmel AT697F by default. If your target is a AT697E, then use the compile-time option -mv7.

The following example gives the command you need:

Example 2-2. Recompiling art0.S

$ leon-coff-gcc -c art0.S

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

$ leon-coff-gnatmake -f hello -largs -Wl,-t
leon-coff-gcc -c hello.adb
leon-coff-gnatbind -x hello.ali
leon-coff-gnatlink -Wl,-t hello.ali
/opt/leon-ada-1.8/leon-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.