1. Host machine
Install OpenSolaris 2008.11 or 2009.06 on x86 platform. The following packages are required.
- ss-dev (Sun Studio Development cluster)
- gcc-dev (GNU Tools Development cluster)
- SUNWperl-xml-parser
Boot OpenSolaris and install above additional packages with packagemanager or pkg command.
$ pfexec pkg install ss-dev gcc-dev SUNWperl-xml-parser
2. Required tools
The following tools are necessary to build and run Solaris for ARM.
- GNU binutils
- newlib 1.17.0
- GCC, the GNU Compiler Collection
- QEMU
3. Setup source tree
$TESTWS is your workspace. $DOWNLOAD is your directory in which downloaded files are stored.
Pull the source of Solaris for arm from the osarm mercurial repository.
$ cd $TESTWS $ hg clone ssh://anon@hg.opensolaris.org/hg/osarm/onarm-gate
Download and unpack the closed binary of Solaris for arm.
$ cd $TESTWS $ cd onarm-gate $ gtar xjvf $DOWNLOAD/on-arm-closed-bins-20090512.tar.bz2
4. Building Cross Development toolchain
Create the directory to install toolchain. The toolchain is supposed to be installed in /opt/arm-eabi directory.
$ pfexec mkdir /opt/arm-eabi
4.1 Sun Cross ld
Build source code.
$ cd $TESTWS/onarm-gate $ ./initenv.sh $ ./usr/src/tools/scripts/bldenv.sh -d opensolaris-arm.sh $ cd ./usr/src $ dmake setup $ cd cmd/sgs $ dmake cross $ exit
Install binary into /opt/arm-eabi/ccs.
$ cd $TESTWS/onarm-gate/usr/src/cmd/sgs/proto/cross/arm $ pfexec mkdir -p /opt/arm-eabi/ccs $ gtar cvf - . | (cd /opt/arm-eabi/ccs; pfexec gtar xvf -)
4.2 GNU binutils
Download the binutils 1.18 and patch for Solaris, unpack the source and install patch.
$ cd $TESTWS $ gtar xjvf $DOWNLOAD/binutils-2.18.tar.bz2 $ cd binutils-2.18 $ bzcat $DOWNLOAD/binutils-2.18-arm-solaris.patch.bz2 | gpatch -p0
Build source code and install binary into /opt/arm-eabi
$ cd $TESTWS/binutils-2.18
$ mkdir objs
$ cd objs
$ $TESTWS/binutils-2.18/configure ~--prefix=/opt/arm-eabi
~--target=arm-pc-solaris2.11
~--with-sysroot=/opt/arm-eabi/root
$ gmake
$ pfexec gmake install
4.3 GNU gcc
Download the gcc 4.1.1 and unpack the sources.
$ cd $TESTWS $ gtar xjvf $DOWNLOAD/gcc-4.1.1.tar.bz2 $ export PATH=$PATH:/opt/arm-eabi/bin
Download the patch for Solaris and install it.
$ cd $TESTWS/gcc-4.1.1 $ bzcat $DOWNLOAD/gcc-4.1.1-arm-solaris.patch.bz2 | gpatch -p0
4.3.1 GNU base gcc
The crt*.o, libc and libm for Solaris are required to become Solaris aware gcc. To build crt*.o and library, the base gcc is built with newlib first.
Download the newlib 1.17.0, unpack the sources and make a symbolic link in gcc directory.
$ cd $TESTWS $ gtar xzvf $DOWNLOAD/newlib-1.17.0.tar.gz $ cd gcc-4.1.1 $ ln -s ./../newlib-1.17.0/newlib
Build source code with newlib and install binary into /opt/arm-eabi.
$ cd $TESTWS/gcc-4.1.1
$ mkdir objs
$ cd objs
$ $TESTWS/gcc-4.1.1/configure ~--prefix=/opt/arm-eabi
~--target=arm-pc-solaris2.11
~--with-as=/opt/arm-eabi/arm-pc-solaris2.11/bin/as ~--with-gnu-as
~--with-ld=/opt/arm-eabi/ccs/bin/ld
~--with-ar=/opt/arm-eabi/arm-pc-solaris2.11/bin/ar ~--with-gnu-ar
~--enable-languages=c
~--with-cpu=mpcore ~--disable-multilib
~--disable-shared ~--disable-threads
~--disable-libssp ~--disable-libada
~--with-newlib
$ gmake
$ pfexec gmake install
4.3.2 Solaris libc and libm
Build Solaris crt*.o, libc and libm.
$ cd $TESTWS/onarm-gate $ ./usr/src/tools/scripts/bldenv.sh -d opensolaris-arm.sh $ cd ./usr/src/lib/common $ dmake install $ cd ../libc $ dmake install $ cd ../libm $ dmake install $ exit
4.3.3 Remove base gcc and reinstall Sun cross ld and binutils
Remove base gcc in /opt/arm-eabi.
$ pfexec rm -rf /opt/arm-eabi
Reinstall Sun cross ld.
$ cd $TESTWS/onarm-gate/usr/src/cmd/sgs/proto/cross/arm $ pfexec mkdir -p /opt/arm-eabi/ccs $ gtar cvf - . | (cd /opt/arm-eabi/ccs; pfexec gtar xvf -)
Reinstall binutils
$ cd $TESTWS/binutils-2.18/objs $ pfexec gmake install
4.3.4 Solaris aware gcc
Build source code with Solaris crt*.o, libc and libm, and install binary into /opt/arm-eabi
$ cd $TESTWS/gcc-4.1.1
$ rm -rf objs newlib
$ mkdir objs
$ cd objs
$ $TESTWS/gcc-4.1.1/configure ~--prefix=/opt/arm-eabi
~--target=arm-pc-solaris2.11
~--with-sysroot=/opt/arm-eabi/root
~--with-build-sysroot=$TESTWS/onarm-gate/proto/root_arm
~--with-as=/opt/arm-eabi/arm-pc-solaris2.11/bin/as ~--with-gnu-as
~--with-ld=/opt/arm-eabi/ccs/bin/ld
~--with-ar=/opt/arm-eabi/arm-pc-solaris2.11/bin/ar ~--with-gnu-ar
~--with-libiconv-prefix=system ~--enable-languages=c,c++
~--with-cpu=mpcore ~--disable-multilib ~--enable-threads=posix
$ gmake
$ pfexec gmake install
5. Building ON for ARM
5.1 Setup build environment
If initenv.sh is done before and the opensolaris-arm.sh is generated in $TESTWS/onarm-gate, this step can be skipped.
$ cd $TESTWS/onarm-gate $ ./initenv.sh
Set up build environment. The -d option supports to build debugging version.
$ ./usr/src/tools/scripts/bldenv.sh -d opensolaris-arm.sh
If setup is done before, this step can be skipped.
$ cd $TESTWS/onarm-gate/usr/src $ dmake setup
If it is built for cross development toolchain before, the cleaning up is required.
$ cd $TESTWS/onarm-gate/usr/src $ dmake clean
5.2 Build and install ON
$ cd $TESTWS/onarm-gate/usr/src $ dmake install $ exit
6. Run Solaris on QEMU
6.1 Setup QEMU
Download the qemu 0.9.1 and patch for ne1 platform, and unpack the source and install patch.
$ cd $TESTWS/onarm-gate/usr/src/qemu $ gtar xzvf $DOWNLOAD/qemu-0.9.1.tar.gz $ cd qemu-0.9.1 $ bzcat $DOWNLOAD/qemu-0.9.1-arm-ne1-solaris.patch.bz2 | gpatch -p0
Build the source code.
$ cd $TESTWS/onarm-gate/usr/src/qemu/qemu-0.9.1 $ ./configure ~--cc=/usr/sfw/bin/gcc ~--target-list=arm-softmmu $ gmake
6.2 Setup Solaris
Set up build environment. The -d option supports to build debugging version.
$ cd $TESTWS/onarm-gate $ ./usr/src/tools/scripts/bldenv.sh -d opensolaris-arm.sh $ cd usr/src
6.3 Making ramdisk of UFS root filesystem
$ cd $TESTWS/onarm-gate/usr/src/qemu/rdimage $ pfexec make
6.4 Setup image files (kernel, ramdisk, ...)
$ cd $TESTWS/onarm-gate/usr/src/qemu/ne1 $ make
6.5 Execute Solaris on QEMU
$ cd $TESTWS/onarm-gate/usr/src/qemu/ne1 $ ./ne1.sh
It shows message and then login prompt appears.
console login:
The root user is available without password.
console login: root #
7. Build applications
Copy root file system into /opt/arm-eabi/root to build applications with the cross toolchain.
$ pfexec mkdir -p /opt/arm-eabi/root $ cd $TESTWS/onarm-gate/proto/root_arm $ gtar cvf - . | (cd /opt/arm-eabi/root; pfexec gtar xvf -)