Tuesday, October 03, 2017

arm cross compiler from Ubuntu apt

I've been doing cross compiling for a while and usually I would download the Code Sourcery from Mentor Graphics or the opens source arm-linux-gnueabi compiler or the one from Yocto.  I just noticed there is an eabi compiler in Ubuntu Linux (as of today's Ubuntu Xenial 16.04)
$ sudo apt-get install gcc-arm-linux-gnueabi 
$ sudo apt-get install gcc-arm-linux-gnueabihf 

This comes handy!

Wednesday, August 16, 2017


It took me a while to understand what is LLVM so I gave it a tried. It turns out... basically in layman's term it's a compiler like gcc

I went to their website and downloaded a lot of stuff.. then figured out that in Ubuntu you can try clang (which is the LLVM compiler in Ubuntu) with a single command:
$ sudo apt-get install llvm
So if you really don't want to use gcc like everyone else... then you should use LLVM..   sounds cool?

Sunday, June 11, 2017

Ubuntu Trusty userspace command to put system to suspend

Below is the Ubuntu Trusty userspace command to put system to suspend.
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Put the above command into the keyboard shortcut can immediately put your desktop to sleep upon entering the shortcut key.

Friday, March 24, 2017

vi indents consist of 4 space characters instead of tab

put the following line to .vimrc for indents that consist of 4 space characters but are entered with the tab key
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab

The width of a hard tabstop measured in "spaces" -- effectively the (maximum) width of an actual tab character.


The size of an "indent". It's also measured in spaces, so if your code base indents with tab characters then you want shiftwidth to equal the number of tab characters times tabstop. This is also used by things like the =, > and < commands.


Setting this to a non-zero value other than tabstop will make the tab key (in insert mode) insert a combination of spaces (and possibly tabs) to simulate tab stops at this width.


Enabling this will make the tab key (in insert mode) insert spaces instead of tab characters. This also affects the behavior of the retab command.


Enabling this will make the tab key (in insert mode) insert spaces or tabs to go to the next indent of the next tabstop when the cursor is at the beginning of a line (i.e. the only preceding characters are whitespace).

Monday, March 13, 2017

An engineer's value

An engineers's value is not defined by one's education level, but defined as a product of one's ability to solve problems and skills to make one's boss happy.

$ = solve problem * boss's happiness

Tuesday, February 28, 2017

I frequently work on my source trees which is managed by git version control.  For many times I worked on several files then I figured I was working on the incorrect checkout.   Then I found out git provides some bash scripts which helps to auto complete your branch name and show the current branch name in the bash prompt (PS1).

However, in the git appendix A it shows a very ugly PS1 script.  I like my original bash PS1 with the branch name and auto-complete, followed by the brach name in bright color.   I paste my code here to remind myself and hopefully can help other people whom want to do the same.

  1. Download git-completion.bash from git source code.  This file auto complete(using <tab> key) your branch name in your bash prompt:
    $ wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
  2. Download git-prompt.sh . This script shows your current branch name:
    $ wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
  3. $ source git-completion.bash
    $ source git-prompt.sh
    $ export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\[\e[96m\]$(__git_ps1 "(%s)")\[\e[0m\]\$ '

Then it should turn PS1 like my prompt below:

To include the above scripts everytime you start your bash, change your .bashrc.   I put the following lines to my .bashrc
source ~/.git-completion.bash
source ~/.git-prompt.sh
# PS1 with git (line wrap issue fixed!!)
export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\[\e[96m\]$(__git_ps1 "(%s)")\[\e[0m\]\$ '
As a note, in Bash, the <Esc> character can be expressed with the following syntaxes:

  • \e
  • \033
  • \x1B

For example, \e[31m shows the following characters in Red color.  The ”\e[0m” sequence removes all attributes which can be used end the bash coloring.  However, these <Esc> and color characters breaks the bash windone line wrap counts.  That is why you need \[ and \] to state to bash that those are non-printing characters.

Yes those are not for human.... and if you understand what I said.... get a life!



Friday, February 24, 2017

xhost+ Fix “Cannot Open Display” Error

The below commands will let you do xforwording with good speed, but very poor security.  Recommended to use this only in a trusted network.

Allow clients to connect from any host
$ xhost +

Enable X11 forwarding
$ ssh username@hostname -X

Wednesday, December 14, 2016

Gazebo in web browser


Gzweb is installed on the server-side. Once the server is set up and running, clients can interact with the simulation simply by accessing the server's URL on a web browser.

It's pretty cool.  Try it!

Ubuntu 14.04 (Trusty) Remote Desktop using x11vnc


Remote desktop between Windows 7 (TightVNC client) and Ubuntu 14.04 (Trusty) -sharing the monitor and mouse (similar to remote desktop but quicker)

In Ubuntu:
$ sudo apt-get install x11vnc
$ x11vnc -display :0

In Windows (TightVNC client)
- same as other VNC connection.

listing TightVNC server and kill them

By default, TightVNC launches a default session listening on port 5901.  You can use the following command to display how many vncserver you've started and kill them by display number:

$ netstat -plant | grep vnc
$ vncserver -kill :1
Other alternatives of VNC clients are:

  • TigerVNC -http://tigervnc.org/
  • UltraVNC - http://www.uvnc.com/