January 21, 2007

Python2.5 Running on Zaurus

為了在上下班的旅程中可以有方便於實際練習python的工具,我決定重新重用被我冷落多時的小白。雖然帶著notebook功能齊全,但是它給我的負擔畢竟還是不適合長期依靠,看來只好將小白強化為python移動開發機這一途,才是根本之道。

我的小白: Zaurus SL-C3000 (kernel 2.4.20, 還沒改用OpenZaurus,僅將原廠的日文版換成英文板)

無聊的游戲開始,
先取得Zaurus的toolchain用來編譯小白版python.
依照該網頁的指示安裝完後,將toolchain的程式路徑加入PATH中。


# export PATH=$PATH:/opt/Embedix/tools/bin

下載Python2.5的source code之後, 我使用了難看的暴力手段,讓它不得不變成了小白的人。

先用下載來的Python-2.5.tar.bz2,依照它的指示編譯一份PC上使用的python執行檔並改名為python_x86。


解開壓縮檔


# tar xjvf Python-2.5.tar.bz2
# cd Python-2.5/

指定要放置最後暴力果實的目錄


# ./configure --prefix=/forZ

畢竟2.4核心的小白,還是舊了點,不得不稍做更動


# vi pyconfig.h:
-- #define HAVE_STAT_TV_NSEC 1
++ #undef HAVE_STAT_TV_NSEC

再將Makefile以及setup.py做些修改,然後將先前的python_x86放到Python-2.5/目錄中。
開始編譯


# cp Makefile.PythontoZaurus Makefile
# cp setup.py.Python25toZaurus setup.py
# cp ../../Python-2.5_x86/python_x86 ./
# make
# make install


好了沒錯,到此為止。正規的編譯動作其實還沒完成,我省略一些步驟,但是我要的已經到手了,不再纏鬥。如果還有你需要的東西沒編譯出來,就自己改makefile吧~

將forZ下的bin和lib壓成python25_zaurus.tgz,用任何小白會的傳輸方法,送到小白嘴裡。


# tar czvf python25_zaurus.tgz

在小白上執行Terminal程式得到一個shell,再依序完成下面的指示,


# su
# cd /hdd2/usr
# tar xzvf /home/zaurus/Documents/python25_zaurus.tgz
# exit

python需要一些對小白的指引


# vi /home/zaurus/.bashrc
++ PYTHONHOME=/usr/
++ export PYTHONHOME

# source ~/.bashrc


好了,小白現在起擁有python開發的無限潛能,正式升格為python移動開發機!


# python
Python 2.5 (r25:51908, Jan 21 2007, 11:13:10)
[GCC 2.95.2 19991024 (release)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>


Python2.5 Running on Zaurus Quick Guide:
================================
I'm a python newbie, try to porting python2.5 to my Zaurus SL3000 for my learning.


** Download toolchain for Zaurus:
To get toolchain from here, following its instructions.
** Download python2.5:
To get source code of python2.5 from here

To build a python for x86 PC, and rename it as python_x86.

Now start to build python for Zaurus:


# export PATH=$PATH:/opt/Embedix/tools/bin
# tar xjvf Python-2.5.tar.bz2
# cd Python-2.5/
# ./configure --prefix=/forZ
# cp ../Python-2.5_x86/python_x86 ./
# vi pyconfig.h:
-- #define HAVE_STAT_TV_NSEC 1
++ #undef HAVE_STAT_TV_NSEC

** Download Makefileandsetup.pythat modified by me and start to compile it.


# cp Makefile.PythontoZaurus Makefile
# cp setup.py.Python25toZaurus setup.py
# make
# make install
# cd /forZ
# tar czvf python25_zaurus.tgz bin lib


I do not fix all compiling errors and do not finish all orignal compiling work, so something may be lost, I'm not sure. It just enough for me study python on Zaurus...:)

** USB connect to Zaurus, and copy python25_zaurus.tgz to Zaurus.
** open a Terminal on Zaurus.


# su
# cd /hdd2/usr
# tar xzvf /home/zaurus/Documents/python25_zaurus.tgz
# exit
# vi /home/zaurus/.bashrc
++ PYTHONHOME=/usr/
++ export PYTHONHOME
# source ~/.bashrc
# python

Posted by ThomasC at January 21, 2007 11:22 PM |[ Python , Zaurus ]
Comments

Hi Thomas,
I love the characters : are they Japanese, Korean, Chinese ? I'd like to try to learn them (probably it will take a while...
Thanks for Zaurus2python process description.
So long,
jm

Posted by: jean-michel on January 23, 2007 03:21 PM

Works also on a SL-5500G. Cool!

Posted by: Thomas Heller on January 25, 2007 06:36 PM

原來小白被冷落了那麼久....
小白來自秋葉原耶~~外型還不錯看說^^

Posted by: 小老弟^^ on January 25, 2007 11:01 PM

Enjoy beautiful Traditional Chinese word, and
Enjoy Python running on your Zaurus!

me too.

Posted by: ThomasC on January 26, 2007 08:14 AM
Post a comment