Issues while build insight-6.8-1 with –target=spare-elf configuration

使用 insight-6.8-1

% ../insight-6.8-1/configure --target=sparc-elf --prefix=$OPT/sparc-elf-4.7.0 --disable-nls --disable-werror

會出現以下 error messages:

...
/GNU/SRC/insight-6.8-1/sim/erc32/float.c:173:2: warning: #warning no fpu trap support for this target [-Wcpp]
gcc -DHAVE_CONFIG_H     -DPROFILE=1 -DWITH_PROFILE=-1          -DDEFAULT_INLINE=0           -DSTAT -DFAST_UART -DIUREV0 -DMECREV0   -I. -I/GNU/SRC/insight-6.8-1/sim/erc32 -I../common -I/GNU/SRC/insight-6.8-1/sim/erc32/../common -I../../include -I/GNU/SRC/insight-6.8-1/sim/erc32/../../include -I../../bfd -I/GNU/SRC/insight-6.8-1/sim/erc32/../../bfd -I../../opcodes -I/GNU/SRC/insight-6.8-1/sim/erc32/../../opcodes  -g -O2 -o sis 
  sis.o exec.o erc32.o func.o help.o float.o  ../../bfd/libbfd.a ../../opcodes/libopcodes.a  ../../libiberty/libiberty.a -lnsl  ../../readline/libreadline.a  -lm 
../../readline/libreadline.a(display.o): In function `cr':
/GNU/SRC/insight-6.8-1/readline/display.c:2205: undefined reference to `tputs'
../../readline/libreadline.a(display.o): In function `_rl_move_cursor_relative':
/GNU/SRC/insight-6.8-1/readline/display.c:1719: undefined reference to `tputs'
/GNU/SRC/insight-6.8-1/readline/display.c:1745: undefined reference to `tputs'
../../readline/libreadline.a(display.o): In function `_rl_move_vert':
/GNU/SRC/insight-6.8-1/readline/display.c:1783: undefined reference to `tputs'
...

查了很久之後,發現是 link erc32 時少了 ncurses 這個 library,也就是少了 -lncurses。
解法:patch insight-6.8-1 source code:
edit ./insight-6.8-1/sim/erc32/Makefile.in

 
Line.25:    SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) -lm -lncurses

重新編譯安裝就OK了!

% ../insight-6.8-1/configure --target=sparc-elf --prefix=$OPT/sparc-elf-4.7.0 --disable-nls --disable-werror
% make
% make install

Install TRAP (TRansaction level Automatic Processor generator)

安裝完 SystemC-2.2.0 and TLM 後,
在來安裝 TRAP 來玩玩看,這裡有詳細的安裝步驟說明。

一些準備工作
請先確認系統是否已安裝以下的 Library or Tools
libELF, SystemC, TLM, Boots, Python, networkx

Checkout TRAP Source Code

% svn checkout http://trap-gen.googlecode.com/svn/trunk/ trap-gen

Compile and Install TRAP

% cd trap-gen
% ./waf configure --with-systemc=/opt/systemc/systemc-2.2.0 --prefix=/opt/systemc/trap
% ./waf
% ./waf install

Compile LEON3 Processor

% cd processors/LEON3
% python LEON3Arch.py
% cd processors
% ./waf configure --with-systemc=/opt/systemc/systemc-2.2.0 --with-tlm=/opt/systemc/TLM-2009-07-15 --with-trap=/opt/systemc/trap
% ./waf

TRAP 產生的 CPU Simulator 可以有四種類型:funcLT, funcAT, accLT, accAT

    funcLT : Instruction-Accurate with loosely-timed TLM interfaces
    funcAT : Instruction-Accurate with accurate-timed TLM interfaces
    accLT : Cycle-Accurate with loosely-timed TLM interfaces
    accAT : Cycle-Accurate with accurate-timed TLM interfaces

但這次編譯,只會生出 funcLT and funcAT。

Install cross compiler
有已經做好的 sparc-elf, arm-elf compiler,替我省下不少時間!
若要自己做 cross compiler,要記得 compiler 安裝完後要將 BSP 檔案 copy 到 compiler 安裝目錄,以 sparc-elf 為例:

% cp $(TRAP_SRC_DIR)/BSP_and_Compiler/sparc/* $(SPARC_ELF_INSTALL_DIR)/sparc-elf/lib
% sparc-elf-gcc -c exceptionTrap.S -o exceptionTrap.o
% sparc-elf-gcc -c libcStub.c -o libcStub.o
% sparc-elf-gcc -c osemu-crt0.S -o osemu-crt0.o

run Hello-World
hello.c

#include "stdio.h"
int main(void) {
    printf("Hello Worldn");
}

Compile hello.c

% sparc-elf-gcc -specs=osemu.specs -g -O2 hello.c -o hello

Simulate with funcAT

% $(TRAP-SRC-DIR)/processors/LEON3/processor/_build_/funcAT/funcAT -a hello

             SystemC 2.2.0 --- Apr 17 2012 12:05:44
        Copyright (c) 1996-2006 by all Contributors
                    ALL RIGHTS RESERVED

	
	      _/        _/_/_/_/    _/_/    _/      _/   _/_/_/
	     _/        _/        _/    _/  _/_/    _/         _/
	    _/        _/_/_/    _/    _/  _/  _/  _/     _/_/
	   _/        _/        _/    _/  _/    _/_/         _/
	  _/_/_/_/  _/_/_/_/    _/_/    _/      _/   _/_/_/
	


	Luca Fossati  -    email: fossati.l@gmail.com




Loading the application and initializing the tools ...
... tools initialized

Hello World

Program exited with value 10

SystemC: simulation stopped by user.

Elapsed 0 sec. (real time)
Executed 1924 instructions
Execution Speed: inf MIPS
Simulated time: 2330 us
Elapsed 2330 cycles

Simulate with funcCT

% $(TRAP-SRC-DIR)/processors/LEON3/processor/_build_/funcAT/funcAT -a hello

             SystemC 2.2.0 --- Apr 17 2012 12:05:44
        Copyright (c) 1996-2006 by all Contributors
                    ALL RIGHTS RESERVED

	
	      _/        _/_/_/_/    _/_/    _/      _/   _/_/_/
	     _/        _/        _/    _/  _/_/    _/         _/
	    _/        _/_/_/    _/    _/  _/  _/  _/     _/_/
	   _/        _/        _/    _/  _/    _/_/         _/
	  _/_/_/_/  _/_/_/_/    _/_/    _/      _/   _/_/_/
	


	Luca Fossati  -    email: fossati.l@gmail.com




Loading the application and initializing the tools ...
... tools initialized

Hello World

Program exited with value 10

SystemC: simulation stopped by user.

Elapsed 0.01 sec. (real time)
Executed 1924 instructions
Execution Speed: 0.1924 MIPS
Simulated time: 2330 us
Elapsed 2330 cycles
%

run Testsuite

% cd $(TRAP-SRC-DIR)/testsuite
% setenv CC_CROSS sparc-elf-gcc
% setenv CFLAGS "-DBIG_TARGET -specs=osemu.specs"
% setenv SIMULATOR "../processors/LEON3/processor/_build_/funcAT/funcAT"
% make test

run Benchmark

% cd $(TRAP-SRC-DIR)/benchmarks
% setenv CC_CROSS sparc-elf-gcc
% setenv CFLAGS "-DBIG_TARGET -specs=osemu.specs"
% setenv SIMULATOR "../processors/LEON3/processor/_build_/funcAT/funcAT"
% make run

OpenSuSE 11.1 上的 TCL Library

閒閒沒事
把之前在 Mac OS 上 跑的 NAND Flash Static Wear Leveling 的 EV程式
拿到 SuSE 上跑,結果居然 Compile 不起來
發現是 “-ltcl” 無法 link 到 正確的 TCL Library
若將之改為 “-ltcl8.5” 就 OK

好像是 TCL Library 在 Install 時有問題
自己動手修正:

$ (cd /usr/lib; sudo ln -s libtcl8.5.o libtcl.o)
$ (cd /usr/lib64; sudo ln -s libtcl8.5.o libtcl.o)

這樣 “-ltcl” 就 OK 了。