wiki:TBR/UserManual/MinGW_Tools_for_Windows

Version 59 (modified by ChrisJohns, on Jan 15, 2009 at 2:53:23 AM) (diff)

MinGW Tools for Windows

{| border="0" cellpadding="5" cellspacing="0" align="right"

! style="background:#efefef;" | |}

Windows users can now use MinGW base 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.




<center>Current Release&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RTEMS Tool Installer (rtems4.9-tools-5.exe)

Previous versions of the tool installers are located at http://www.rtems.org/ftp/pub/rtems/windows/.</center>




It is recommended you install MinGW, MSYS and MSYS DTK before you install the RTEMS Tools. The autotools installer builds autoconf and automake before installing them on your computer. There is no safe way to build autoconf using a cross-build on a Linux host. To build the autotools packages on Windows MSYS and MSYS DTK are required. The autotools installer checks for them and aborts installation if they do not exist. Read the section Setting Up MinGW for details.


Before you use these tools install MinGW and MSYS as described above plus also install an newer GNU M4 tools (http://downloads.sourceforge.net/mingw/m4-1.4.7-MSYS.tar.bz2). In the MSYS shell enter:

cd / tar -xvjf /c/my-download/m4-1.4.7-MSYS.tar.bz2

where the file has been downloaded to {{{c:\my-download</code>. If you do not have the correct M4 installed the building of autoconf will fail. You can observe this in the Windows CMD shell window when it says:

<blockquote><blockquote><blockquote>{{{

DO NOT CLOSE DO NOT CLOSE

Warning: this command window will automatically close.

Build output: C:/opt/rtems-4.9/Packages/Source/at-log.txt

configure: error: no acceptable m4 could be found in $PATH. GNU M4 1.4.5 or later is required; 1.4.11 is recommended error: configuring autoconf-2.62 ERROR: code '222'. Press Any Key to continue

}}}</blockquote></blockquote></blockquote>

Pressing any key will continue how-ever the autoconf and/or automake will not be correct. You should exit the installer and install the required M4 program.


For a detailed walk through of the installer take a look at Installing MinGW RTEMS Tools?.

The source code for the tools is under the GNU GPL and can be found here http://www.rtems.org/ftp/pub/rtems/windows/4.9/build-4/source. The installers and tools are built and packaged on a Linux Fedora (FC9) computer and the scripts are all provided in the RTEMS source code. Instructions on using the scripts can be found in Building MinGW Tools?.

The RTEMS Tools are all installed into the default path of <tt>c:\opt\rtems-4.9</tt>. The version number changes with each release. To test the tools run the <tt>rtems.bat</tt> file. This will open a Windows Command prompt (cmd) with a valid path to the installed tools. You can find the <tt>rtems.bat</tt> under the install point or in the RTEMS 4.9 menu under the Start Menu. Enter the GCC command for your tool set. For example the RTEMS 4.9 ARM GCC command is:

RTEMS C:\opt\rtems-4.9> arm-rtems4.9-gcc arm-rtems4.9-gcc: no input files

A few batch files and a script file are installed into the install point. The first is called <tt>rtems-env.bat</tt>. It sets up the path and environment variables you need to run the RTEMS tools. The second is <tt>rtems.bat</tt>. It will open a Windows command box with the RTEMS tools path and environment set. The last is <tt>sh-run.bat</tt>. You can call this batch file from your editor when you want to compile within the editor. You need to install the MinGW and MSYS packages to use this batch file. For example:

c:\rtems\arm\sh-run.bat ./vs-make.sh /c/opt/src/rtems/app all

can be used with Visual Studio and an external make project to compile an application in <tt>c:\opt\src\rtems\app</tt>. The script <tt>vs-make.sh</tt> will change directory and invoke GNU make converting the GCC error messages to the MS format that Visual Studio understands.

RTEMS 4.10 Tools

Tools for the RTEMS 4.10 release are available at http://www.rtems.org/ftp/pub/rtems/windows/4.10/build-1/.

Please try these tools and report any issues to the Users mailing list quoting the build number.

Setting Up MinGW

The 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. If you want some excellent tools or wish to build RTEMS on Windows the MinGW project provides just what you need. You can find the MinGW project at http://www.mingw.org/.

The MinGW project has 3 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, and GNU make (called mingw32-make). The second package is MSYS for Minimal SYStem (MSYS), and the third is the Minimal SYStem Developers Tool Kit (MSYS DTK). 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</code> scripts from the autoconf package. It is simpler to install and setup than the larger more complex Cygwin package.

<blockquote> MinGW Tools<br /> MSYS Installer<br /> MinGW MSYS Developers Tool Kit </blockquote>

Click on the above and install each package. The default settings for these package should be ok for most users. 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.

<blockquote> WARNING: If you uninstall the MinGW package it currently deletes everything under the install directory. It is recommended you use the standard install point and do not place any files you need to keep under that directory. </blockquote>

It is advised to set up a home directory that MSYS can use and if you do not the MSYS shell will use a default one for your login name. If you create a home directory MSYS will use it. To create a home directory simply create a HOME environment variable. 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 HOME and point it to the home directory you wish to use. It could point to a network drive that is a real Unix home directory, your Windows home directory under Documents and Settings that becomes part of a roaming profile, or just a directory local to the disk.

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 installed batch file <tt>rtems.bat</tt> shows how you can manage specific paths for MinGW and RTEMS.

The MSYS shell can run the RTEMS {{{configure</code> script. You can use the MSYS shell which you can find as a menu or Desktop icon. This is just like a Unix shell so you need to know some basic Unix commands to use. You can also run {{{configure</code> from a Windows command prompt started with the <tt>rtems.bat</tt> file by placing sh before the {{{configure</code> command.

If you wish to modify RTEMS and/or need to run autoconf, automake or any of the autotools you will need to install the MinGW MSYS Developers Tool kit.

The RTEMS installer checks to see if the MSYS <tt>/etc/fstab</tt> is present and appends the install path the tools are built with as a mount to the install point you set in the installer. The <tt>/etc/fstab</tt> will have the following entry (rtems4.9) for the default install point:

C:/opt/rtems-4.9 /opt/rtems-4.9

The install tries hard to locate MSYS. If it does not find it please let us know.

Building RTEMS

If you do the following stage from an MSYS terminal you will need to update the path to refer to the correct versions of the tools

export PATH=/c/opt/rtems-4.9/bin:${PATH}

To build RTEMS with the source code in a directory 'c:\rtems\src\rtems-4.9.0' you would do the following:

c: cd \opt\src\rtems tar jxf c:\downloads\rtems\rtems-4.9.0.tar.bz2 cd rtems-4.9.0 sh ./bootstrap cd .. mkdir m68k cd m68k sh ../rtems-4.9.0/configure --target=m68k-rtems4.9 --enable-multilib --prefix=/c/opt/src/rtems/m68k sh make all install

<blockquote> <i>Note</i> The current RTEMS releases need to be bootstrapped on Windows to work around an autoconf bug. This bug will be fixed in the next version of autoconf but until then a bootstrap is needed. </blockquote>

If you have checked RTEMS out from CVS you will first need to bootstrap. If you have used Windows to check out from CVS with tools such as TortoiseCVS the files will have DOS line endings. This causes problems with autoconf and automake and some files need to be stripped. The RTEMS bootstrap script may be modified to handle this but until then you will need to bootstrap with the following:

cd rtems-4.9 sh find . \( -name \*.ac -o -name \*.m4 -o -name \*.am -o -name \*.in \) -exec dos2unix '{}' \; sh ./bootstrap

If you are using the MSYS shell you need to first set the path to correctly point to the installed tools. The example above is using the pre-configured Windows command shell (<tt>cmd.exe</tt>) and this has the path set. For MSYS:

$ export PATH=/c/opt/rtems-4.9/bin:$PATH $ mkdir -p /c/opt/src/rtems $ cd /c/opt/src/rtems $ tar jxf /c/downloads\rtems\rtems-4.9.0.tar.bz2 $ cd rtems-4.9.0 $ ./bootstrap $ cd .. $ mkdir i386 $ cd i386 $ ../rtems-4.9.0/configure --target=m68k-rtems4.9 --enable-multilib --prefix=/c/opt/src/rtems/i386 $ make all install

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 'M-x compile' then type

c:/opt/rtems-4.9/sh-run.bat make -C c:/opt/rtems-4.9/src/rtems-4.9

Trouble Shooting

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 me 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 stackdump, you might want to check whether you have a logitech webcam (or similar) installed on your system. Killing the process "lvprcsrv.exe" in the Windows Task Manager might help in these situations.

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. RealTerm? can be download from http://realterm.sourceforge.net/.