23/06/2010

RTEMS HelloWorld Tutorial

Let's go embedded.

RTEMS is a real-time executive which provides a high performance environment for embedded applications on a range processors and embedded hardware. In this tutorial you will learn howto:
  • install RTEMS and build RTEMS tools
  • run RTESM applications on TSIM simulator 
We leave the topic of compiling RTEMS applications for a separe howto article.  Check the blog for updates.
    Note: This tutorial is focused on the following platforms : SPARC LEON3 and ERC32/SIS.

    1) Prerequisities
    First, you will need a linux distribution supporting RTEMS. Try Fedora 11 or higher or SUSE 11 or higher.
    This tutorial is using the RTEMS version 4.9. RTEMS 4.10 is not officially distributed, but the instructions here in general should be valid once this new distribution is released.
       
    2) RTEMS OS installation
    As part of the installation, we need to install the RTEMS prebuilt tools first.
                rtems-4.9-autoconf-2.62-4.suse11.2.noarch.rpm      
                rtems-4.9-automake-1.10.3-1.suse11.2.noarch.rpm    
                rtems-4.9-binutils-common-2.19-3.suse11.2.i586.rpm 
                rtems-4.9-gcc-common-4.3.2-24.suse11.2.i586.rpm    
                rtems-4.9-gdb-common-6.8-11.suse11.2.noarch.rpm
                rtems-4.9-newlib-common-1.16.0-24.suse11.2.i586.rpm
                rtems-4.9-sparc-rtems4.9-binutils-2.19-3.suse11.2.i586.rpm
                rtems-4.9-sparc-rtems4.9-gcc-4.3.2-24.suse11.2.i586.rpm
                rtems-4.9-sparc-rtems4.9-gcc-c++-4.3.2-24.suse11.2.i586.rpm
                rtems-4.9-sparc-rtems4.9-gdb-6.8-11.suse11.2.i586.rpm
                rtems-4.9-sparc-rtems4.9-newlib-1.16.0-24.suse11.2.i586.rpm
    Install (SUSE):
    $ rpm -Uvh <package name>.rpm

    Install (Fedora):
    $ yum install "installation_package_name"

    Notes:
    • All the packages will be installed in /opt/rtems-4.9/ by default.
    • During installation you can get some warnings about keys. Don't worry about them.
    • During installation you can get some dependency errors. Find the required packages from suse repositories and install them.
    3. Build RTEMS  
    In this step we will build RTEMS for two different configurations - LEON3 and ERC32/SIS.

    3.1 Build RTEMS with LEON3 support 
    1. Become root
    2. Browse http://www.rtems.org/ftp/pub/rtems/4.9.3/
    3. Download rtems-4.9.3.tar.bz2. Extract archive in the /opt/ directory. This will create /opt/rtems-4.9.3/
    4. Execute the following:
    $ cd /opt/rtems-4.9/
    $ export PATH=/opt/rtems-4.9/bin:$PATH
    $ ./bootstrap
    $ mkdir leon3
    $ cd leon3
    $ ../../rtems-4.9.3/configure --target=sparc-rtems4.9 
             --enable-rtemsbsp=leon3 --enable-posix
    $ make
    $ make install        
           
    3.2 Build RTEMS with ERC32/SIS support (optional)
    The same approach as above, only the configuration during the building is different:
    $ cd /opt/rtems-4.9/
    $ export PATH=/opt/rtems-4.9/bin:$PATH
    $ ./bootstrap
    $ mkdir bsis
    $ cd bsis
    $ ../../rtems-4.9.3/configure --target=sparc-rtems4.9 
    --enable-rtemsbsp=sis --enable-posix
    $ make
    $ make install    
    
        
    3.3 TSIM simulator
    Go to TSIM distribution at Gaisler Inc.
     - install the TSIM simulator, eg. in /opt/tsim 
    - the simulator will allow you to execute RTEMS binnaries on your x86

    4. RTEMS Helloworld with TSIM:
    First, you need to compile RTEMS C application. We will however not address this step here, we will dedicate a separate tutorial for this step. But, in order to verify that your installation is correct, RTEMS distribution contains many pre-compiled examples that you can use to run out of the box.
    You can also download it here: RTEMS HelloWorld binnary (compiled for SPARC LEON3).

    And then load the binnary file into the TSIM simulator and run it:
    $ /opt/tsim/linux/tsim-eval
    tsim> load hello
    tsim> go
    resuming at 0x40000000
    Hello World!
    
    Program exited normally.
    tsim> quit
    

    5. RTEMS installation - Building a toolchain and target C library  (optional)
    First, fetch gcc-core and gcc-c++ 4.3.2, binutils 2.19, newlib 1.16.0, and related patches from http://www.rtems.org/ftp/pub/rtems/SOURCES/4.9/. You need only the newest patch (the filenames include the date) for each component. Extract and patch each component from the same directory (we'll call it $TOP), so that you have $TOP/gcc-4.3.2/, $TOP/binutils-2.19/, and $TOP/newlib-1.16.0/.

    Link $TOP/newlib-1.16.0/newlib to $TOP/gcc-4.3.2/newlib:
    ln -s $TOP/newlib-1.16.0/newlib $TOP/gcc-4.3.2
    Create a build directory for each of binutils and gcc, indicating the architecture; something like binutils-2.19-$ARCH, where $ARCH is i386, sparc, etc.

    Pick an install directory; we will call it $PREFIX -- I use /opt/rtems-4.9.
    Configure and build binutils:
    cd $TOP/binutils-2.19-$ARCH
    ../binutils-2.19/configure --target=$ARCH-rtems4.9 
    --prefix=$PREFIX --disable-werror
    make
    make install

    Configure and build gcc; this may require some platform-specific arguments:
    cd $TOP/gcc-4

    6. Other Tips (optional)

    RTEMS on x86:
    If you wish to boot RTEMS using grub (as for qemu), provide --enable-rtems-grub. This forces the binary to load up above the 1MB mark.

    FPU support:
    In case your RTEMS configuration is not FPU-friendly, when building your tools, provide --with-float=soft to the gcc configuration.

    References:
    1) Another RTEMS installation tutorial
    2) RTEMS: http://www.rtems.com/

    Acknowledgment: Thanks to Petr Maj and Ethan Blanton for help with this tutorial! 

    14/06/2010

    Static Checker for SCJ released!

    We have released a new version of our Static Checker for SCJ. The checker is based on the Checker framework that will be shipped with Java 7 and is able to statically verify various SCJ properties.

     Here you can see an example SCJ code and possible errors that the checker will identify:

                                                                      (click to enlarge)

    We now support all the SCJ annotations:
    • @SCJAllowed
    • @SCJRestricted
    • @DefineScope
    • @Scope
    • @RunsIn
    A typical example of a checker output can be seen here:
                          (click to enlarge)

    You can find more information about the Checker at oSCJ Home Page.

    The checker is open-source and can be downloaded from here.

    01/06/2010

    Comparator: An AST Parser for SCJ

    Keeping specification and its corresponding implementation in sync is often a huge hasle.

    In our case, the situation is even more complex since we have several different implementations of the same Specification. Moreover, the Spec. itself is being constantly updated.

    Therefore, we introduce Comparator -- our new tool that is able to automatically determine all the differences between a specification class and its corresponding implementation.

    Comparator creates AST trees both from the spec and from the implementation and compares them, simple yet powerful.


    You can see a typical report log produced by the Comparator :



    Comparator will be shipped with the updated version of SCJ TCK soon, stay tuned.

    JTRES Workshop

    As every year, JTRES'10 : International Workshop on Java Technologies for Real-time and Embedded Systems is coming.

    This year in Prague, Czech Republic, August 19-21.
    Research Paper Deadline : June 7th (firm).

    For more info, see: