Archive

Archive for the ‘Log’ Category

Building gcc as cross-compiler

Motivation

A cross-compiler is a compiler that runs on your PC and reads source code in your PC and converts that into binary suitable for some other CPU. Sometimes the precise cross compile tool may not be available as a binary package. For example, in my case i wanted to use bare-metal x86 tools(To build BIOS or similar low level system software). It was not available as binary package. Hence only option is to build it.

Dependencies

The packages and libraries needed to build gcc are well documented along with gcc. If you usually build softwares on your linux build PC, there are not much extra dependencies on the PC. One important dependency to build cross gcc is you should already have cross binutils for the same platform. And the binaries especially linker(ld) and assembler(as) should be available in the path. Eg. to build i686-elf-gcc, i686-elf-ld and i686-elf-as should be available in the system path. So

  1. Step 1 is to build binutis
  2. Step 2 is to build gcc

Further I will list the steps needed to build the cross gcc; specifically the i686-elf variant

Step 1: Build binutils as cross-tool

Download binutils. Extract, configure from a separate build directory, build and install it using following commands.

tar -xvf binutils-2.26.tar.bz2
mkdir build_binutils
cd build_binutils
../binutils-2.26/configure --target=i686-elf --prefix=<path-to-bin> --disable-nls --with-sysroot
make
make install
cd ..

All binaries will be available in the path specified in <path-to-bin>

Step 2: Build gcc as cross-tool

First set the path to binutils executables that got generated in the previous step.

PATH=<path-to-bin>:$PATH

Download, extract, configure from a separate build directory, build and install it using following commands

tar -xvf gcc-gcc-4_9_3-release.zip
mkdir build_gcccd build_gcc
../gcc-gcc-4_9_3-release/configure --target=i686-elf --prefix=<path-to-bin> --disable-nls --enable-languages=c,c++ --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc

All binaries and libraries generated will be available in path specified in <path-to-bin>

References

OSDev: GCC Cross-Compiler

OSDev: GCC tool naming/prefix convention

Categories: Log, Tech Tags: , , ,

Xilinx ISE on Ubuntu

January 26, 2015 Leave a comment

This post shall contain the issue I faced and solutions, when trying to use Xilinx ISE on Ubuntu(11.04). Shall keep updating as and when I encounter problems.

ISim Simulator – Link issue

The installation and the synthesis were trouble free. Had a bit issue with simulation. The simulation was not getting compiled. It was reporting “FATAL_ERROR:Simulator:Fuse.cpp:500:1.133 – Failed to compile generated C file isim/testbench_isim_beh.exe.sim/work/<filename>”. First step was to enable the more detailed error report by adding the “-v 1” option to the simulation build command. From the detailed log it turns out that the ‘fuse simulator’ was picking up the wrong libstdc++.so.6 from /opt/Xilinx/14.7/ISE_DS/ISE/lib/lin instead of /usr/lib/i386-linux-gnu. Issued the following commands as suggested by the 4th post at this archlinux forum.

From /opt/Xilinx/14.7/ISE_DS/ISE/lib/lin,

mkdir backup
mv libstdc++.so.6 backup
ln -s /usr/lib/i386-linux-gnu/libstdc++.so.6 /opt/Xilinx/14.7/ISE_DS/ISE/lib/lin/libstdc++.so.6

That solved the simulation issue.

Categories: Log Tags: ,

System C on Ubuntu – Installation

August 15, 2012 2 comments
Installation of systemc-2.3.0.tgz is straight-forward.. Just follow the instructions in INSTALL file. This log is for systemc-2.2.0.tgz

I am looking towards learning systemC. So the first step is setting up one on my PC. It was not so straight-forward for somebody like me who has done only a few hours of research about systemC. So I thought of logging my experience setting up systemC in Ubuntu 11.04. (The best way to backup information is to make it public)

1.What is it

Initially I was thinking it is a new language all-together, with a different set of tool-chain. With a little bit of research, I came to the conclusion – “to the user, systemC is c++ library and header file collection, that can be linked to other c++ files using any c++ compiler & linker”.

2. Where to get it

According to the wikipedia page on systemC, it’s just an IEEE standard, which anybody can implement. So there will be multiple versions of the systemC. Luckily, Accellera has a proof of concept implementation, which is available for free from here. You need to register, providing your email id. After registration and logging in, the systemc-2.2.0.tgz (I am not very clear about the TLM stuff. Will first experiment with this and then the latest 2.3.0, with TLM)can be downloaded. If you directly go for systemc-2.3.0.tgz, some of the steps here may be irrelevant.

3. How to setup

Unzipped the file, and read the README and INSTALL. Followed the instructions in INTALL file. But got a compiler  error in sc_utils_ids.cpp, regarding some namespace issue while running make. As an embedded engineer, I am really bad at any language other than plain C. So did the searching, the following two links came up

Link1

Link2

Downloaded the 0001-missing-system-headers-function-qualification.patch file from the second link. Patched the original sc_utils_ids.cpp file with the patch using command

patch -i ~/Downloads/0001-missing-system-headers-function-qualification.patch ../src/sysc/utils/sc_utils_ids.cpp

Then did a make and make install again. This gave me the libraries and include files in /usr/local/systemc-2.2.0 (As I have used the ../configure –prefix=/usr/local/systemc-2.2.0 to do the configuration).

Categories: Log Tags: ,