README.md 5.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
Introduction
============

This folder contains the EDISOFT RTEMS scaffold. It showcases 
how to:

* support both debug and release compilations
* support compilation for native and emulated FPU usage
* support targetting Leon2 and Leon3 CPUs
* enable/disable showing compilation commands

Application sources
-------------------
Due to [FPU register corruption issues that are caused by a GCC bug](https://devel.rtems.org/wiki/TBR/UserManual/Floating_Point_Support), the building of RTEMS EDISOFT applications must be done
with separate compilation for non-FPU tasks (i.e. with -msoft-float)

The sources of your project must therefore be set inside the Makefile in two
sets: in the FPU_SRC and NONFPU_SRC variables. The VPATH can then be used
to automatically locate them in your source tree:

    VPATH=src:Library/foo:Library/bar:...

    NONFPU_SRC=          \
        init.c           \
        tasking.c        \
        ...

    FPU_SRC=             \
        gnc.c            \
        compute_pi.c

As their names suggest, you add a file in the FPU_SRC list if you want it
to be compiled for native FPU use (i.e. without `-msoft-float`).
Whether native or emulated FPU compilation is actually performed on the FPU_SRC,
is selected during build time by the `FPU` Makefile parameter (see below)

# Compilation options

39 40 41 42 43 44 45
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`)

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
## Debug/Release mode

Using the `CFG` Makefile parameter, you can select debug or release 
compilation:

    $ make CFG=debug
    ...
    $ ls -l bin.debug.NONFPU.leon3/
    -rwxr-xr-x 1 user user 645273 Mar 16 17:43 fputest

    $ make CFG=release
    ...
    $ ls -l bin.release.NONFPU.leon3/
    -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

Notice that:

64
- In release compilation, the process creates a small binary
65 66
  (containing only the executable code) and separately, the debug information -
  for loading from inside GDB via the `file` command.
67
- The output folder indicates that the NONFPU (i.e. `-msoft-float`
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
  everywhere) and `Leon3` options were automatically selected.
  These are the default options unless you select different
  (see following sections)

## Native or emulated FPU compilation for the FPU_SRC source files

To use native FPU compilation for the FPU_SRC list of source files, use the
`FPU` Makefile parameter:

    $ make CFG=debug FPU=1

To use emulation (default, if `FPU` option is not provided), pass `FPU=0`:

    $ make CFG=debug FPU=0

...or just don't mention `FPU` at all:

    $ 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.

## 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

## Verbosity

Messages shown during compilation follow the semantics of the Linux kernel
compilation process, emitting short messages by default (CC for compilation,
 LD for linking):

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

If you want to see the complete commands used, use `V=1`:

    $ touch src/task1.c
    $ make CFG=debug FPU=0 V=1
    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 \
        -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 \
        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 \
        -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 \
        -Wl,--start-group \
        -lrtemscpu -lio -lno_event -lno_msg -lno_sem \
        -lno_timer -lno_rtmon -lno_ext -lrtemsbsp -llibc -lrtemscpu \
        -Wl,--end-group \
        -Wl,--script=linkcmds -B/tmp/edilibtmp/edilib/library -lgcc

137 138 139 140 141
# Support

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

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