User:Columbus/OR1K Toolchain

From OSDev.wiki
Revision as of 19:14, 13 November 2014 by Columbus (talk | contribs) (Mentioned GDC)
Jump to navigation Jump to search

A tutorial, how to build a OpenRISC toolchain. At the end of the tutorial, you have a GCC-Toolchain for or1k. I'm trying to use it for OS deving. I'd be happy, if someone could write a Barebone for it, because I don't understand the or1k opcodes/mnemonics.

Prerequisites

You must have git installed, and the folder /opt/or1k-toolchain should exist, and the user you're using should have write access.

Compiling the toolchain

The toolchain gets installed to /opt/or1k-toolchain In some directory do

# Clone repos
git clone git://github.com/openrisc/or1k-src.git
git clone git://github.com/openrisc/or1k-gcc.git
# Create build directories
mkdir build-or1k-src build-or1k-gcc
# Extend $PATH
export PATH=$PATH:/opt/or1k-toolchain

# Build src
cd build-or1k-src

../or1k-src/configure --target=or1k-elf      \
--prefix=/opt/or1k-toolchain --enable-shared \
--disable-itcl   --disable-tk --disable-tcl  \
--disable-winsup --disable-gdbtk             \
--disable-libgui --disable-rda --disable-sid \
--disable-sim    --disable-gdb --with-sysroot \
--disable-newlib --disable-libgloss          \
--disable-werror

make -j8
make install

# Build gcc
cd ../bld-or1k-gcc

../or1k-gcc/configure --target=or1k-elf           \
--prefix=/opt/or1k-toolchain --enable-languages=c \
--disable-shared --disable-libssp --disable-werror

make -j8
make install -j8

# Rebuild src with newlib
cd ../bld-or1k-src
rm -rf *

../or1k-src/configure --target=or1k-elf      \
--prefix=/opt/or1k-toolchain --enable-shared \
--disable-itcl   --disable-tk --disable-tcl  \
--disable-winsup --disable-gdbtk --disable-nls \
--disable-libgui --disable-rda --disable-sid \
--enable-sim  --disable-or1ksim --enable-gdb \
--with-sysroot   --enable-newlib             \
--enable-libgloss --disable-werror

make -j8
make install -j8

# Rebuild gcc with newlib
cd ../bld-or1k-gcc
rm -rf *

../or1k-gcc/configure --target=or1k-elf               \
--prefix=/opt/or1k-toolchain --enable-languages=c,c++ \
--disable-shared --disable-libssp --with-newlib       \
--disable-werror --disable-nls --without-headers

make -j8
make install -j8

Further

You now have a C/C++ Compiler, and an Assembler with or1k as target. But you should know, that in the Assembler, you can only use GAS-Keywords, and or1k instructions. If you don't have problems with that, have fun with linking and so on as usual.

One could also combine with the GDC-Toolchain tutorial, to have a really special thing. I didn't try this, and I don't know if or1k breaks GDC

If you're interested, the or1k page is |here. It contains the Architecture Specification, which names the instructions that you can use.

Sources

I got the main commands from the or1k Documentation

Then I combined them with the GCC-CrossCompiler tutorials.