Linux based
Embedded, Realtime and HMI
solutions

  Home
  News
     RTAI
     U-Boot
     RTEMS
     MPC8xx BDM
     Wireshark
     DMX USB Driver
  Links

RTEMS

RTEMS is short for RealTime Executive for Multi processor Systems ( formerly RealTime Executive for Military Systems). It is a small embedded realtime system that runs on several CPU's. There are a number of API's like the Classical RTEID (Real-Time Executive Interface Definition), POSIX and iTron. RTEMS is available under the BSP-style license and combined with a active user community it is a true OpenSource project.

I used RTEMS for several projects where the footprint of Linux is simply too big, or where the rich feature set of Linux is simply not needed.

RTEMS and U-Boot

I made a small (and now available in U-Boot CVS) addition to U-Boot to boot RTEMS images with it. To do this there are a few small changes needed to your RTEMS BSP startup code. The main alteration you have to do is to get the boot parameters from U-Boot. This must be done very early in the startup code or they can get overwritten by RTEMS. The description of the boot info block of U-boot depends on the CPU type. By using a slightly changed version of the u-boot.h include file this structure is made available to the RTEMS-BSP sources. In order to make a copy of the bootinfo block, there needs to be a specifically defined space for it, which I accomplish with the following two lines:

bd_t M860_binfo;
unsigned long M860_binfo_size = sizeof( bd_t );

The copying is done in the BSP startup code with the following code:

/*
 * Initialization code
 */
.startup:
        /* Get start address */
        mflr    r1

        /* clear the bss section */
        bl      bssclr

/*
 * Copy the Board Info Block
 */
        .extern SYM(M860_binfo)
        .extern SYM(M860_binfo_size)
        lis     r6, SYM(M860_binfo)@ha
        addi    r6, r6, SYM(M860_binfo)@l

        lis     r5, SYM(M860_binfo_size)@ha
        la      r5, SYM(M860_binfo_size)@l(r5)
        lwz     r4, 0(r5)

        rlwinm. r4, r4, 30, 0x3fffffff   /* get number of words */

        mtctr   r4

cpy_b:  lwz     r5, 0(r3)                /* In with the old ...  */
        stw     r5, 0(r6)                /* ... Out with the new */
        addi    r6, r6, 0x4              /* Go to the next word */
        addi    r3, r3, 0x4
        bdnz    cpy_b                    /* decrement counter and loop */

        ...
        ...
        ...

After compiling RTEMS, you will need to transform your ELF executable to a U-Boot image, which is done with the U-Boot mkimage tool. This tool has new options for RTEMS. The easiest way to accomplish this is to add the following code to your application Makefile:

$(PGM): $(OBJS)
        $(make-exe)
        powerpc-rtems-objcopy -O binary $(PGM) ${ARCH}/$(NAME).bin
        gzip -9 ${ARCH}/$(NAME).bin
        $(MKIMAGE)      -A ppc -O rtems -T kernel -C gzip \
                        -a 10000 -e 10000 -n "RTEMS" \
                        -d ${ARCH}/$(NAME).bin.gz ${ARCH}/$(NAME).img

Where $(MKIMAGE) is the location of the mkimage tool, and the other variables are the standard RTEMS ones.

For more information on U-Boot see the references on my U-Boot page, or feel free to ask.

References

RTEMS homepage: http://www.rtems.com/
RTEMS Mailing List: http://www.rtems.com/lists.html




copyright © 2004-2006 Erwin Rol
disclaimer, copyright and contact information