Friday, April 5, 2013

Setting up an RTEMS Development Environment for Windows

Setting up an RTEMS Development Environment for Windows


Update

I have updated the windows setup with a set of newly built mingw32 toolchains for RTEMS. Now the arm-rtems tools match the ones I build with the RTEMS source builder tool. In fact, these mingw tools are compiled using the RTEMS source builder on FreeBSD. I’m pretty sure this would work on linux as well.


Introduction

In a previous entry, I described how to set up an RTEMS development environment for the Raspberry Pi on an Ubuntu 12.10 system. This entry will describe how to setup a similar environment on Windows 7 and/or Windows 8.

To have a working RTEMS development environment on Windows, you need a few development packages:

Windows Tools Needed

  • A MinGW native GCC compiler for windows

  • A collection of GNU build utilities known as MSYS

  • One or more RTEMS MinGW cross compilers

Let’s look at each one of these:


1. MinGW

The MinGW project that provides the native x86 gcc compiler seems to be going through a transition. There are a few different MinGW projects:

MinGW Projects

  • The original 32 bit MinGW

  • The newer unrelated 64 bit Mingw-w64

  • Other builds of the MinGW system such as: TDM-Dragon MinGW

I use the TDM-Dragon MinGW installation.


2. MSYS

To build RTEMS, you also need some Unix run-time tools to properly configure RTEMS with the automake/autoconf tools. These run-time tools are provided by a set of ports called MSYS. I use a package of these tools that include the automake/autoconf tools, git, make, a nice unix shell, etc.


3. RTEMS MinGW cross compiler

The RTEMS project provides MinGW RTEMS cross compilers for all of the architectures, including ARM. MinGW is a port of the GNU compiler to the native Win32 environment. You also need the RTEMS cross compiler for either Mingw or Cygwin. These are provided by the RTEMS project.


My Windows 7 RTEMS compiler setup

Here is exactly what I used to setup my Raspberry Pi RTEMS environment for Windows 7 64 bit:

  1. The TDM-Dragon MinGW compiler

  2. A pre-built Msys collection. This is a nice package because it includes git, which will be needed to check out RTEMS.

  3. The RTEMS mingw arm-rtem4.11 compiler from the RTEMS project

Here is where I put everything:

Table 1. Directory Structure
Path Description

C:\opt

The base directory for all Tools

C:\opt\mingw

Install directory for TDM-GCC Mingw

C:\opt\msys

Install directory for the msys bundle

C:\opt\rtems-4.11

Install directory for the RTEMS compiler tools


Installation

Do the following steps:

  • Install TDM-MinGW in C:\opt\mingw

  • Set the Windows system Path to include C:\opt\mingw\bin

  • Unpacked the msys bundle into C:\opt\msys

  • Set the Windows system Path to include C:\opt\msys\bin

  • Edit the file c:\opt\msys\etc\fstab to include the following lines:

   c:/opt/mingw     /mingw
   c:/opt           /opt
Tip The fstab setup will make sure when you unpack the RTEMS tools, they will go in the right place.

Download the arm-rtems4.11 tools from the RTEMS project here: http://www.rtems.org/ftp/pub/rtems/people/chrisj/source-builder/4.11/mingw32/

I downloaded:

 rtems-4.11-arm-rtems4.11-1.tar.bz2
Note These compilers are all updated often, and will change! You may need to re-download and unzip the compiler when it is updated.
Tip I recommend putting the files you download in C:\opt so they can be uncompressed in the correct directory.

Unpack all of the files you downloaded To do this, open a command prompt, and run the bash shell:

sh

Your command prompt should change to this:

$

Change to the "opt" directory and unpack:

$ cd /c/opt
$ tar -xf rtems-4.11-arm-rtems4.11-1.tar.bz2

When you are done, you should see all of the tools in C:/opt/rtems-4.11/bin

Set the Windows system path to include:

C:\opt\rtems-4.11\bin

So at this point your path should include:

c:\opt\mingw\bin;c:\opt\msys\bin;c:\opt\rtems-4.11\bin
Tip I recommend putting these path entries at the start of the PATH environment variable, because msys "find" command is needed by the configure script. If these paths are at the end of the environment variable string, the windows "find" program will be used instead and the RTEMS configure tools will not work.

If you have everything set up correctly, you should be able to open a command prompt and type:

$ arm-rtems4.11-gcc -v

You should see the compiler version message. The compiler is installed and ready to use! If you are using the unix sh, then the commands will work the same way they do in linux. In fact, there is a nice program called "mintty" that provides a resizeable unix shell window. I have been able to use this mintty, the old DOS style command prompt and the Windows PowerShell to build code.

Next: Download and build RTEMS