README.md 5.15 KB
Newer Older
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
1 2 3
Introduction
============

4 5
This folder contains the OAR RTEMS scaffolds. The Makefile and example
source code demonstrates how to:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
6 7 8

* support both debug and release compilations
* support compilation for native and emulated FPU usage
9 10
* support targetting Leon2 and Leon3 CPUs
* enable/disable showing compilation commands
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
11

12 13 14 15 16 17 18 19 20 21 22
Building RTEMS via the RSB
--------------------------
The contrib folder includes a script that you can use to compile RTEMS4.11
with the Leon2 and Leon3 BSPs from the OAR repository. Note that
[as discussed in the RTEMS mailing list](https://lists.rtems.org/pipermail/users/2016-February/029782.html),
you will need to compile your BSP for native or emulated FPU, based
on what your desired target is (i.e. edit the leon2.cfg/leon3.cfg 
files to remove `-msoft-float` or not). The Makefile mirrors this
need, by pointing to different paths (see FPU_SUFFIX variable),
depending on whether you build with FPU=1 or not.

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
23 24
Application sources
-------------------
25 26
The sources of your project must be set inside the Makefile, in the SRC
variable. The VPATH can be used to automatically locate them in 
27 28
your source tree:

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
29 30
    VPATH=src:Library/foo:Library/bar:...

31
    SRC= \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
32 33 34 35 36
        init.c           \
        tasking.c        \
        gnc.c            \
        compute_pi.c

37 38 39 40 41 42 43 44
# Compilation options

There are 4 orthogonal compilation options that you can control:

- debug/release compilation (`CFG`)
- emulated/native FPU compilation (`FPU`)
- Leon2/Leon3 target (`LEON`)
- show/hide compilation commands (`V`)
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
45

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
46
## Debug/Release mode
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
47

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
48 49
Using the `CFG` Makefile parameter, you can select debug or release 
compilation:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
50

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
51 52
    $ make CFG=debug
    ...
53
    $ ls -l bin.debug.NONFPU.leon3/
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
54 55 56 57
    -rwxr-xr-x 1 user user 645273 Mar 16 17:43 fputest

    $ make CFG=release
    ...
58
    $ ls -l bin.release.NONFPU.leon3/
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
59 60 61
    -rwxr-xr-x 1 root root  47860 Mar 16 17:48 fputest
    -rwxr-xr-x 1 root root 585178 Mar 16 17:48 fputest.debug

62
Notice that:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
63

64 65 66 67 68 69
- In release compilation, the process creates a small binary
  (containing only the executable code) and separately, the debug information -
  for loading from inside GDB via the `file` command.
- Notice also that the output folder tells you this build did not use
  native FPU, and targeted Leon3 (the defaults). To compile for 
  native FPU or a different Leon target, use the next two options.
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
70

71
## Native or emulated FPU compilation for the source files
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
72

73 74
To use native FPU compilation for the source files, use the `FPU`
Makefile parameter:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
75

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
76
    $ make CFG=debug FPU=1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
77

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
78
To use emulation (default, if `FPU` option is not provided), pass `FPU=0`:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
79

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
80
    $ make CFG=debug FPU=0
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
81

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
82
...or just don't mention `FPU` at all:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
83

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
84 85 86 87 88
    $ make CFG=debug

The `FPU` and `CFG` options are completely independent ; you can e.g.
compile a debug version that uses native FPU, and a release one that uses
emulation.
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
89

90 91 92 93 94 95 96
## Select Leon target

Use the `LEON` Makefile parameter to decide which target to build for
(currently, only `leon2` and `leon3` are supported):

    $ make CFG=debug FPU=1 LEON=leon3

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
97
## Verbosity
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
98

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
99 100 101
Messages shown during compilation follow the semantics of the Linux kernel
compilation process, emitting short messages by default (CC for compilation,
 LD for linking):
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
102 103 104 105 106 107

    $ touch src/task1.c
    $ make
    [CC] objs.debug/FPU_task1.o
    [LD] bin.debug/fputest

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
108
If you want to see the complete commands used, use `V=1`:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
109 110

    $ touch src/task1.c
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
111
    $ make CFG=debug FPU=0 V=1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
112 113 114 115 116
    sparc-rtems4.8-gcc -c \
        -B/home/user/development/rtems/sparc-rtems4.8/leon3/lib \
        -specs bsp_specs -qrtems -nodefaultlibs -mcpu=cypress -DBSP_leon3 \
        -g -Wall -D_DEBUG \
        -I/home/user/development/build/rtems-impr/testsuites/support/include \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
117 118
        -I src -msoft-float -o objs.debug/FPU_task1.o src/task1.c
    sparc-rtems4.8-gcc -g -o bin.debug/fputest objs.debug/NONFPU_init.o \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
119 120 121
        objs.debug/NONFPU_printk.o objs.debug/NONFPU_leon3.o \
        objs.debug/FPU_task1.o -msoft-float \
        -B/home/user/development/rtems/sparc-rtems4.8/leon3/lib \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
122 123 124 125 126 127 128 129
        -specs bsp_specs -qrtems -nodefaultlibs -mcpu=cypress -DBSP_leon3  \
        -nodefaultlibs -Wl,--wrap,_IO_Initialize_all_drivers \
        /home/user/development/rtems/sparc-rtems4.8/leon3/lib/libno_event.a \
        /home/user/development/rtems/sparc-rtems4.8/leon3/lib/libno_msg.a \
        /home/user/development/rtems/sparc-rtems4.8/leon3/lib/libno_sem.a \
        /home/user/development/rtems/sparc-rtems4.8/leon3/lib/libno_timer.a \
        /home/user/development/rtems/sparc-rtems4.8/leon3/lib/libno_rtmon.a \
        /home/user/development/rtems/sparc-rtems4.8/leon3/lib/libno_ext.a \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
130 131 132 133
        -Wl,--start-group \
        -lrtemscpu -lio -lno_event -lno_msg -lno_sem \
        -lno_timer -lno_rtmon -lno_ext -lrtemsbsp -llibc -lrtemscpu \
        -Wl,--end-group \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
134 135
        -Wl,--script=linkcmds -B/tmp/edilibtmp/edilib/library -lgcc

136 137 138 139 140
# Support

For any questions/feedback, raise tickets in the repository and/or contact
me directly:

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
141 142 143 144 145 146 147 148 149 150 151
    Thanassis Tsiodras
    Real-time Embedded Software Engineer 
    System, Software and Technology Department
    Address:
        ESTEC/Office EF216
        Keplerlaan 1, PO Box 299
        NL-2200 AG Noordwi
    E-mail:
        Athanasios.Tsiodras@esa.int
    Phone:
        +31 71 565 5332