wiki:TBR/UserManual/MinGW_Tools_for_Windows

Version 64 (modified by Sh, on 02/03/09 at 13:34:24) (diff)

/* MSYS - M4 */

MinGW Tools for Windows



<center>RTEMS Tools Installer (Current Release: 4.9 Build 5)</center> <center>Previous and Test Releases</center>



Introduction

Windows users can use MinGW based RTEMS tools. These tools will generate the same application code for RTEMS as the tools on Linux or Cygwin. MinGW tools use the native Windows runtime rather than access Windows via the POSIX interface Cygwin provides. MinGW tools are faster than the Cygwin equivalent and are not confused by Cygwin mount points. Compiler errors will show a Windows path rather than a Cygwin path and so do not confuse native Windows editors.

The RTEMS MinGW Tools are packaged in Windows installers. The latest tools can be accessed using the top level installer. It will install the common files and present you with a selection box for the targets you wish to install. The installer will check to see if you already have the target installer present and if present it will not download it again and will install the one you already have.

Target User

This page targets a single user with a Windows machine who wishes to play with a real-time OS. This user is independent with no corporate support and she wants to build her desired board support package from a RTEMS release TAR-file or CVS. Only default installation paths are used so if the user wishes to access support on MinGW or MSYS mailing lists she has the standard set up and lay out for those forums. If you wish to contain all the RTEMS installed files in a common location you may find the hints in the Advanced Users section useful.

Base Installation

If you want some excellent tools or wish to build RTEMS on Windows the MinGW project provides just what you need. The RTEMS Tools as installed do not need any extra packages, DLLs or installs to work. You could use any available make program or tools to build any RTEMS application. Please note that the MinGW and MSYS installation is only necessary if you want to build RTEMS. If someone else provides you with your desired RTEMS board support package you do not need them. The RTEMS Tools (compiler, assembler, linker etc.) do not depend on them. The only exception is the RTEMS Autoconf and Automake subpackage, but this package is only needed if you want do build RTEMS from the CVS sources.

The MinGW project has four packages we are interested in using. You should install them before you install the RTEMS Tools. The first MinGW package contains a Windows native GCC compiler. The second package is the Minimal SYStem (MSYS), the third is the MSYS Developer Tool Kit (DTK) and the fourth is M4 for MSYS. MSYS is a stand alone package based on the excellent and successful Cygwin package but simplified to providing a self hosted mingw32 target POSIX style environment. It provides a shell with enough functionality to run configure scripts from the Autoconf package. It is simpler to install and setup than the larger more complex Cygwin package.

You can also use an existing MinGW or MSYS installation. In this case you have to take care that a recent M4 is provided, see also MSYS - M4.

Download

Download the following files:

*MinGW *MSYS - Base *MSYS - Developer Tool Kit *MSYS - M4

If there are problems with the above links or to check for other MinGW packages, visit the MinGW Download Site which should refer you to the MinGW Sourceforge Files page.

MinGW

Follow the instructions of the installer to download and install MinGW. All default values from the installer are suitable.

MSYS - Base

Follow the instructions of the installer to install MSYS. All default values from the installer are suitable. Continue with the post install process and enter the MinGW installation location from above. <center>No image "msys-post-install.jpg" attached to TBR/UserManual/MinGW_Tools_for_Windows</center>

If you have Cygwin installed or another package which contains Cygwin you should consider removing any paths to those packages from your global path variable and using batch files to set paths specifically. It can be confusing if you end up mixing MSYS and Cygwin executables in the same environment. The batch file <tt>rtems.bat</tt> shows how you can manage specific paths for MinGW and RTEMS (this file is part of the RTEMS Tools).

To avoid trouble you need to set a home directory for the MSYS shell. The home directory path must not contain any space characters. The default home directory is derived from your login name, so it may contain space characters. Open the file <tt>C:\msys\1.0\etc\profile</tt> with a capable editor. The standard Windows editors Notepad and WordPad? are not suitable. In the next picture the open source editor notepad++ is used to highlight the changes. Set the <tt>HOME</tt> environment variable to the fixed location <tt>/c/home</tt> (or whatever you want). In the Advanced Users section you find more information regarding the home directory. <center>No image "msys-home.jpg" attached to TBR/UserManual/MinGW_Tools_for_Windows</center>

MSYS - Developer Tool Kit

Follow the instructions of the installer to install the MSYS - DTK. For the installation location you should choose the one of your MSYS installation like: <center><tt>C:\msys\1.0</tt></center> For all other settings the default values from the installer are suitable.

MSYS - M4

The Autotools used for RTEMS require a recent version of M4 (>= 1.4.7). As of 2 February 2009, the current MSYS release delivers an outdated version so we have to upgrade it manually. We assume that you have downloaded the M4 package into the directory <tt>C:\download</tt>. Now open a Windows command shell (cmd.exe) and type in the following three commands (the '>' prompt indicates the Windows command shell):

cd C:\msys\1.0 set PATH=C:\msys\1.0\bin;%PATH% tar xjf /c/download/m4-1.4.7-MSYS.tar.bz2

Alternatively you can use a MSYS shell (Start > All Programs > MinGW > MSYS > msys) with the commands below (the '$' prompt indicates the MSYS shell):

$ cd / $ tar xjf /c/download/m4-1.4.7-MSYS.tar.bz2

If you downloaded a GZIP compressed TAR-file you can use

tar xzf /c/download/m4-1.4.7-MSYS.tar.gz

instead of the previous <tt>tar</tt> commands to extract it.

You can also use an archive extractor like IZArc to extract the bzip2 compressed TAR-file into <tt>C:\msys\1.0</tt>.

You can verify the installation of M4 with the following command in a shell:

m4 --version

It should produce the following output:

GNU M4 1.4.7 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Written by Rene' Seindal.

RTEMS Tools Installation

Download

Choose your desired RTEMS Tools release:

*RTEMS 4.10 Tools Installer *RTEMS 4.9 Tools Installer *RTEMS 4.8 Tools Installer

Other releases are available in the RTEMS Tools directory.

Installation

Follow the instructions of the installer to download and install the RTEMS Tools. You may deselect the subpackages that you do not need. For all settings the default values from the installer are suitable. If you have problems with the Autoconf and Automake subpackage installation see above to the MSYS - M4 section. After the installation check the file <tt>C:\msys\1.0\etc\fstab</tt> if it is suitable for you, see also MSYS Shell. In case of trouble you may have a look at the RTEMS Tools Installation Guide.

Update

Remove all currently installed builds of the corresponding RTEMS release with the uninstaller and install the new build afterwards.

RTEMS Build

We will use the RTEMS 4.9.1 release here and assume that all tools from above are installed. If you use a CVS version make sure that the Unix to DOS line endings conversion was switched off during the checkout and do not forget the bootstrap.

The build will be done in a Windows command shell (cmd.exe). Execute the following commands within a Windows command shell to build for example the PSIM board support package (the '>' prompt indicates the Windows command shell):

set PATH=C:\opt\rtems-4.9\bin;C:\MinGW\bin;C:\msys\1.0\bin;%PATH% tar xjf /c/download/rtems-4.9.1.tar.bz2 mkdir rtems-4.9.1-psim cd rtems-4.9.1-psim sh ../rtems-4.9.1/configure --target=powerpc-rtems4.9 --enable-rtemsbsp=psim --enable-cxx --enable-tests=samples make install

Alternatively you can use a MSYS shell (Start > All Programs > MinGW > MSYS > msys). Execute the following commands within a MSYS shell to build for example the PSIM board support package (the '$' prompt indicates the MSYS shell):

$ export PATH="/opt/rtems-4.9/bin:$PATH" $ tar xjf /c/download/rtems-4.9.1.tar.bz2 $ mkdir rtems-4.9.1-psim $ cd rtems-4.9.1-psim $ ../rtems-4.9.1/configure --target=powerpc-rtems4.9 --enable-rtemsbsp=psim --enable-cxx --enable-tests=samples $ make install

It is recommended to use a fresh build directory for each configuration. See also Building RTEMS.

Advanced Users

Installation Root Directory

You can use common root directory for all packages and tools like:

<center><tt>C:\rtems-mingw</tt></center>

This root directory must not contain any space characters in its path. With a common root directory you have everything that is related to RTEMS in one place and the various packages are not scattered over your Windows root device. Ths installation may then look like this:

*<tt>C:\rtems-mingw\MinGW</tt> *<tt>C:\rtems-mingw\MSYS</tt> *<tt>C:\rtems-mingw\opt\rtems-4.9</tt>

Your <tt>C:\rtems-mingw\MSYS\etc\fstab</tt> should contain this:

C:/rtems-mingw/MinGW /mingw C:/rtems-mingw/opt /opt

MSYS Shell

The MSYS shell can run the RTEMS configure script. After the installation you can start the MSYS shell via the start menu (Start > All Programs > MinGW > MSYS > msys) or a Desktop icon. It is just like a Unix shell so you need to know some basic Unix commands to use. You can also run <tt>configure</tt> from a Windows command prompt started with the <tt>rtems.bat</tt> file by placing <tt>sh</tt> before the <tt>configure</tt> command.

The MSYS shell provides a Unix like view to the Windows filesystem. The MSYS shell root directory <tt>/</tt> is mapped to the MSYS installation location <tt>C:\msys\1.0</tt>. Windows device characters are mapped from <tt>/c/directory/file.txt</tt> to <tt>C:\directory\file.txt</tt>. You can add mount points via the <tt>mount</tt> command or the <tt>C:\msys\1.0\etc\fstab</tt> file. The <tt>fstab</tt> file should contain this:

C:/MinGW /mingw C:/opt /opt

It is advised to set up a home directory that the MSYS shell can use. If you do nothing the MSYS shell will use a default one for your login name. The home directory should not contain any space characters in its path. You can use a global <tt>HOME</tt> environment variable or edit the MSYS profile.

To edit the MSYS profile open the file <tt>C:\msys\1.0\etc\profile</tt> with a capable editor and set the <tt>HOME</tt> variable to the fixed location <tt>/c/home</tt> (or whatever you want).

Advanced users in a Windows networked environment where home directories are resident on the network can use the user's global <tt>HOME</tt> environment variable. Make sure that this does not interfere with other programs like Cygwin. For Windows 2000 and Windows XP open the System icon on the Control Panel, select the Advanced tab then the Environment Variables button. Add a New environment variable for your login called <tt>HOME</tt> and point it to the home directory you wish to use. If you use this method to set a home directory you do not need to change MSYS's profile.

Miscellaneous

Trouble Shooting

Space characters in the install paths or the home directory may cause problems. You should avoid them.

Do not use the Unix to DOS line ending conversion for CVS checkouts.

If you have trouble with MSYS when building RTEMS check what virus or spyware detection software you have. The PC Tools Spyware Doctor has been giving someone problems. The machine loses all resources. Turing off Spyware Doctor does not help, it had to be uninstalled.

If you experience, that the shell crashes sometimes, resulting in a stack dump, you might want to check whether you have a Logitech webcam (or similar) installed on your system. Killing the process <tt>lvprcsrv.exe</tt> in the Windows Task Manager might help in these situations.

If you encounter an error like this

Couldn't reserve space for cygwin's heap, Win32 error 6

try to use a 1.0.11 version of the MSYS DLL and base files.

An outdated version of M4 causes a problem during the RTEMS Autotools installation. You notices this if a window like this pops up: <center>No image "msys-m4.jpg" attached to TBR/UserManual/MinGW_Tools_for_Windows</center> Pressing any key will continue but the installation of the Autotools will not be correct. You should exit the installer and install the required M4 program, see also MSYS - M4.

Compiling in Emacs

You can use Emacs on Windows to compile RTEMS or your application and use it to track the error messages. To compile enter <tt>M-x compile</tt> then type

C:/rtems-mingw/opt/rtems-4.9/sh-run.bat make -C C:/rtems-mingw/home/build-rtems-4.9.1

Terminal Software

If you are using RTEMS with these tools on Windows you may find the RealTerm program useful when connecting to the console of your target.

=RTEMS Tools License and Sources =

The source code for the tools is licensed under the GNU GPL and can be found in a source directory under each of the installer builds. The installers and tools are built and packaged on a current Linux Fedora computer and the scripts are all provided in the RTEMS source code. Instructions on using the scripts can be found in Building MinGW Tools?.