2014年10月24日金曜日

SoftEther VPN on Gentoo

SoftEther VPN is an opensource VPN client/server software, which supports multiple vpn protocols like their own protocol, L2TP/IPsec, OpenVPN, and MS-SSTP. Its client and server software runs on multiple platform including Window, Linux and BSD. Simply saying it's awesome.

Maybe because the software is originally developed on Windows, some part of its behavior is not unix-style.
  • logs are saved in the same directory as the binary locates
  • config file is saved in the same directory as the binary locates

And no ebuild in the gentoo portage exists. That's why I make my portage overlay.
It is available at my github repository.

The ebuild includes several patches that I think not appropriate to merged in mainline.
  1. pid file and log file are saved in /var/run and /var/log/softeher respectively.
  2. disable override /proc/sys/kernel/threads-max setting
  3. activate all features including X.509 authentication that are disabled on original source

How to use my overlay: 

  • emerge layman
  • enable the line of "overlay_defs" in /etc/layman/layman.cfg
  • wget https://raw.githubusercontent.com/yTakatsukasa/misc/master/layman/yutetsu.xml -O /etc/layman/overlay/yutetsu.xml
  • layman -a yutetsu

How to install softether-vpn

After my overlay is enabled,
# emerge softether-vpn
# rc-update add vpnserver
# /etc/init.d/vpnserver start
Then configure the vpnserver. I recommend to use Server Management program on windows to configure the server.

2014年9月25日木曜日

Changing the permission of /dev/nvidia* on Gentoo Linux

To use CUDA on Gentoo, just emerge nvvidia-cuda-sdk is sufficient.
After installing the driver and sdk, /dev/nvidia* will be found.

These device files has 660 permission and belong to video group.
So if users are a member of video group, no problem.

If you want to use the device file from other groups, you have to change the permission.
Here is what I did.


1) edit /etc/modprobe.d/nvidia.conf
  change the line starts with "options nvidia NVreg_DeviceFileMode=", from NVreg_DeviceFileMode=432 to NVreg_DeviceFileMode=0666

2) chmod +x /opt/bin/nvidia-modprobe

3) reboot

Then you will find /dev/nvidia* have permissioin 666.

2013年10月10日木曜日

PATCH for SystemC-2.3 to keep the module hierarchy in VCD

As I have posted to SystemC Forum I wrote a small patch to keep the module hierarchy in VCD.
The patch modifies a PoC simulator to treat signal name as a dot-separated path.
VCD Hierarchy Manipulator is no more necessary.

How to get the patch

Please see my github page or simply wget it.

How to apply

% tar zxvf systemc-2.3.0.tgz
% cd systemc-2.3.0
% patch -p0 <  ../sc_vcd_trace.patch
% ./configure --any-options
% make
% make install 
 

How to Use

No need to modify the SystemC model. All you need to do is just rebuild your design with the patched systemc library. You will get the VCD as a following screen shot.

If you want to disable this feature, set an environmental variable SC_VCD_NO_HIERARCHY.


Feedbacks

I only tested with a small example. Any feedback is welcome.

2013年7月29日月曜日

OpenRISC toolchain

Toolchain for OpenRISC cannot be built with the mainline source code. It was difficult for me to find the right way from openrisc web site.

After a couple of days of crawling, I found a repository maintained by Kevin Mehall.
It works perfectly, and its good point is gdb is also maintained.

If all libraries(GMP, MPFR and MPC) to build GCC have already been installed, simply do as following.
 
% git clone https://github.com/kevinmehall/openrisc-tools-build
% cd openrisc-tools-build
% git submodule update --init
% make -j3 PREFIX=

I wanted to build them on CentOS5.x machine and these libraries are not installed by default.
I wrote a preparation script to download and build these libraries.
These libraries are built as a static library, so setting LD_LIBRARY_PATH is not required.
If you faced the same problem, please try the following procedure.

% git clone https://github.com/kevinmehall/openrisc-tools-build
% cd openrisc-tools-build 
% git submodule update --init
% wget https://raw.github.com/yTakatsukasa/misc/master/openrisc_toolchain/toolchain.patch -O - | patch -p1
% bash ./prepare.sh
% make -j3 PREFIX=

Note that this patch disables openOCD. If you need openOCD, add openOCD to all: in Makefile.

2013年6月25日火曜日

SystemC-AMS 1.0 with clang

On some system, linking with libsystemc-ams.a compiled with clang may cause multiple definitions. In that case, systemc-ams must be compiled with
-fgnu89-inline option.
 

Howto

 tar zxvf systemcams-1.0.tar.gz 

 cd systemcams-1.0
 ./configure --with-systemc=/your/systemc/path
 make CC="clang -fgnu89-inline"
 make install

configure script ignores environmental variable CFLAGS, so -fgnu89-inline option must be specified during make.

Background

Clang assumes .c file as a C99 source code. Some C program assumes its language is C89 with gnu extension (aka gnu89).
gnu89 and C99 have several differences. The biggest one is a function with 'extern inline'.
In gnu89, functions with 'extern inline' are not necessarily compiled to normal non-inlined function.
In C99, such functions must be also compiled to a normal non-inlined function.
Source code which is expected to be compiled with gnu89 may cause link error of multiple definitions for this case.
If you use inline function in C, use 'static inline'. Its meaning is same for both C99 and gnu89.

2013年6月12日水曜日

SystemC-2.3 with Clang

Clang is a compiler which features fast compile, friendly error messages and high-compatibility with the latest C++ standard.
SystemC-2.2 can not be compiled with clang due to syntax violation of SystemC library.
Such violations are fixed in SystemC-2.3 but not perfect.
Clang emits warnings with -Wall and -Wextra option.
It is important to set the warning level higher to keep code clean.
If warnings are emitted at the library, warnings of user code may be concealed by them.
This is why libraries must be warning-free.

I wrote small patch to suppress such warnings.
https://github.com/yTakatsukasa/misc/tree/master/systemc-2.3_clang

Apply systemc-2.3_clang.patch before configure., then build it as usual.
 
  1. tar zxvf systemc-2.3.0.tgz
  2. patch -p0 < systemc-2.3_clang.patch
  3. cd systemc-2.3.0
  4. env CC=clang CXX=clang++ CPP="clang -E" ./configure
  5. make
  6. make install

2013年6月10日月曜日

JCPU shows pretty good performance

I changed the name or QCPU (in previous post) to JCPU, because noun QCPU is already used in a FA industry. 'J' derives from JIT (Just In Time compilation).
Only limited instructions are implemented, but now it can execute simple program.
I tested with a bubble sort with printf and get the result of more than 100 million instructions / sec without any optimization techniques.
Exceptions, MMU and supervisor mode is still unimplemented. These feature will decrease the performance. I hope I can cancel these negative effect with optimization.

(2013/06/12 update)
very primitive version can be seen at https://github.com/yTakatsukasa/JCPU