VNC Server setup guide for Ubuntu

Usually, I used Fedora/CentOS as the development system. Recently, as I move into the machine learning world, I get my laptop setup with Ubuntu 14.04 LTS to utilize my GTX 860M for running ML algorithms. However, to set up vncserver properly on Ubuntu does not seems to be as easy as on Fedora/CentOS. In a lot of cases, you end up getting a blank desktop in your vnc-client with no menu and a basic GTK looking terminal.

I have searched online quite some while ago to find a good and easy way of setting up the vnc server and here comes the resolution. I cannot find the original post for the same method, so if you know, please give me a feedback there that I can credit the original writer.

1. Use x11vnc instead of tigervnc

To my knowledge, if you use tigervnc (command vncserver) as your vncserver, you are likely end up with a blank screen on your vnc-client. You need to add several parameters to your ~/.vnc/xstartup to start the old 2d unity menus and get it functional.

However, it seems to be pretty to setup with x11vnc without any change to xstartup script – and here is how:

Install x11vnc with command

$ apt-get install x11vnc

or you can download the newest x11vnc from sourceforge:


$ sudo apt-get install checkinstall
$ wget http://x11vnc.sourceforge.net/dev/x11vnc-0.9.14-dev.tar.gz
$ gzip -dc x11vnc-0.9.14-dev.tar.gz | tar -xvf -
$ cd x11vnc-0.9.14/
$ ./configure
$ make
$ sudo checkinstall --pkgname=x11vnc --default --pkgversion="2:0.9.14-0.1" --backup=no --deldoc=yes

Create authentication password:

$ sudo /usr/local/bin/x11vnc --storepasswd /etc/x11vnc.pass

Start x11vnc with command:

$ sudo /usr/local/bin/x11vnc -auth /var/run/lightdm/root/:0 -display :0 -rfbauth /etc/x11vnc.pass -rfbport 5900 -noxrecord -noxfixes -noxdamage -forever -bg -o /var/log/x11vnc.log

You can figure out the meaning of all those parameters with $ x11vnc -help

To start it automatically, create a file /etc/init/x11vnc.conf

Put following lines in the file


start on login-session-start
script
/usr/local/bin/x11vnc -auth /var/run/lightdm/root/:0 -display :0 -rfbauth /etc/x11vnc.pass -rfbport 5900 -noxrecord -noxfixes -noxdamage -forever -bg -o /var/log/x11vnc.log
end script

2. Repeat Key Fix

The only draw back about x11vnc is the reaction to key repeating when you long pressing the same key on keyboard.
This issue only apply to VNC client in Windows.
And the problem is how VNC client react to key-long pressing in windows and linux

From the server side, you can actually configure it on the fly:

For Windows, if you want to enable key repeating, open a command line and type:
$ x11vnc -R repeat

For Linux, you need to disable repeat option by
$ x11vnc -R norepeat

And now, everything works fantastic!!
Enjoy!

Xilinx Driver Installation in Fedora 19

Pre-requisit Packages

  • GCC Compiler
    You can install with command
    $sudo yum install gcc make
  • libusb development package
    In order to compile usb driver library for Xilinx Tools, libusb development package needed to be installed. It can be installed via command
    $sudo yum install libusb libusb-devel
  • fxload package
    fxload package can be installed via command
    $sudo yum install fxload
  • git
    git is used to download libusb-driver source code from a public git repository. git can be installed via command
    $sudo yum install git

Install pcusb driver

In this blog, Xilinx 14.6 is used as an example. In Xilinx 14.6 package, the pcusb installation script has not been updated to work with 3.x kernels. So, we need to modify install pcusb installation script a bit to use udev no matter what.

Open pcusb setup script “setup_pcusb” under <Xilinx_ISE_DS_DIR>/ISE/bin/lin64/install_script/install_drivers/linux_drivers/pcusb
[tinghui.wang@localhost ~]$cd /opt/Xilinx/14.6/ISE_DS/ISE/bin/lin64/install_script/install_drivers/
linux_drivers/pcusb/

[tinghui.wang@localhost pcusb]$ sudo vim setup_pcusb
[sudo] password for tinghui.wang:

Assign TP_USE_UDEV to 1 by inserting TP_USE_UDEV="1" after kernel version checking as follows:
45 else
46 TP_USE_UDEV=$1
47 fi;
48
49 TP_USE_UDEV="1"
50
51 if [ $TP_USE_UDEV = "1" ]
52 then
53 echo "--Using udev..."
54 fi;

Then install pcusb driver by typing following in the terminal:
[tinghui.wang@localhost pcusb]$ sudo ./setup_pcusb
--Using udev...
--File /usr/share/xusbdfwu.hex does not exist.
--File version of /usr/share/xusbdfwu.hex = 1030
--Updating xusbdfwu.hex file.
--File /usr/share/xusb_xlp.hex does not exist.
--File version of /usr/share/xusb_xlp.hex = 0000.
--Updating xusb_xlp.hex file.
--File /usr/share/xusb_emb.hex does not exist.
--File version of /usr/share/xusb_emb.hex = 0000.
--Updating xusb_emb.hex file.
--File /usr/share/xusb_xpr.hex does not exist.
--File version of /usr/share/xusb_xpr.hex = 0000.
--Updating xusb_xpr.hex file.
--File /usr/share/xusb_xup.hex does not exist.
--File version of /usr/share/xusb_xup.hex = 0000.
--Updating xusb_xup.hex file.
--File /usr/share/xusb_xp2.hex does not exist.
--File version of /usr/share/xusb_xp2.hex = 0000.
--Updating xusb_xp2.hex file.
--File /usr/share/xusb_xse.hex does not exist.
--File version of /usr/share/xusb_xse.hex = 0000.
--Updating xusb_xse.hex file.
--File /etc/udev/rules.d/xusbdfwu.rules does not exist.
--File version of /etc/udev/rules.d/xusbdfwu.rules = 0000.
--Updating rules file.

Install Digilent Driver Files

To let Xilinx iMPACT work with Digilent boards, we need to install Digilent plugin. Digilent plugin comes with Xilinx Design Suite, located at <Xilinx_ISE_Suite>/ISE/bin/lin64/digilent/
[tinghui.wang@localhost ~]$ cd /opt/Xilinx/14.6/ISE_DS/ISE/bin/lin64/digilent/
[tinghui.wang@localhost digilent]$ sudo ./install_digilent.sh

Modify Udev Rules

In Fedora 19, the syntax for udev rules has been updated. So, we need to modify the rule files as well. Here is the /etc/udev/rules.d/xusbdfwu.rules
1 # version 0003
2 ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0008", MODE="666"
3 SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0007", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusbdfwu.hex -D $tempnode"
4 SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0009", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xup.hex -D $tempnode"
5 SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000d", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_emb.hex -D $tempnode"
6 SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000f", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xlp.hex -D $tempnode"
7 SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0013", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xp2.hex -D $tempnode"
8 SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0015", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xse.hex -D $tempnode"

In /etc/udev/rules.d/52-digilent-usb.rules, 38 ATTRS{idVendor}=="1443", MODE:="666" 39 ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{manufacturer}=="Digilent", MODE="666", RUN+="/usr/local/sbin/dftdrvdtch %s{busnum} %s{devnum}"
You also need to create a third acl rule file to auto change the mode of the device. The one I created is named
1 ENV{MAJOR}=="", GOTO="acl_end"
2 ENV{ACL_MANAGE}=="0", GOTO="acl_end"
3 ACTION!="add|change", GOTO="acl_apply"
4
5 SUBSYSTEM=="usb", ATTRS{idVendor}=="03fd", ATTR{idProduct}=="0008", ENV{ACL_MANAGE}="1"
6
7 # apply ACL for all locally logged in users
8 LABEL="acl_apply", ENV{ACL_MANAGE}=="1", TEST=="/var/run/ConsoleKit/database", \
9 RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"
10
11 LABEL="acl_end"
12 #

Compile libusb-driver.so for Xilinx Tools

Download libusb-driver source files from git://git.zerfleddert.de/usb-driver
[tinghui.wang@localhost Downloads]$ git clone git://git.zerfleddert.de/usb-driver
Cloning into 'usb-driver'...
remote: Counting objects: 751, done.
remote: Compressing objects: 100% (525/525), done.
remote: Total 751 (delta 455), reused 412 (delta 226)
Receiving objects: 100% (751/751), 129.08 KiB | 117.00 KiB/s, done.
Resolving deltas: 100% (455/455), done.

Get into usb-driver folder. Run make to compile libusb-driver.so:
[tinghui.wang@localhost usb-driver]$ make cc -Wall -fPIC -DUSB_DRIVER_VERSION="\"2013-09-10 22:28:10\"" usb-driver.c xpcu.c parport.c config.c jtagmon.c -o libusb-driver.so -ldl -lusb -lpthread -shared parport.c: In function 'parport_transfer': parport.c:21:23: warning: variable 'last_pp_write' set but not used [-Wunused-but-set-variable] static unsigned char last_pp_write = 0; ^ cc -DDEBUG -Wall -fPIC -DUSB_DRIVER_VERSION="\"2013-09-10 22:28:10\"" usb-driver.c xpcu.c parport.c config.c jtagmon.c -o libusb-driver-DEBUG.so -ldl -lusb -lpthread -shared Built library is 64 bit. Run `make lib32' to build a 32 bit version [tinghui.wang@localhost usb-driver]$
Ignore all the warnings, and you will see libusb-driver.so under the folder.

Environment Settings

We need to use libusb-driver.so for iMPACT, so we specify LD_PRELOAD environment variable. You can do this in .bashrc environment setting file or export it before using iMPACT.
export LD_PRELOAD="~/Download/usb-driver/libusb-driver.so"

How-to Install Digilent Cable Driver for Xilinx Design Suite on Ubuntu 11.10

It has always been a problem to install cable driver for Xilinx Design Suite on Linux machines since the day I was introduced to Xilinx FPGA.

Recently, I received many questions concerning the installation, which matters libusb issues, kernel issues and permission problems.

So, I would like to write a detailed guide about the installation procedure.

 

Section I: The packages you need

The package you need before installation are list as follows:

1. libusb for your distribution

    for Ubuntu OS, you can install it with command:

          $ sudo apt-get install libusb

    for CentOS, Fedora, or RHEL, you can install with:

          $ sudo yum install libusb

2. Digilent Adept Runtime x32 / x64

     Digilent Adept Runtime package is available at website 
     http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,66,828&Prod=ADEPT2

     0001

      Chose the package according to your linux OS. If it’s a 32-bit OS, dowload Adept 2.8.2 Runtime x86 Linux. If it’s 64-bit kernel, download Adept 2.8.2 Runtime x64 Linux.

      The downloaded software package is wrapped in format .tar.gz.

3. Digilent Adept Utilities x32/x64

     Digilent Adept Utilities package is available at website  
     http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,66,828&Prod=ADEPT2

     0001

      Chose the package according to your linux OS. If it’s a 32-bit OS, dowload Adept 2.8.2 Utilities x86 Linux. If it’s 64-bit kernel, download Adept 2.8.2 Utilities x64 Linux.

      The downloaded software package is wrapped in format .tar.gz.

4. Digilent Plugins x32/64

      Download Digilent Plugin for Xilinx Design Suite if you want to download your bitstream from XPS, ISE or iMPACT directly and debug with SDK or Chipscope.

      Digilent Plugin is available at website

      http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,66,768&Prod=DIGILENT-PLUGIN

     0002

       Chose the package according to your linux OS. If it’s a 32-bit OS, dowload Adept 2.8.2 Utilities x86 Linux. If it’s 64-bit kernel, download Adept 2.8.2 Utilities x64 Linux.

        The downloaded software package is wrapped in format .tar.gz.

5. Xilinx Design Suite

     I believe you have already have the Xilinx Tools installed. But remember, do not ever install the cable driver provided inside Smile with tongue out

 

Section II: Installation

1. Decompress all packages.

    Let’s say all packages are stored under ~/Download (~ is the home directory under your login name, i.e. /home/<username>)

    As I installed ubuntu 11.10 x64 on my laptop, the packages I have are shown in the figure below:

    0003

    Decompress all packages with command “tar zxvf <filenames>”

    0004

2. Install Digilent Adept Runtime 2.8.2

     Enter directory digilent.adept.runtime_2.8.2-<platform>

     run command “$ sudo ./install.sh” and keep all default locations unchanged.

     * NOTE: If you are install on Ubuntu 11.10 or other recent distributions with kernel version >= 3.0 (verify it with command `uname –r`)
                      You need to add the following lines after line 209: cprocUdev=$ (ps –e | grep –I –c udevd)

209 cprocUdev=$(ps -e | grep -i -c udevd) 
210 
211 if [ "${szVmjr}" = "3" ] 
212 then 
213        if (( $cprocUdev )) 
214        then 
215               let fUseUdev=1 
216        fi 
217 fi

                      0005

     Here is the log:

[WangTH@localhost digilent.adept.runtime_2.8.2-x86_64]$ sudo ./install.sh
Adept Runtime Installer
64-bit operating system detected
In which directory should libraries be installed? [/usr/local/lib64/digilent/adept]
Installing runtime libraries…..
Successfully installed runtime libraries.
Installing system binaries…..
    installed "/usr/local/sbin/dftdrvdtch"
Successfully installed system binaries in "/usr/local/sbin".
Installing firmware images…..
Successfully installed firmware images in "/usr/local/share/digilent/data/firmware".
Installing JTSC device list…..
Successfully installed JTSC device list "/usr/local/share/digilent/data/jtscdvclist.txt".
Installing CoolRunner support files…..
Successfully installed CoolRunner support files in "/usr/local/share/digilent/data/xpla3".
Installing CoolRunner 2 support files…..
Successfully installed CoolRunner 2 support files in "/usr/local/share/digilent/data/xbr".
Installing Adept Runtime configuration…..
Successfully installed Adept Runtime configuration "/etc/digilent-adept.conf".
Installing USB UDEV rules…..
Successfully installed USB UDEV rules "/etc/udev/rules.d/52-digilent-usb.rules".
Installing dynamic loader configuration…..
Successfully installed dynamic loader configuration "/etc/ld.so.conf.d/digilent-adept-libraries.conf".
Successfully reloaded UDEV rules.

[WangTH@localhost digilent.adept.runtime_2.8.2-x86_64]$

3. Install Digilent Adept Utilities 2.8.2

     Enter directory digilent.adept.utilities_2.8.2-<platform>

     run command “$ sudo ./install.sh” and keep all default locations unchanged.

     Here is the installation log:

[WangTH@localhost digilent.adept.utilities_2.1.1-x86_64]$ sudo ./install.sh
[sudo] password for WangTH:
Adept Utilities Installer
64-bit operating system detected
In which directory should binaries be installed? [/usr/bin]
In which directory should manuals be installed? [/usr/local/man]
Installing binaries…..
    installed dadutil: "/usr/bin/dadutil"
    installed djtgcfg: "/usr/bin/djtgcfg"
Successfully installed binaries in "/usr/bin"
Installing manuals…..
    installed dadutil.1: "/usr/local/man/man1/dadutil.1"
    installed djtgcfg.1: "/usr/local/man/man1/djtgcfg.1"
Successfully installed manuals in "/usr/local/man"
Successfully installed Adept Utilities

4. Install Digilent Plugin for Xilinx Design Suites

    Enter directory libCseDigilent_2.0.5-<platform>

    Enter directory of the Xilinx DS version installed on your computer.

    For me, it was ISE13x, because I installed Xilinx DS 13.2

    There is a pdf under the folder named: Digilent_Plug-in_Xilinx_<versionNo>.pdf

    The document tells exactly how to install the Digilent Plugin and how to use it.

     To install plugin is quite easy, all you need to do is copy the libCseDigilent.so and libCseDigilent.xml to

     <Xilinx_DS_Path>/ISE/lib/lin64/plugins/Digilent/libCseDigilent/  (if 64-bit OS)

    or <Xilinx_DS_Path>/ISE/lib/lin/plugins/Digilent/libCseDigilent/ (if 32-bit OS)

    if there is no dir “Digilent” under <Xilinx_DS_Path>/ISE/lib/lin64/plugins/, just make a new dir with command mkdir.

    On my computer:

0006

Section III: Test and Troubleshoot

1. Connect your digilent board to your PC

     Test whether Adept utilities can recognize your board.

     All you need is to run the command “djtgcfg enum” and see whether your boards pop up.

2. Open iMPACT with command “impact&”

     See if any FPGA can be found on your JTAG chain.

(I will go on with this part later, good luck Smile with tongue out)