next up previous contents
Next: sparc_linux: Linux/SPARC Process as Up: Virtual Targets Previous: Virtual Targets

Compiling and Running on Virtual Targets

There is no need to build a cross-compiler for virtual targets: the native gcc, assembler and linker all work fine. (The GNU toolchain is required, though Linux distributions come with it.) Compiling uCR is then reduced to setting UCR and TARGET, and typing make in the ucr/source directory. The parts that are not applicable to virtual boards will not be built.

Build uCR applications the same as you would for any other target. The output .exe file is ELF format (for all linux targets) and can be directly executed. The return from main() is passed as the exit code from the process (Hey, a board that exits) just like any other Linux process, but command line parameters are currently not supported.

The uCR remote debugging support is not required or included when building for virtual boards. It is reasonable and convenient to use the native debugger on a virtual board application as if it were any other Linux program. This in fact works extremely well and is highly recommended for debugging routines that do not require any special hardware. Unfortunately, the host debugger typically does not understand the uCR thread structure, so the thread capabilities of gdb will not work.

Since the Linux virtual machine is well defined, uCR includes all the necessary runtime files, including the locore.o file and linker models. The makefile for compiling a simple program could look like the following:

include $(UCR)/make/rules.mk
TARG := file.exe
OBJ := hello.o
LIBS := 
MODEL := linux.ld
include $(UCR)/make/image.mk

Notice that the .exe file is the desired output, and will be an executable ELF file. This sample makefile will work for any of the virtual targets, unless otherwise noted.


next up previous contents
Next: sparc_linux: Linux/SPARC Process as Up: Virtual Targets Previous: Virtual Targets
Stephen Williams
9/2/1997