RES: RES: How to generate a raw C program with xxx-rtems-gcc?

Fabrício de Novaes Kucinskis fabricio at
Thu Jan 12 18:11:57 UTC 2006


Thank you for the (quick!) answer.

If there's no more non-RTEMS toolchain, I'll follow the Aleix's instructions
to compile my raw-C test applications.
Best regards,


-----Mensagem original-----
De: Jiri Gaisler [mailto:jiri at]
Enviada em: quinta-feira, 12 de janeiro de 2006 16:05
Para: Fabrício de Novaes Kucinskis
Cc: Aleix Conchillo Flaqué; RTEMS - Mailing List
Assunto: Re: RES: How to generate a raw C program with xxx-rtems-gcc?

We did have toolchains that could compile both rtems and non-rtems
apps for erc32 (ERC32CCS and LECCS), but these have been discountinued.
It is difficult to compile the C-library to be compatible with both
rtems and non-rtems application. Today we have an rtems-only
toolchain (RCC) which is the same as the toolchain provided by
OAR, and a non-rtems toolchain (BCC) for the LEON processors.
We do no longer maintain a non-rtems toolchain for erc32.


Fabrício de Novaes Kucinskis wrote:
> Aleix,
> Thank you very much for the "tutorial"!
> I'll follow your instructions and I'm sure it'll work. But there's no
> simpler way to do this?
> In the RTEMS ERC32 package that ESA/ESTEC distributed (version 4.0.0
> by Jiri Gaisler), there was a switch in sparc-rtems-gcc, "-rtems". Without
> this switch, the application created would be raw C. I don't know if this
> switch was specific to the ERC32 port, or if it was available to any RTEMS
> port.
> I'm using now RTEMS 4.6.4. I read somewhere about a "-nortems" switch, but
> this switch is not recognized by the compiler.
> I would like to ask to Joel, Jiri or another RTEMS guru: there's a switch
> compile raw C programs using sparc-rtems-gcc? If not, I'll use the
> Aleix gave.
> Thanks again,
> Fabrício.
> -----Mensagem original-----
> De: Aleix Conchillo Flaqué [mailto:aconchillo at]
> Enviada em: segunda-feira, 9 de janeiro de 2006 15:44
> Para: Fabrício de Novaes Kucinskis
> Cc: RTEMS - Mailing List
> Assunto: Re: How to generate a raw C program with xxx-rtems-gcc?
> Hi,
> yes, it is possible, but you'll have to change some things.
> I'm not sure if what I'm going to explain is the best way to do it,
> but it has worked for me, and I have ran programs generated this way
> in a real board.
> 1. You will need to get the sparc ERC32 asm.h, sparc.h, cpu.h,
> start.S, window.S and syscall.S.
> 2. Modify start.S, so it does not call any RTEMS code, that is,
> commenting this lines:
> /*
>           call    __bsp_board_init
>           nop
>           set     (SYM(rdb_start)), %g6   ! End of work-space area
>           st      %sp, [%g6]
>           set     (SYM(Configuration)), %l1
>           ld      [%l1+4], %l3            ! work_space_size
>           sub     %sp, %l3, %sp           ! set %sp to area below
> work_space
>           andn    %sp, 0x0f, %sp          ! align stack on 16-byte
> boundary
> */
> 3. Compile start.S, window.S and syscall.S. You can remove many
> things from the header files, but that's up to you.
> sparc-rtems4.6.1-gcc -DASM -c -o start.o start.S
> 4. Compile your C files.
> sparc-rtems4.6.1-gcc -O4 -Wall -mcpu=cypress -c -o test.o test.c
> 5. And the last thing is to link your program:
> sparc-rtems4.6.1-gcc -mcpu=cypress -Betc -specs my_bsp_specs -o test
> window.o syscall.o test.o
> Note the arguments -B and -specs. -specs is used to specify a file
> with extra information for the compiler. By default RTEMS uses the
> file bsp_specs, it is in erc32/lib directory. Edit it an you will see
> that it automaticaly links with the RTEMS libraries and adds its own
> start.S object file. The -B flag is used to specify the directory to
> find this file (I have used an etc/ directory).
> So, what we need to do is to create our own file (my_bsp_specs) which
> will not use any RTEMS library and which will point to our compiled
> start.S object file.
> Basically,
> ------------------
> *endfile:
> crtend.o%s crtn.o%s
> *lib:
> -T linkcmds
> *startfile:
> start.o crti.o%s crtbegin.o%s
> *link:
> -dc -dp -N -e start
> ------------------
> The %s indicates to search the file in the compiler specific
> directories. I removed the %s from start.o so It will search for it
> in the current directory.
> Another important thing to note in this file is the -T linkcmds. This
> indicates the linker script to be used by GNU LD. You better check
> the GNU LD manual to understand it, I was a bit confused the first
> time I saw it. Anyway, you can use the one that comes with RTEMS (in
> erc32/lib).
> Note that when linking, we have not specified the start.o file as it
> is already done in the my_bsp_specs file.
> Also, many of this things are explained in the RTEMS BSP and Device
> Driver Development Guide.
> Of course you will need to investigate to make it work but I hope
> this information helps you.
> Best regards,
> aleix
> On 22 Dec 2005, at 19:44, Fabrício de Novaes Kucinskis wrote:
>>Hi all,
>>First of all, I'm sorry for asking so many questions in the last
>>few days.
>>It's because I was just setting up my development environment in
>>the free
>>time (or better said, my "idle" time), and now I'm starting to work
>>RTEMS in full-time.
>>I hope I'll soon stop to ask, and start to answer here in the list ;)
>>Well, let's go: Is it still possible to compile raw C applications
>>RTEMS libs) using xxxx-rtems-gcc?
>>I have some applications which I created to test my development
>>board (an
>>ERC32 from Tharsys) and compiled under sparc-rtems-gcc from
>>I updated to RTEMS-4.6.4, created some RTEMS applications with
>>success, and
>>tried to run these raw C ERC32 apps, but when loading them with gdb
>>I got
>>the error "memory access error while loading".
>>I tried to recompile the source code and got the message "cannot
>>find symbol
>>_start". Then I pointed to the "linkcmds" file using the -T switch
>>and the
>>program was compiled with no warnings or errors.
>>But when I load and run the application nothing happens; the
>>program I'm
>>using is just a HelloWorld, and it just finishes doing nothing. I
>>breakpoints in main() and in the ERC32 initial address (0x2000000),
>>but none
>>of then is reached.
>>Am I doing something - or everything - wrong? How can I compile a
>>"raw C"
>>app with sparc-rtems-gcc from RTEMS 4.6.4?
>>Thanks in advance,
>>Fabrício de Novaes Kucinskis - DEA / INPE
>>Divisão de Eletrônica Aeroespacial
>>Instituto Nacional de Pesquisas Espaciais
> .

More information about the users mailing list