2009年12月21日 星期一

libopenh323 and libopal conflict

前陣子為了編譯 t38modem 所以需要 libopenh323 當作 library,(header files 需要 libopenh323-dev)
後來發現 the successor of OpenH323 project --- OPAL project (Open Phone Abstraction Library)
但是在 Debian sqeeze 上,這兩組有些衝突,原因是底層的 libpt 版本需求不同造成的,目前我沒有去解決(或強制把 "依賴" libpt-1.10.10 的部份以 libpt-2.6.5 取代,沒有試過不知道!)衝突關係如下列:

compile libopal-3.6.6 source get  from [ here ], needs libpt-2.6.5

libopal-3.6.6
depends on
libpt-2.6.5

header files in :
libopal-dev-3.6.6
depends on
libpt-dev-2.6.5-1


compile t38modem
needs
libopenh323-dev: /usr/share/openh323/openh323u.mak

libopenh323-dev
depends on
libpt-1.10.10-dev  <-- conflict libpt-dev-2.6.5-1
libopenh323-1.18
   

libopenh323-1.18
depends on
libpt-1.10.10 ← conflict libpt-2.6.5

結論:
所以目前 compile 使用 OpenH323 的 source 與使用 OPAL 的 source 無法同時 compile ,必需把相關的 libpt 重裝(一個用 2.6.5, 另一個用 1.10.10) #Technorati 標籤: , , , ,

2009年12月13日 星期日

Debian 升級 testing (sqeeze) 與 ATI X1450 的 driver 問題

Asus A8J 大約是兩三年前的華碩主流筆電之一,獨立顯卡採用  ATI X1450.
Debian Lenny 下有提供 ATI propietary driver (non-free) :
kernel driver(要 3D 加速,需要 kernel driver ) : fglrx-modules-2.6.26-* 等,driver source : fglrx-kernel-src
for openGL lib : fglrx-glx
根據這篇 [ arch linux ATI ] [ref 1] 知道,X1450 的 code name 為 (RV515, 即 r5xx  系列)

Debian 系統升級到  testing 後,kernel driver 套件變成 : fglrx-source , 且改為支援 r6xx-r7xx 而已,也就是說 ATI 官方 driver 不再支援 r5xx 系列,
但是這些不被支援的系列的 spec 已經  release 給 open source 社群。所以目前升級後的  xorg 7.4 裡面的  xserver-xorg-video-ati 套件,可以支援 r5xx 系列。
xorg.conf 已經不需要了,xorg 會自動偵測掛載  radeon driver。

glxgears 的數據為
1598 frames in 5.0 seconds = 319.450 FPS 
1613 frames in 5.0 seconds = 322.503 FPS  ( 本blog時間測)

6097 frames in 5.0 seconds = 1219.223 FPS 
6014 frames in 5.0 seconds = 1202.697 FPS  ( 2010年4月20測)

跟使用 ATI propietary ~1200 FPS 比較起來,稍稍等待 open source 社群是值得的,
時間會證明 open source community 提供的 code 效能,總會超越 propietary code 的,並且更穩定。
Technorati 標籤: , , ,

2009年12月7日 星期一

製作 beagle board kernel v2.6.29-58cf2f1

約四個月前,在網路上找到了一篇 [ building a customed kernel for beagle board ] ,但是事過境遷,該篇 blog 已經不存在。有位對岸的大哥把步驟給節錄下來了[ 制作beagleboard的kernel  ] ,為了避免以後有類似情形,這裡再節錄一遍過程:

Retrieve the GIT checkout:

    git clone git://git2.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git
    cd linux-omap-2.6/
    git checkout 58cf2f1 -b v2.6.29-58cf2f1
    git archive --format=tar --prefix=v2.6.29-58cf2f1/ v2.6.29-58cf2f1 | gzip > ../v2.6.29-58cf2f1.tar.gz
    git checkout master
    git branch v2.6.29-58cf2f1 -D
    cd ..

Download kernel diffs and kernel config:

    wget http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/v2.6.29-58cf2f1-oer34.diff
    wget http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/defconfig

Extract Kernel Source

    tar -xf v2.6.29-58cf2f1.tar.gz
    cd v2.6.29-58cf2f1/

Apply Patch

    patch -p1 < ../v2.6.29-58cf2f1-oer34.diff

Copy Defconfig

    cp ../defconfig .config

Configure the kernel (requires libncurses5-dev installed)

    make menuconfig

Build, Cross-Compiling:

    make CROSS_COMPILE=arm-linux-gnu- uImage

A few moments later, you can find your new kernel in the ‘arch/arm/boot/’ directory.

Make modules:

    make CROSS_COMPILE=arm-linux-gnu- modules

    make CROSS_COMPILE=arm-linux-gnu- modules_install


2009年12月3日 星期四

sparse type checking

因為 compiler 只能檢查 syntax.
Linus 為了檢查程式的 semantics ,創造出 sparse. 在 [ Linux Journal "Linus & Lunatics" ] 這篇文章提到了他當初的想法:

相關的 code 在 compiler.h 可以看得到 (kernel source 2.6.28 )

#ifdef __CHECKER__
# define __user        __attribute__((noderef, address_space(1)))
# define __kernel    /* default address space */
# define __safe        __attribute__((safe))
# define __force    __attribute__((force))
# define __nocast    __attribute__((nocast))
# define __iomem    __attribute__((noderef, address_space(2)))
# define __acquires(x)    __attribute__((context(x,0,1)))
# define __releases(x)    __attribute__((context(x,1,0)))
# define __acquire(x)    __context__(x,1)
# define __release(x)    __context__(x,-1)
# define __cond_lock(x,c)    ((c) ? ({ __acquire(x); 1; }) : 0)
extern void __chk_user_ptr(const volatile void __user *);
extern void __chk_io_ptr(const volatile void __iomem *);
#else
# define __user
# define __kernel
# define __safe
# define __force
# define __nocast
# define __iomem
# define __chk_user_ptr(x) (void)0
# define __chk_io_ptr(x) (void)0
# define __builtin_warning(x, y...) (1)
# define __acquires(x)
# define __releases(x)
# define __acquire(x) (void)0
# define __release(x) (void)0
# define __cond_lock(x,c) (c)
#endif

平常 gcc compile 時,不定義 __CHECKER__,所以這裡的許多 macros 就得到空定義 (程式碼 #else 部份)
那麼使用 sparse 時,就定義 __CHECKER__ ,(程式碼 #ifdef 部份) 舉例來說 第一行:

# define __user        __attribute__((noderef, address_space(1)))

使得 sparse 檢查 __user 定義的變數,是否落在 user space,例如用在 copy_to_user() :

unsigned long
copy_to_user(void __user *to, const void *from, unsigned long n)
{...}

compiler 是不會知道 "to" 的變數是不是正確!但是 sparse 檢查時,若發現 to 所指的不是在 user space 裡,就會發出 warning
因此這些 attributes 是給 sparse 用的,在 gcc 文件裡面查不到這些 attributes (是的,不要怪 gcc 文件寫不好...)

另外這篇 [ linux 內核中 compiler.h 文件的分析 ] 還解釋了 __acquire / __release 必須成對使用,否則 sparse 會發出 warning.

Linus 真神人也,可以讓 kernel source 藉由 sparse 工具來檢查 program semantic !!Technorati 標籤: ,

2009年11月25日 星期三

意外的快樂

出社會以來,因為家中經濟需要援助,一直都沒有存下甚麼錢。一直到了結婚,也就順勢把所有的收入交給了老婆,接著添了一個弟弟。所以有些年輕時候想要完成的夢,就一直擱著。排一排順序,大概是這樣:
1 最想變成 open source 的 hacker ,為某些 project 貢獻程式碼。當然,基本功還在練習,所以還沒到那個火侯可以當 hacker ...
2  一直想帶親愛的另一半,去美國玩。常出國的人,是不會理解這種渴望的...,有小朋友的父母,更是難排出時間與金錢(費用不訾啊...)
3. 希望有朝一日,圍棋可以上段。 這個夢想本來是四十歲的生日願望,結果沒有達成。因為要扛一家之計,很多時間需要支配到別處,也就擺著了。

承蒙老婆大人的體貼,跟圍棋老師約了時間,叫我去下指導棋。天啊,一對一耶!這可是有錢人才這樣玩吧!
本來想上完一堂,應付應付就好,不要讓圍棋老師以為咱們家老婆大人沒信用。
但是奇妙的心理變化發生了.....我整晚在棋院都好興奮我竟然有機會實現,十幾年來的夢想之一,老師說我有機會上段耶!!!

這是第一次 感覺到,我把錢拿來花在 "實現自己夢想" 上,好快樂!!!
這是第一次 體會到,老婆以前學鋼琴,說她很快樂,是甚麼滋味...
這是十年來第一次,覺得自己活得很有成就感
...

快樂的感覺,一直在心中徘迴,老婆大人,謝謝您!

2009年11月18日 星期三

Emacs 捲動的設定

Emacs 內定的捲動方式為一次半頁,這樣看起來跳動很大,有些不習慣。修改 .emacs 加入下面設定,可以變成『自然捲』...
(setq scroll-margin 0 scroll-conservatively 10000 )

另外,想定義新的 macro 並且紀錄於 .emacs 以供下次使用,可以這樣作,
(以 scroll other window (up/down) one line 這個動作為例) :

C-x (      定義新的 macro
M 1 C-M-v   我們的新 command --- scroll other window down one line
C-x )     結束 macro 定義

給它取一個名字:
M-x name-last-kbd-macro [Enter]
打入自取名稱 ,例如 scroll-other-window-down-one-line [Enter]

打開 ~/.emacs 準備加入這個新定義:
M-x insert-kbd-macro
打入剛剛取的名稱  scroll-other-window-down-one-line [Enter] 就會出現
(fset 'scroll-other-window-down-one-line
   "\261\226")
然後定義一個 hotkey 例如 F11 給它:
(define-key global-map [f11] 'scroll-other-window-down-one-line)

以後按 F11 就會 scroll down other window.

為了對稱,做了一個 scroll other window up one line ,最後在 .emacs 裡長成這樣:

...
(fset 'scroll-other-window-up-one-line
   "\2551\226")
(define-key global-map [M-f11] 'scroll-other-window-up-one-line)
(fset 'scroll-other-window-down-one-line
   "\261\226")
(define-key global-map [f11] 'scroll-other-window-down-one-line)
...

Technorati 標籤:

2009年11月13日 星期五

eclipse + CDT for C++ Development

這篇說明 eclipse 的設定,為了怕設定的部份翻譯不好,乾脆用英文寫...

Since `cscope + ecb + emacs' is my favorite development tool, there is no need for "eclipse", while not all people get used to `emacs' conveniently. Here we introduce another good IDE for C/C++ developemnt --- Eclipse !!

1. From [ http://www.eclipse.org/downloads/ ] download `Eclipse IDE for Java EE...' or `Eclipse IDE for Java...' or `Eclipse IDE for C/C++...', I download the eclipse-jee-galileo-linux-gtk.tar.gz  , extract,  then add path (where you untar eclipse ) to ~/.bashrc such that when I type `eclipse' command so that it can be brought up (Yes, its green software).

2. Install the CDT plugin : (If you use `Eclipse IDE for C/C++' , please skip this step)
In eclipse menu, goto (Help | Install New Software ...) then type this html page:
http://download.eclipse.org/tools/cdt/releases/galileo
(note : CDT need > eclipse 3.5 or up )
then update. The CDT component will then be installed.

3. Create C++ project :
In eclipse menu, goto "File | New | Project...|C++":
   a. Fill "Project Name".
   b. Select Makefile Project | Empty Project.  <--- yes, choose `Empty Project' for the external Makefile case !!
   c. Select Linux GCC at the right side.
   d. Press the "Finish" button.
then you have created an empty project in eclipse.

4. Import external sources/Makefile to project:
Right click on the project name, select "import...":
choose "General | File System" , click "Next" button, then "browse" to your source path, (of,course, you can filter out unnecessary files ) then press "Finish".

5. Goto "Project | properties| C/C++ Build", in the right "Build Location" field, press the "workspace" button, and given your project path , for e.g. ${workspace_loc:/test/home/tom/external_open_source}. (I was fooling around here for 6 hours --- before I learn to press the "workspace" button)

Then press "OK", the project will be built. But in our `external_open_source' project, we need use `make opt' as the building command ---goto "Project |Proties" , in "C/C++ Build",
a. select the "Behavior" tab,
b. uncheck "Build on resource save(Auot build)",
c. modify "Build (Incremental build)" to "opt",
d. then press "OK" to finish.

Now, you should build the `external_open_source'  sucessfully, instead of the 'No rule to make target `opt' error message !

ps. In Debian Lenny, make sure to use

$update-alternatives --config java

to configure your default java to `java-6(5)-sun' instead of `java-gcj' , the Eclipse will NOT start with `java-gcj' as the default java environment:

  Selection    Alternative
-----------------------------------------------
              1    /usr/bin/gij-4.3
              2    /usr/lib/jvm/java-gcj/jre/bin/java
*+          3    /usr/lib/jvm/java-6-sun/jre/bin/java

Press enter to keep the default[*], or type selection number: 3
 
Technorati 標籤: ,