README.md 5.4 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.

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 93
    $ 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
94

95 96 97 98 99 100 101
## 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
102
## Verbosity
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
103

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
104 105 106
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
107 108 109 110 111 112

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

Thanassis Tsiodras's avatar
Cleanup  
Thanassis Tsiodras committed
113
If you want to see the complete commands used, use `V=1`:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
114 115

    $ touch src/task1.c
Thanassis Tsiodras's avatar
Cleanup  
Thanassis Tsiodras committed
116
    $ make CFG=debug FPU=0 V=1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
117 118 119 120 121
    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
122 123
        -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
124 125 126
        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
127 128 129 130 131 132 133 134
        -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
135 136 137 138
        -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
139 140
        -Wl,--script=linkcmds -B/tmp/edilibtmp/edilib/library -lgcc

141 142 143 144 145
# Support

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

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