Building RTEMS-4.10 Tools for Lattice Mico32 (lm32)

To build the tools you will need the sources for the Lattice Mico32 GNU Tools which you can download from the Lattice site.

You will also need the sources for newlib-1.16.0.cvs.20081127 from the RTEMS ftp server and RTEMS specific patches for newlib.

In addition to these sources you will need the following patches:

binutils-2.18-rtems4.10-lm32-20081117.diff
gcc-3.4.4-rtems4.10-lm32-20081209.diff
newlib-1.16.0.cvs.lm32-20081127.diff

The tools can be built for example on Fedora 9, however, the versions automake and autoconf required by rtems-4.10 are not provided here so these have to be installed separately (see RTEMS Wiki for detailed instructions how to load Yum repository configuration information).

yum -y install "*4.10*auto*"

Download the sources and patches listed above and build and install the tools following.

mkdir build-lm32-tools
cd build-lm32-tools/
tar zxf ../tool-sources/mico32_gnutools_src_7.1.tar.gz

Apply patch for binutils

cd src/binutils
patch -p1 < ../../../tool-sources/binutils-2.18-rtems4.10-lm32-20081117.diff
cd ../..

Build and install binutils

mkdir b-binutils
cd b-binutils
../src/binutils/configure --prefix=/opt/rtems-4.10 --target=lm32-rtems4.10 \
--disable-nls
make -w all
make install (as root)
cd ..

Untar and patch newlib-1.16.0.cvs

tar zxf ../tool-sources/newlib-1.16.0.cvs.20081127.tar.gz
cd newlib-1.16.0
patch -p1 < ../../tool-sources/newlib-1.16.0.cvs.lm32.20081127.diff
patch -p1 < ../../tool-sources/newlib-1.16.0.cvs.20081128-rtems4.10-20081128.diff
cd newlib/libc/machine/lm32/
aclocal -I ../../..
autoconf
automake -a --cygnus Makefile
cd ../../../../..

We need to replace the version of newlib supplied with the Lattice sources with a more recent one and patch the gcc sources.

cd src
rm -rf newlib
cd gcc
ln -s ../../newlib-1.16.0/newlib newlib
patch -p1 < ../../../tool-sources/gcc-3.4.4-rtems4.10-lm32-20081209.diff
cd ../..

Now build and install gcc and newlib

PATH=/opt/rtems-4.10/bin:${PATH}
mkdir b-gcc
cd b-gcc
../src/gcc/configure --prefix=/opt/rtems-4.10 --bindir=/opt/rtems-4.10/bin \
--exec_prefix=/opt/rtems-4.10 --includedir=/opt/rtems-4.10/include \
--libdir=/opt/rtems-4.10/lib --libexecdir=/opt/rtems-4.10/libexec \
--mandir=/opt/rtems-4.10/man --infodir=/opt/rtems-4.10/info \
--datadir=/opt/rtems-4.10/share --target=lm32-rtems4.10 \
--enable-languages=c,c++ --with-newlib --enable-sjlj-exceptions \
--disable-nls --disable-libstdcxx-patch --with-gnu-as --with-gnu-ld \
--verbose --with-system-zlib --enable-version-specific-runtime-libs \
--enable-threads=rtems
make -w all
make install (as root)

Building RTEMS for Lattice Mico32 target

Short instructions to build the RTEMS operating system for the Lattice Mico32 target are shown here. Please refer to Building RTEMS-4.10 Tools for Lattice Mico32 (lm32) for instruction to setup cross-compiler tools required for building RTEMS.

Get RTEMS sources from the CVS Repository, see instructions in RTEMS Wiki.

Run bootstrap:

cd rtems 
./bootstrap
cd ..

Create building directory and build RTEMS for Lattice Mico32:

mkdir b-rtems
cd b-rtems
../rtems/configure --target=lm32-rtems4.10 --prefix=/opt/rtems-4.10 \
--enable-doc --enable-cxx --enable-rdbg --enable-tests --enable-posix \
--enable-networking
make RTEMS_BSP=lm32_evr all
make install (as root if you want to install it in /opt/rtems-4.10)

This will build (and optionally install) RTEMS itself and samples and test application. For further information please see instructions to load and run an application on the target.

Loading and Running RTEMS on Lattice Mico32

The following instructions assume you have Lattice ispLEVER tools and Lattice Mico32 tools installed on a Windows PC and you have your target connected to the PC using the Lattice JTAG cable.

  1. Configure your target board FPGA using ispVM.
  2. Start two instances of LatticeMico32 System SDK Shell
  3. In first instance of LatticeMico32 System SDK Shell enter command TCP2JTAGVC2
  4. In second instance change directory to b-rtems/lm32-rtems4.10/c/lm32_evr/testsuites/samples/hello and run lm32-elf-gdb and run commands:
file hello.exe  
target remote localhost:1000
load
c

Now there should be output on the console:

*** HELLO WORLD TEST ***
Hello World
*** END OF HELLO WORLD TEST ***