README.md 5.52 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
Building RTEMS via the RSB
--------------------------
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
14
The contrib folder includes a script that you can use to compile RTEMS4.12
15 16 17 18 19 20 21 22
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.

23 24 25 26 27
Executive summary: if you want to build native-FPU-using binaries,
you'll need to edit leon2.cfg/leon3.cfg and remove the `-msoft-float`
before building the BSPs (that is, right after the clone from
the RTEMS git repository - in line 87 of the script).

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
28 29
Application sources
-------------------
30 31
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 
32 33
your source tree:

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
34 35
    VPATH=src:Library/foo:Library/bar:...

36
    SRC= \
Thanassis Tsiodras's avatar
Cleanup  
Thanassis Tsiodras committed
37 38 39 40 41
        init.c           \
        tasking.c        \
        gnc.c            \
        compute_pi.c

42 43 44 45 46 47 48 49
# 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
50

Thanassis Tsiodras's avatar
Cleanup  
Thanassis Tsiodras committed
51
## Debug/Release mode
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
52

Thanassis Tsiodras's avatar
Cleanup  
Thanassis Tsiodras committed
53 54
Using the `CFG` Makefile parameter, you can select debug or release 
compilation:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
55

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
56 57
    $ make CFG=debug
    ...
58
    $ ls -l bin.debug.NONFPU.leon3/
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
59 60 61 62
    -rwxr-xr-x 1 user user 645273 Mar 16 17:43 fputest

    $ make CFG=release
    ...
63
    $ ls -l bin.release.NONFPU.leon3/
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
64 65 66
    -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

67
Notice that:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
68

69 70 71 72 73 74
- 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
75

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

78 79
To use native FPU compilation for the source files, use the `FPU`
Makefile parameter:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
80

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
81
    $ make CFG=debug FPU=1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
82

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

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
85
    $ make CFG=debug FPU=0
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
86

Thanassis Tsiodras's avatar
Cleanup  
Thanassis Tsiodras committed
87
...or just don't mention `FPU` at all:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
88

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
89 90 91 92
    $ 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
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
93
emulation. Just keep in mind that currently, 4.12 
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
94 95 96
[does not allow you to use the same BSP](https://lists.rtems.org/pipermail/users/2016-February/029782.html),
for both native and emulated FPU usage ; you'll have to build separate
BSPs by tweaking the `leon2.cfg`/`leon3.cfg` files when you build RTEMS.
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
97

98 99 100 101 102 103 104
## 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
Cleanup  
Thanassis Tsiodras committed
105
## Verbosity
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
106

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
107 108
Messages shown during compilation follow the semantics of the Linux kernel
compilation process, emitting short messages by default (CC for compilation,
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
109 110
 LD for linking). The compilation is also incremental, taking into account
the modification timestamps of the files and their dependencies:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
111 112 113

    $ touch src/task1.c
    $ make
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
114 115
    [CC] objs.debug.NONFPU.leon3/task1.o
    [LD] bin.debug.NONFPU.leon3/fputest
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
116

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
117
If you want to see the complete commands used, pass `V=1`:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
118 119

    $ touch src/task1.c
Thanassis Tsiodras's avatar
Cleanup  
Thanassis Tsiodras committed
120
    $ make CFG=debug FPU=0 V=1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
121 122
    /opt/rtems-4.12-2016.06.13.NONFPU/bin/sparc-rtems4.12-gcc -c \
        -B/opt/rtems-4.12-2016.06.13.NONFPU/sparc-rtems4.12/leon3/lib \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
123 124 125 126 127
        -specs bsp_specs -qrtems -mcpu=cypress -DBSP_leon3 -ffunction-sections \
        -fdata-sections -Wall -Wmissing-prototypes \
        -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs \
        -g -Wall -D_DEBUG -I src -msoft-float \
        -o objs.debug.NONFPU.leon3/task1.o src/task1.c
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
128
    /opt/rtems-4.12-2016.06.13.NONFPU/bin/sparc-rtems4.12-gcc -g \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
129 130 131
        -o bin.debug.NONFPU.leon3/fputest objs.debug.NONFPU.leon3/init.o \
        objs.debug.NONFPU.leon3/task1.o objs.debug.NONFPU.leon3/task2.o \
        objs.debug.NONFPU.leon3/common.o -msoft-float \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
132
        -B/opt/rtems-4.12-2016.06.13.NONFPU/sparc-rtems4.12/leon3/lib \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
133 134 135 136
        -specs bsp_specs -qrtems -mcpu=cypress -DBSP_leon3 \
        -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes \
        -Wimplicit-function-declaration -Wstrict-prototypes \
        -Wnested-externs -Wl,--gc-sections
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
137
    Built with RTEMS at /opt/rtems-4.12-2016.06.13.NONFPU/sparc-rtems4.12/leon3/lib for leon3.
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
138

139 140 141 142 143
# Support

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

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
144 145 146 147 148 149 150 151 152 153 154
    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