Sunday, July 29, 2007

Low Power Design -- Lesson 1

Lesson 1: Low-power overview:
Low power design is an increasingly common technique help reduce power dissipation in complex SOCs/ASIC. Power consumption on the chip is consumed both when the circuit is active (dynamic power) and also when it is inactive (static power).
+ Dynamic power is associated by switching of state on nets and cells. Dynamic power is absoluted by switching-frequency, load-capacitance and square of supply voltage:
P(dynamic) = a x F x C x sqr(Vdd)

+ Static power is referred to leakage power. Leakage power consumption is computed by sub-threshold leakage, gate leakage and reverse-bias junction BTBT leakage. For a particular technology process, the gate leakage and reverse-bias leakage are constant. therefore, the leakage current from Drain to Source (into a CMOS-transitor) is defined as static-power consumption:

P(static) = exp (-q x Vth / KT), Vth is threshold-voltage of gate.

So, I think we should learn how the gate delay are computed. The cell delay associated with a transistor is affected by the switching threshold voltage (Vth) and the supply voltage (Vdd):

Delay = Vdd x sqr [(Vdd - Vt), *a]

The high-speed cell delay is reference with lower threshold-voltage and higher supply-voltage. Now a day, when cmos process is scaling down to 65nm and below, the leakage consumption is 40 percent of total power-consumption.

Nokia 工模代码

1. 显示IMEL号 *#06#
2. 显示软件版本: *#0000# 第一行--软件版本;第二行--软件发布日期;第三行--手机型号
3. 显示通话时间: *#92702689#
4. 激活EFR模式:*3370# (全速增强型编码模式,可改善话音质量但会耗电)
5. 关闭EFR模式:#3370#
6. 激活HR模式: *4720# (半速模式,通话质量变低,但是大大延长电池使用时间,需要网络支持
7. 关闭HR模式:#4720#
8. 检查SIM卡自带的时钟是否可被关闭:*#724025625# 本来是 *#sim0clock# 之意
9. 手机电子钱包解密: #7370925538#

Use Google Linux repositories in Debian

Google’s Linux software repositories make it easier to download and stay up-to-date with current releases of Google Linux applications. Please choose one of the guides below to help configure your system to use these repositories.

First you need to edit /etc/apt/sources.list file

#emacs /etc/apt/sources.list

add the following line

# Google software repository

deb stable non-free

Save and exit the file

you must download the key and then use apt to install it and refresh your package indexes.

Run these commands as root:

#wget -q -O - | apt-key add -

Now you need to update the source list using the following command

#apt-get update

Install google applications now you can see the following command to install google picasa

#apt-get install picasa

Saturday, July 28, 2007


In Breezy(5.10), laptops with a synaptics touchpad should work out of the box. Go to a terminal and grep (look inside) your /etc/X11/xorg.conf file:

grep Id /etc/X11/xorg.conf

If one of the lines is:

Identifier "Synaptics Touchpad"

then you have a Synaptics Touchpad.

In Dapper flight 7 (6.06) and Edgy (6.10) , synaptics touchpads seem to be misdetected as some kind of wacom device, so the scrollbar may not work. See - "Editing Your xorg.conf File to Include Synaptics Touchpad drivers" - for scrollbar support.

qsynaptics (or in KDE ksynaptics) is a GUI which allows you to configure your touchpad. At a terminal, enter:

sudo apt-get install qsynaptics


sudo apt-get install ksynaptics

You may need to run qsynaptics -r each time you restart X. Go to System>Preferences>Sessions>Startup Programs> and add it.
Dapper: Editing Your xorg.conf File to Include Synaptics Touchpad

In order to get scrollbar support, you may need to edit your xorg.conf file. In a terminal, type: gksudo gedit /etc/X11/xorg.conf After the lines:

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ExplorerPS/2"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "true"

add the following:

Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "HorizScrollDelta" "0"
Option "SHMConfig" "on"

there are also a bunch of lines about a wacom tablet, I have commented them out, I am not sure if that is a necessary step. -brallan

next, find the bit near the bottom where it says:

Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "stylus" "SendCoreEvents"
InputDevice "cursor" "SendCoreEvents"
InputDevice "eraser" "SendCoreEvents"

and add the following line after the "Configured Mouse" line:

InputDevice "Synaptics Touchpad"

i also commented out the three lines about the wacom: "stylus", "cursor", and "eraser", but I am not sure if this is necessary. -brallan.

restart X: and you should now have scrollbar support. Install qsynaptics for fine control over the device.
Turning Synaptics Touchpads On/Off with a shortcut key

You may wish to turn the touchpad on or off so that it doesn't interfere with typing when using a USB or other mouse.

Use following steps:

Step 1

from a terminal, edit /etc/xorg.conf

gksudo gedit /etc/X11/xorg.conf

and look for the following section of code:

Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "HorizScrollDelta" "0"

and add one more Option at the End of the Section:

Option "SHMConfig" "on"

If you are using an Alps-Touchpad, which you can find out by typing

cat /proc/bus/input/devices

your code section should look like this

Section "InputDevice"
Driver "synaptics"
Identifier "TouchPad"
Option "SendCoreEvents" "true"
Option "Device" "/dev/input/event2"
Option "Protocol" "event"
Option "SHMConfig" "on"

You can define some parameters which influence the behaviour of your touchpad. These parameters are presented already in [WWW] You can check if your touchpad works correct and you have the correct parameters with

synclient -m l

If everything works fine, the position of your finger will be updated everytime you move it and based on this information you can set your parameters.

Step 2

Next we will create 3 files - a bash script to turn the touchpad on, one to turn it on, and a python script to use a single key combination for both. At a terminal, cd to /usr/local/bin and make a new file:

cd /usr/local/bin
gksudo gedit tpoff

and paste the following code in the file, save it and close it.


synclient touchpadoff=1

again, make a new file:

gksudo gedit tpon

paste the following, save and close:


synclient touchpadoff=0

once again, make a new file:

gksudo gedit

paste the following, save and close

import os
import string

def ReadFile():
myfile = open('/tmp/synclient.tmp', 'rb')
for line in myfile:

def TestString(string):
for word in string.split():
if word == "TouchpadOff":
setting = string.split()

def ChangeState(current):
if current == "0":
os.system("synclient touchpadoff=1")
os.system("synclient touchpadoff=0")
os.system("rm /tmp/synclient.tmp")

def Main():
os.system("synclient -l > /tmp/synclient.tmp")

and finally, change the permissions of these three files:

sudo chmod 777 tpon tpoff

Step 3

Next, edit your sudoers files to allow you to execute both scripts without a password.

sudo visudo

and add this line

{user} ALL = NOPASSWD: /usr/local/bin/

where {user} is your user name

save (in nano hit ), and make sure to save it as: /etc/sudoers and not /etc/sudoers.tmp

Step 4

Alternatively to setup bellow, you might use [WWW] gnome-keybindings(In depth instructions, 4.) or other desktop-dependent tool.

Next, install xbindkeys

sudo apt-get install xbindkeys

when it's done, install xbindkeys-config, the GUI for xbindkeys

sudo apt-get install xbindkeys-config

once each is installed, start both applications:




edit your file to the shortcut key you want. For example, to be able to switch the touchpad on/off by , fill in the following, under Edit:

Name: Touchpad On/Off Key: Control + F5 | m:0x4 + c:71 Action: /usr/local/bin/

then click apply & save & exit

Now that that is done, restart xbindkeys:


You may need to restart X.

Remember that each time you restart X, you will need to run xbindkeys again in order for the shortcut to work. Go to System>Preferences>Sessions>Startup Programs> click add type xbindkeys then click ok.

Compressing VNC Connections over SSH (vncviewer -via)

You might remember a recent tutorial I did on securing VNC via SSH with the -via
option of vncviewer. Today I started looking into it more with one of
my students and we wanted to make the -via option use compression. By
default it just creates a basic tunnel with SSH and doesn’t let you get
much more specific. We figured out how to make it follow more specific

update: the environment variable is valid in vncviewer version 4.1.2, but apparently not in Feisty’s current version, 3.3.7. Solution 1 applies to Ubuntu, Solution 2 does not apply to Ubuntu (successful on RHEL5 and most likely recent Fedora series)

Solution 1:

vncviewer will look to client-side configuration files for its
settings. You can create a ~/.ssh/config file for any of your ssh
connections and, which might look like this:

Host alias

HostName hostname

Compression yes

User username

…you get the idea. This will connect to the HostName value when you
“ssh alias”, using Compression and the User specified. You can use any
valid ssh value in this config (see man ssh). Using client-side
configuration like this can cut a long ssh configuration down to a much
shorter one. ie;

The vncviewer will look for this file when used in combination with the -via switch and use compression if set to on, as above. Test it with and without the Compression value and see if you find a difference in performance.

Solution 2:

vncviewer uses an environment variable to start an ssh connection. By default it looks like:

VNC_VIA_CMD=/usr/bin/ssh -f -L “$L”:”$H”:”$R” “$G” sleep 20

You can find this using one of the following:

env | grep VNC_VIA_CMD


strings /usr/bin/vncviewer | grep ssh

The second method of altering it’s connection settings are to update
this environment value and tell it to use Compression. This would be
done using the following:

export VNC_VIA_CMD=’/usr/bin/ssh -C -f -L “$L”:”$H”:”$R” “$G” sleep 20′

(that uses single quotes around the entire value and double quotes on the embedded values. This is important.)

So, if you do a lot of work with VNC I hope you’re using the -via
option for SSH tunneling. Now you can also compress your connection
for better performance on slower networks. What are your results
here? Do you notice much of a difference? I have only tested this on
a LAN so the speeds are fast in the first place. Anyone want to share
their results out over the public interweb?

Powered by ScribeFire.

Vim Tip of The Week : +[num] or +/{pat}

First let me start of by saying that if you haven’t yet taken the
plunge to use vi/vim you really should. This editor will take you to
levels of efficiency that you’ve only dreamed of, and probably beyond.
Seriously, take the time to teach yourself some vim tips.

You might want to read a few of my previous posts on vim.

How to pwn your text files with vim

Find and replace with vim

Vim : the ultimate editor

..and for those that want something more, let’s talk a bit about the
+[num] and +/{pat} options when launching vim. These options will let
you begin editing on a certain line number (+[num]) or at an instance
of a certain pattern (+/{pat}). Let me show you a few examples.

If you’d like to begin editing a file on line 45 you could launch vim using a command such as:

vim file +45

If you’d like to begin editing at the last line in the file you could use +[num] without assigning a value:

vim file +

This option is really helpful for things such as trying to fix code
or fixing syntax errors in configuration files. If the log displays
the line number you could jump right to the line as you open the file.
…and you thought the :[num] option was convenient!

vim file +185, vim file +2, vim file +823, etc.. simple ways to begin editing at a certain point.

The +/{pat} option lets you begin editing at the first occurrence of
a certain pattern. This means instead of opening the file and
beginning your search function you can use the search as you open vim.
Some examples:

vim +/foo, vim +/bar, vim +/baz

You can use the :help search-pattern within vim to see available search patterns.

Anyway, I thought I would share this little tidbit of
vim-awesomeness today. Hopefully I can continue to do a vim tip of the
week. Would the faithful readers like that? Would you like more
advanced vim options? Simpler tutorials? Are you happy with gedit and
kate and don’t even want to bother? Let me know, I’ll do my best to

Powered by ScribeFire.

Disabling the F10 Key (menu accelerators) in Gnome Terminal

To disable the F10 “feature” in gnome-terminal you have two options. I’ll outline both.

The first option is to open the gnome-terminal and select “Edit” from the File menu, and then select “Keyboard Shortcuts”.

Within the next window check the boxes for:

Disable all menu access keys (such as Alt-f to open File menu)

Disable menu shortcut key (F10 by default)

At this point the changes should be available and the F10 key should be unused by gnome-terminal.

For the second option, you’ll need to launch the gconf-editor. You can do this like so:

press ALT-F2. This will open the “Run Application” dialog box for gnome.

In the field provided type “gconf-editor” and hit ENTER.

Well then need to navigate our way to the following two addresses to change what the default value may be.



What these paths mean, if it isn’t clear, is to navigate on the
left-side column to “apps” > “gnome-terminal” > “global” and find
the check boxes for “use_menu_accelerators” and “use_mnemonics”.

In my testing you may need to uncheck both of them for the change to
work. The change should be immediate. The F10 key should now be
available for use in htop and other similar applications that try to
bind the F10 key but are unable because the focus is stolen by

Powered by ScribeFire.

Vim Tip of the Week : SHIFT-K