2012年5月18日 星期五

New I2C I/O Expander Supplier

Goyatek is a new I2C I/O expander supplier.
It supplies PCA9554, PCA9554A and PCA9555.


A new I2C IO expander supplier

Goyatek is a new i2c io expander supplier. PCA9555, PCA9554 and PCA9554A are available.

2012年4月26日 星期四

GNU Cross Compiler 編譯程序

寫了一個 Makefile,可以半自動的編譯 GNU Cross Compiler
做個記錄,怕以後忘記

#TARGET = arm-elf
#TARGET = mips-elf
TARGET = sparc-elf

PKG_DIR = $(CURDIR)/PKG
SRC_DIR = $(CURDIR)/SRC
BUILD_DIR = $(CURDIR)/BUILD-$(TARGET)
TARGET_DIR = /srv/xfile/compiler/$(TARGET)-4.7.0

BINUTILS_VER = binutils-2.22
GCC_VER = gcc-4.7.0
MPC_VER = mpc-0.9
MPFR_VER = mpfr-3.1.0
GMP_VER = gmp-5.0.4
NEWLIB_VER = newlib-1.20.0
GDB_VER = gdb-7.3.1
INSIGHT_VER = insight-6.8-1

GCC_PACKAGE = $(PKG_DIR)/gcc/$(GCC_VER).tar.bz2
GCC_SRC_DIR = $(SRC_DIR)/$(GCC_VER)
GCC_BUILD_DIR = $(BUILD_DIR)/$(GCC_VER)

GMP_PACKAGE = $(PKG_DIR)/gmp/$(GMP_VER).tar.bz2
GMP_SRC_DIR = $(SRC_DIR)/$(GMP_VER)
GMP_BUILD_DIR = $(BUILD_DIR)/$(GMP_VER)

MPFR_PACKAGE = $(PKG_DIR)/mpfr/$(MPFR_VER).tar.bz2
MPFR_SRC_DIR = $(SRC_DIR)/$(MPFR_VER)
MPFR_BUILD_DIR = $(BUILD_DIR)/$(MPFR_VER)

MPC_PACKAGE = $(PKG_DIR)/mpc/$(MPC_VER).tar.gz
MPC_SRC_DIR = $(SRC_DIR)/$(MPC_VER)
MPC_BUILD_DIR = $(BUILD_DIR)/$(MPC_VER)

BINUTILS_PACKAGE = $(PKG_DIR)/binutils/$(BINUTILS_VER).tar.bz2
BINUTILS_SRC_DIR = $(SRC_DIR)/$(BINUTILS_VER)
BINUTILS_BUILD_DIR = $(BUILD_DIR)/$(BINUTILS_VER)

GDB_PACKAGE = $(PKG_DIR)/gdb/$(GDB_VER).tar.gz
GDB_SRC_DIR = $(SRC_DIR)/$(GDB_VER)
GDB_BUILD_DIR = $(BUILD_DIR)/$(GDB_VER)

NEWLIB_PACKAGE = $(PKG_DIR)/newlib/$(NEWLIB_VER).tar.gz
NEWLIB_SRC_DIR = $(SRC_DIR)/$(NEWLIB_VER)
NEWLIB_BUILD_DIR = $(BUILD_DIR)/$(NEWLIB_VER)

INSIGHT_PACKAGE = $(PKG_DIR)/insight/$(INSIGHT_VER).tar.bz2
INSIGHT_SRC_DIR = $(SRC_DIR)/$(INSIGHT_VER)
INSIGHT_BUILD_DIR = $(BUILD_DIR)/$(INSIGHT_VER)

CONFIG_FLAGS = --target=$(TARGET) \
--prefix=$(TARGET_DIR)
note:
@echo ----------------------------------------
@echo make binutils # Build binutils
@echo make gcc-p0 # Build GMP, MPFR, MPC
@echo make gcc-p1 # Build GCC Pass-1
@echo make newlib # Build newlib
@echo make gcc-p2 # Build GCC Pass-2
@echo make insight # Build insight
@echo ----------------------------------------

all: binutils gcc-p0 gcc-p1 newlib gcc-p2 insight

dir : src_dir

# Source Decompress

src_dir: $(BINUTILS_SRC_DIR) $(NEWLIB_SRC_DIR) $(GCC_SRC_DIR) $(GDB_SRC_DIR) $(INSIGHT_SRC_DIR) $(GMP_SRC_DIR) $(MPFR_SRC_DIR) $(MPC_SRC_DIR)

build_dir: $(BINUTILS_BUILD_DIR) $(NEWLIB_BUILD_DIR) $(GCC_BUILD_DIR) $(GDB_BUILD_DIR)

# ------------- BINUTIL ----------------

BINUTILS_CONF = $(CONFIG_FLAGS) --disable-nls

binutils: $(BINUTILS_BUILD_DIR)
@echo "****** Build $(BINUTILS_VER) ***********"
(cd $(BINUTILS_BUILD_DIR); $(BINUTILS_SRC_DIR)/configure $(BINUTILS_CONF);)
(cd $(BINUTILS_BUILD_DIR); make all install)

$(BINUTILS_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(BINUTILS_PACKAGE) ***********"
-@mkdir $(BINUTILS_SRC_DIR)
(cd $(SRC_DIR); tar -jxvf $(BINUTILS_PACKAGE))

$(BINUTILS_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(BINUTILS_BUILD_DIR) ***********"
-@mkdir $(BINUTILS_BUILD_DIR)

# ------------- NEWLIB ----------------

NEWLIB_CONF = $(CONFIG_FLAGS) --disable-nls

newlib: $(NEWLIB_BUILD_DIR)
@echo "****** Build $(NEWLIB_VER) ***********"
(set path = $(TARGET_DIR)/bin;cd $(NEWLIB_BUILD_DIR);$(NEWLIB_SRC_DIR)/configure $(NEWLIB_CONF);)
(cd $(NEWLIB_BUILD_DIR); make all install)

$(NEWLIB_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(NEWLIB_PACKAGE) ***********"
(cd $(SRC_DIR); tar -zxvf $(NEWLIB_PACKAGE))

$(NEWLIB_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(NEWLIB_BUILD_DIR) ***********"
-@mkdir $(NEWLIB_BUILD_DIR)

# ------------- GDB ----------------

GDB_CONF = $(CONFIG_FLAGS) --disable-nls

gdb: $(GDB_BUILD_DIR)
@echo "****** Build $(GDB_VER) ***********"
(cd $(GDB_BUILD_DIR); $(GDB_SRC_DIR)/configure $(GDB_CONF);)
(cd $(GDB_BUILD_DIR); make all install))

$(GDB_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(GDB_PACKAGE) ***********"
(cd $(SRC_DIR); tar -zxvf $(GDB_PACKAGE))

$(GDB_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(GDB_BUILD_DIR) ***********"
-@mkdir $(GDB_BUILD_DIR)

# ------------- INSIGHT ----------------
INSIGHT_CONF = $(CONFIG_FLAGS) --disable-nls --disable-werror

insight: $(INSIGHT_BUILD_DIR)
@echo "****** Build $(INSIGHT_VER) ***********"
(cd $(INSIGHT_BUILD_DIR); $(INSIGHT_SRC_DIR)/configure $(INSIGHT_CONF);)
(cd $(INSIGHT_BUILD_DIR); make all install)

$(INSIGHT_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(INSIGHT_PACKAGE) ***********"
(cd $(SRC_DIR); tar -jxvf $(INSIGHT_PACKAGE))

$(INSIGHT_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(INSIGHT_BUILD_DIR) ***********"
-@mkdir $(INSIGHT_BUILD_DIR)

# ------------- gcc-p0 ----------------

gcc-p0: gmp mpfr mpc

# ------------- GMP ----------------

GMP_CONF = --prefix=$(TARGET_DIR)

gmp: $(GMP_BUILD_DIR)
@echo "****** Build $(GMP_VER) ***********"
(cd $(GMP_BUILD_DIR); $(GMP_SRC_DIR)/configure $(GMP_CONF);)
(cd $(GMP_BUILD_DIR); make all install)

$(GMP_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(INSIGHT_PACKAGE) ***********"
(cd $(SRC_DIR); tar -jxvf $(GMP_PACKAGE))

$(GMP_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(GMP_BUILD_DIR) ***********"
-@mkdir $(GMP_BUILD_DIR)

# ------------- MPFR ----------------

MPFR_CONF = --prefix=$(TARGET_DIR) \
--with-gmp=$(TARGET_DIR)

mpfr: $(MPFR_BUILD_DIR)
@echo "****** Build $(MPFR_VER) ***********"
(cd $(MPFR_BUILD_DIR); $(MPFR_SRC_DIR)/configure $(MPFR_CONF);)
(cd $(MPFR_BUILD_DIR); make all install)

$(MPFR_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(MPFR_PACKAGE) ***********"
(cd $(SRC_DIR); tar -jxvf $(MPFR_PACKAGE))

$(MPFR_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(MPFR_BUILD_DIR) ***********"
-@mkdir $(MPFR_BUILD_DIR)

# ------------- MPC ----------------

MPC_CONF = --prefix=$(TARGET_DIR) \
--with-gmp=$(TARGET_DIR) \
--with-mpfr=$(TARGET_DIR)

mpc: $(MPC_BUILD_DIR)
@echo "****** Build $(MPC_VER) ***********"
(cd $(MPC_BUILD_DIR); $(MPC_SRC_DIR)/configure $(MPC_CONF);)
(cd $(MPC_BUILD_DIR); make all install)

$(MPC_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(MPC_PACKAGE) ***********"
(cd $(SRC_DIR); tar -zxvf $(MPC_PACKAGE))

$(MPC_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(MPC_BUILD_DIR) ***********"
-@mkdir $(MPC_BUILD_DIR)

# ------------- GCC ----------------
GCC_CONF = $(CONFIG_FLAGS) \
--enable-interwork \
--disable-multilib \
--disable-nls \
--disable-shared \
--disable-threads \
--disable-decimal-float \
--disable-libmudflap \
--disable-libssp \
--disable-libgomp \
--disable-libquadmath \
--without-ppl \
--without-cloog \
--enable-languages=c,c++ \
--with-newlib \
--with-headers=$(NEWLIB_SRC_DIR)/newlib/libc/include \
--with-gmp=$(TARGET_DIR) \
--with-mpfr=$(TARGET_DIR) \
--with-mpc=$(TARGET_DIR) \
--enable-obsolete \

# --with-mpfr-include=$(GCC_SRC_DIR)/mpfr/src \
# --with-mpfr-lib=$(GCC_SRC_DIR)/mpfr/src/.lib

gcc-p1: $(GCC_BUILD_DIR)
@echo "****** Build $(GCC_VER) Phase-1 ***********"
(cd $(GCC_BUILD_DIR); $(GCC_SRC_DIR)/configure $(GCC_CONF);)
(cd $(GCC_BUILD_DIR); make all-gcc install-gcc)

gcc-p2:
@echo "****** Build $(GCC_VER) Phase-2 ***********"
(cd $(GCC_BUILD_DIR); make all install)

$(GCC_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(GCC_PACKAGE) ***********"
(cd $(SRC_DIR); tar -jxvf $(GCC_PACKAGE))

$(GCC_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(GCC_BUILD_DIR) ***********"
-@mkdir $(GCC_BUILD_DIR)

# ------------- misc ----------------

$(SRC_DIR):
@echo "****** create directory $(SRC_DIR) ***********"
-@mkdir $(SRC_DIR)

$(BUILD_DIR):
@echo "****** create directory $(BUILD_DIR) ***********"
-@mkdir $(BUILD_DIR)

$(PKG_DIR):
@echo ERROR! No $(GNU_DIR) found!
exit

clean: clean-build clean-src

clean-src:
@rm -rf $(SRC_DIR)

clean-build:
@rm -rf BUILD-*

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

2012年4月18日 星期三

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 World\n");
}

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

2012年4月17日 星期二

安裝 SystemC and TLM on OpenSuSE 12.1 (64-bit Linux)

Setup Environment Variable
edit .cshrc by adding:

setenv SYSTEMC_HOME /opt/systemc/systemc-2.2.0
setenv TLM_HOME /opt/systemc/TLM-2009-07-15


Install SystemC-2.2.0

照例,要先修改 ./systemc-2.2.0/src/sysc/utils/sc_utils_ids.cpp
加上下列兩行

#include "string.h"
#include "cstdlib"

開始編譯

% cd systemc-2.2.0
% mkdir objdir
% cd objdir
% ../configure --prefix=/opt/systemc/systemc-2.2.0
% make

嗯,跟之前安裝時不一樣,這次跑出來以下錯誤訊息:

../../../../systemc-2.2.0/src/sysc/datatypes/bit/sc_bit_proxies.h:716:16: error: reference ‘m_obj’ cannot be declared ‘mutable’ [-fpermissive]
../../../../systemc-2.2.0/src/sysc/datatypes/bit/sc_bit_proxies.h:1193:18: error: reference ‘m_left’ cannot be declared ‘mutable’ [-fpermissive]
../../../../systemc-2.2.0/src/sysc/datatypes/bit/sc_bit_proxies.h:1194:18: error: reference ‘m_right’ cannot be declared ‘mutable’ [-fpermissive]
../../../../systemc-2.2.0/src/sysc/datatypes/bit/sc_bit_proxies.h:1196:18: error: reference ‘m_refs’ cannot be declared ‘mutable’ [-fpermissive]

Google 一下之後,找到解法,將 src/sysc/datatypes/bit/sc_bit_proxies.h 中的 mutable 都去除
重新 compile

% ../configure --prefix=/opt/systemc/systemc-2.2.0
% make
% sudo make install

最後可以做一下測試

$ make check


Install TLM-2.0.1
Step.1 將 TLM-2.0.1 解到 /opt/systemc/systemc-2.2.0

sudo tar -C /opt/systemc -zxvf ~/work/SystemC/SystemC.org/download/TLM-2.0.1.tgz

Spte.2 修改 systemc-2.2.0/include/sysc/packages/boost/bind/placeholders.hpp

LINE.28 #if defined(__BORLANDC__) || defined(__GNUC__)

Spte.3 修改 systemc-2.2.0/include/sysc/datatypes/bit/sc_lv_base.h

LINE.309 return sc_logic_value_t( (m_data[wi] >> bi & SC_DIGIT_ONE) |
LINE.310 (m_ctrl[wi] >> bi << 1 & SC_DIGIT_TWO) );


Run TLM-2.0.1 examples
Step.1 修改 TLM-2009-07-15/examples/tlm/build-unix/Makefile.config

LINE.2 DEFAULT_TARGET_ARCH = linux64

Step.2 執行 examples

% cd TLM-2009-07-15/examples/tlm/build-unix
% make
% make run


Run TLM-2.0.1 unit_test
Step.1 修改 TLM-2009-07-15/unit_test/tlm/build-unix/Makefile.config

LINE.2 DEFAULT_TARGET_ARCH = linux64

Step.2 執行 examples

$ cd TLM-2009-07-15/unit_test/tlm/build-unix
$ make
$ make run

2012年2月20日 星期一

有時候,Safari Download 會卡住?找到原因了!

不知道從時候開始,Safari 在 Download file 時,經常會卡住完全沒反應,
且只在我的 Macbook 才會發生,家裡的 Mac Mini 以及 iMac 並不會有這情形,
找了很久都找不出原因....
今天,
在 Download vlc-2.0.0.dmg 時,又卡住了,
這次,發現一個錯誤訊息:『外掛模組錯誤』(之前都沒有留意)
查了一下 Safari 的 輔助說明 -> 以安裝的外掛模組
發現一個外掛模組 "SpeedDownload Browser Plugin" 非常可疑,
決定將他砍掉:

$ cd /Library/Internet\ Plug-Ins/
$ sudo rm -rf SpeedDownload\ Browser\ Plugin.plugin/

重新啟動 Safari,
Yes, it works!