VxWorks Under Linux
Here are step-by-step instructions to build a linux gcc cross compiler
for m68k (Motorola 680x0) targets running vxWorks. The instructions specifically
apply to the following system:
-
original host: sunOS 5.6 or Solaris 2.6
-
new host: linux redhat 6.2
-
target chipset: motorola 68040
-
target OS: vxWorks 5.3.1
-
gcc:
2.95.3
-
binutils: 2.9.1
If one or more of the above are different in your system (especially the
target OS), these instructions should still be useful in showing the main
steps to building a cross compiler, but you probably have to improvise
when it comes to details.
There are some additional shell scripts, source files, and binaries
mentioned in the instructions below. You may find all of them in
http://cahrd.tuc.noao.edu/mpg/vxworks/linuxHostingVx.tgz
I will refer to this location as UtilDir.
To simplify the instructions, I assume that the entire vxWorks 5.3.1
distribution resides in directory Tornado somewhere on the original
host. I also install things in specific directories; feel free to rearrange
things when you build your own system. Here we go:
-
copy the entire vxWorks distribution from the original host to /Tornado
on the linux host
-
create a linux directory in /Tornado/<HOST>, where
<HOST>
is where the other host directories are; e.g.,
mkdir /Tornado/host/linux
-
install binutils
-
cd /
-
tar xzf binutils-2.9.1.tgz
-
cd binutils-2.9.1
-
mkdir vx68k
note: we build things in vx68k for convenience; e.g., if anything
goes wrong we just zap the contents of vx68k and start over; or we can
create another directory for a different type of target chipset.
-
cd vx68k
-
../configure --target=m68k-wrs-vxworks --prefix=/Tornado/host/linux
--exec-prefix=/Tornado/host/linux > zap.log
note: piping stdout to a log file allows you to see the stderr of
configure,
which otherwise may go unnoticed.
-
make
-
make install
-
install gcc
-
cd /
-
tar xzf gcc-2.95.3.tgz
-
cd gcc-2.95.3
-
mkdir vx68k
-
cd vx68k
-
../configure --target=m68k-wrs-vxworks --prefix=/Tornado/host/linux
--exec-prefix=/Tornado/host/linux \
--with-headers=/Tornado/target/h --with-libs=/Tornado/target/lib > zap.log
note: the /Tornado/target/h and /Tornado/target/lib
are where all the target-specific headers and libraries are located, respectively.
-
in /Tornado/host/linux/m68k-wrs-vxworks/sys-include/sys/stat.h,
somewhere on top, before the first occurrence of ULONG, add:
#include "../types/vxTypesOld.h"
I had to do this to get gcc to compile; it still baffles me though,
because under Solaris ULONG somehow is in scope without the #include!
By the way, this is more than likely a 5.3.1-specific detail.
-
make LANGUAGES=c
-
make LANGUAGES=c install
some other languages may be problematic (e.g., the link below reports
a problem with Objective C).
-
in /Tornado/host/linux/bin, for all the executables create soft
links like this:
ln -s m68k-wrs-vxworks-gcc cc68k
for 5.3.1 you can use the softlinker script in UtilDir.
-
throw in some additional utilities from here and there
-
grab xsym.c from UtilDir, and:
-
gcc -o xsym xsym.c
-
cp xsym /Tornado/host/linux/bin
-
find the vxsize shell script in your vxWorks distribution (e.g.,
/Tornado/host/sun4-solaris2/bin/vxsize)
and copy it to /Tornado/host/linux/bin
(for 5.3.1 you will also
find it in DirUtil).
-
grab munch from UtilDir and copy it /Tornado/host/linux/bin
-
note: this part could be the messiest part, especially if the tools
are binaries and you have to somehow put together the proper source code;
also, the tools missing could vary from one version of vxWorks to another.
Always check and see if the tool is a shell script, in which case you just
copy it over. If it's a binary, search the entire vxWorks distribution
tree; chances are you'll find the source code right there. If that
fails, you have to search the web and enter the underworld of newsgroups
:-) For this project I was lucky to find Trebisky's webpage (see acknowledgment
below).
-
set the vxWorks environment variables. e.g., for 5.3.1:
-
export WIND_BASE=/Tornado
-
export WIND_HOST_TYPE=linux
-
export GCC_EXEC_PREFIX=/Tornado/host/linux/lib/gcc-lib/
-
create proper linux files in the make directory of the target. e.g., for
5.3.1:
-
cd /Tornado/target/h/make
-
cp defs.sun4-solaris2 defs.linux
-
cp rules-lib.sun4-sunos4 rules-lib.linux
note: luckily here we didn't have to modify the files; but in other
cases there may be some host-specific issues that require modifying these
files.
We are done! Now the best way to test things is to make a clean build of
the kernel.
Acknowledgment
I was lucky to come across this document by
T. Trebisky. The munch binary used here is from his archive, and
so is the xsym.c, which I had to modify slightly to get it to
compile. You will find his archive (trebisky.tgz) in UtilDir.
Last update: 18 June 2001
http://chard.tuc.noao.edu/mpg/vxworks/linuxHostingVx.html
behzad@noao.edu