2008年11月3日 星期一

心目中的 Linux development 課程建議

早上讀了一封某國立大學資訊系教授的信,百感交集。也不想評論些什麼…
就說說自已的想法罷了
我個人覺得,一個活在 AC 2008 Embedded GNU/Linux Software Developer 要會以下一些東西。
我認為…這只是基礎。這些會了,再來談創意…
光是空想,手上沒有工具,或是有工具不會用…只是白搭。

技術方面
* C programming
-- study forever...
-- Learning how to tracing code - Learning from the master

* Shell programming
-- Bash & awk & sed & grep & diff & patch
-- Python | Perl | Ruby

* Software testing
-- smoke test
-- boundary test
-- stress test
...

* cross toolchain.
-- Static link & Share Library
-- ABI
-- Dependency tree
-- How kernel execute programs & ELF study

* SCM
-- git
-- svn
-- cvs
-- patch
---- quilt

* Distribution structure
-- How system boots
-- Build a distribution from scratch

* Misc tools
-- gdb
-- valgrind
-- gprof
-- gcov
-- doxygen
-- autotools

文化方面
* Mailing List
* Bugzilla
* Hacker ethics
* IRC
* English
* Eat your dog food
* Coding style
* Knowledge management skill - search & skip

很明顯以上不是一門課就可以上完的,不過可以分散在幾門課之中。
0. 計概
1. OS
2. C programming
3. System programming
4. XXX 專題

作為:
. 老師自已開始始用 GNU/Linux or any Unix like system 把自已丟進 FOSS 的世界…會更有 fu

. 鼓勵學生在大一時,就學習用 GNU/Linux,以及使用公開格式文件。
學校為什麼要為 MS 做免費的廣告呢?
要求學生使用不是每個人都買得起的東西,使用不公開格式的文件…
這是不道德也不經濟的。
學生也可以真正的體會 FOSS 的文化,有興趣的人還可以真正深入了解系統的運作。

. 要求學生使用 gpg keys 以及使用 ssh key

. 作業用 git+ssh 繳交…

. 教導學生使用 Unix 下的一些超級工具
-- 一旦學會了…一輩子受益。可惜…很多老師自已不會,學一下吧。 ~>_<~

. 要求學生加入有名的 open source 的專案,成為期中作業。(以 commit log 為準)

. OS 課程之中,指派學生 Trace Linux kernel code ,對照 textbook 內容,且 present 給大家,作為作業。

. Algorithm 課程中,指派學生 Trace glibc | stdc | stdc++ | java library code ,使用,且學習用它們的 API 自已 cleanroom 一個出來,用 test framwork 來測。

. C programming 中,學生的每個程式作業,都要擺出 autotools 的架式,以及使用 doxygen 產生文件 (或不同工具)

. RTFM, 選一些重要的 manual 叫學生讀,學會讀文件和學會讀 code 是一樣重要的。

. 出幾題如 pythonchallenge 之類的上機作業給學生…

. 要求程式作業要先交 .h 檔,先上 git

. 鼓勵學生訂 mailing list, 為課程開 mailing list,在上面討論課程和作業

. 老師也要學習新把戲 ;-) 如果您在教 GNU/Linux development 而上面的任何 Item 不清楚的話,或不了解怎麼做的話…也許要再 update 一下您的 knowledge 了。

基礎很重要。手中有工具,才能玩遊戲。

小弟其實懂得不多,每天也還忙著學新東西,不過看完了某教授的信後,心裏是這麼想的。

2008年10月30日 星期四

Neo 機器人

月初從朋友那拿了一個控制 servo 的 LSC chip,以及一雙由 servo 組成的腳…
就在想,能不能拿 Neo 來做機器人呢?

Neo 上有兩個 g-sensor ,GPS chip,2.5G GSM chip, bluetooth,還有 wifi…
如果它能動…那會有多可怕… 拿它來開船、開飛機。可用 bluetooth wifi 和 GSM 來遙控…
應該會是一個很好玩的東西…

為了可以在 Neo 上能快快樂樂的玩 servo ,我開了個小案子:LSCD

把 servo 的 driver 寫好,再寫一個 python-binding... 就可以快快樂樂的玩了

liblscd 是控制 chip 的 API 可讀寫每個servo 的角度和速度。
pylsc 是 liblscd 的 python binding
在 tests 中還有一個 robot.py ,可以用來控制由 servo 組合而成的 robot...
未來想把 pylsc 寫成 freesmartphone 的一個 service 如此就可以和 phone event manager 整合在一起… (感覺起來可以做很多壞事 :P )


怎麼玩呢?
1. kernel 要有 HIDDEV drvier (Debian default 有,Ubuntu 沒有), Neo 從今天開始的 stable kernel 就會有 :P

2.1 在 laptop 上玩:
a. 安裝 gcc python cython pyrex python2.5-dev intltool libgettextpo-dev libtool automake autoconf make subversion
b. > svn checkout http://lscd.googlecode.com/svn/trunk/ lscd
c. > cd lscd
> ./autogen.sh
> make
> sudo make install
d. 接上 LSC device, sudo chmod 777 /dev/usb/hiddev0
e. 就可以進 test 來玩 robot.py 了
2.2 在 Neo 上玩
a. wget http://lscd.googlecode.com/files/liblscd0_armv4t.opk
b. opkg install
liblscd0_armv4t.opk
c. 用 wifi or bluetooth 連進Neo
http://wiki.openmoko.org/wiki/Wifi

http://wiki.openmoko.org/wiki/Manually_using_Bluetooth#Bluetooth_networking_with_a_Linux_system
d. 把 usb 切到 host mode http://wiki.openmoko.org/wiki/USB_host#Selecting_USB_host_modes
e. 接上 LSC device (要有一個 mini 公 <----> USB B公的線, 可以用組合的)
example:
(mini公 <--> A 公 | A 母 <--> A 母 | A公<-->B 公)
f. 就可以玩了 ^_^

除了接線外…一切都可寫成 script :P




2008年10月23日 星期四

kernel indent 備忘

indent -kr -i8 -ts8 -sob -l80 -ss -bs -ps1

也可以看 scripts/Lindent

2008年9月10日 星期三

Share Screen 備忘

Screen 是一個很古老又好用的工具,雖然自已不是很常用…不過有時在幫別人做一些事情時,我們可以用 screen 的 share 功能,多人同時使用同一個 screen。在 demo,教學上實在蠻方便的。
很久之前有在用,不過一陣子沒用後就忘了,寫下來以免自已又忘掉。

1. sudo chmod u+s /usr/bin/screen
2. sudo chmod 755 /var/run/screen
3. screen
4.在另一個 terminal 上 screen -x

如要多人 share

1. ^a + :multiuser on
2. ^a + :acladd

3. 另一個人就可以 screen -x /[pid] 連上去

2008年7月30日 星期三

Using git-svn migrate svn repository server

Suppose we create a project on one SVN repository server say A, however that server is going to close and disappear. And we still want to develop that project. So we found another repository server say B as our new host. However if we cannot use svnadmin commit on server B.(if you can you can use this) How do we migrate?

git-svn gives us a chance to do such thing.

Now we have server A and want to migrate project to server B.

support you are in /tmp
1. git-svn clone svn://server_A/my_project my_project_from_A
2. git clone file:///tmp/my_project_from_A my_project_sent_to_B
3. cd my_project_sent_to_B
4. git-svn init svn+ssh://whoyouare@server_B/my_project
(Here svn://server_B/my_project should be empty, make sure you can commit)
5. git-svn fetch
6. git-svn set-tree [the very first one commit in master]
note:1
7. git-svn dcommit
Done, Happy hacking...

Step 1: clone the svn log from old repository (let it read only)
Step 2: does not clone the svn infomation in server_A, so that we will have a clean space to do the hack
Step 4, 5: get the information from Server_B and get the initial point

Step 6: push the very first one commit in master to server B svn
Step 7: commit the whole tree to server B

Combining these skills actually you can migrate/convert/clone many kinds of SCM.

extension reading:GIT first SVN later
Note 1:If you meet
CONFLICT (delete/modify): XXXX deleted in HEAD and modified in adding License declare. Version adding License declare or XXXX left in tree.

you can
git status
then
git add (those unmerged files/directories)
git rebase --continue

2008年7月17日 星期四

Easy Sample to create ipk files

step 1. ceate 2 new temp dirs say "_ipkg_temp" "_ipkg_tar"
step 2. use _ipkg_temp as root directory put your stuff there:
for example:
usr/bin/lala.sh
step 3. pushd _ipkg_temp; tar -czf ../ipkg_tar/data.tar.gz .; rm -rf * ; popd
step 4. create control file in _ipkg_temp
fill the following fields: (CONTROL="control")
        echo "Package: Your_package_name"   >  ${CONTROL}
echo "Version: 0.1" >> ${CONTROL}
echo "Description: your_descriptions">> ${CONTROL}
echo "Section: base" >> ${CONTROL}
echo "Priority: optional" >> ${CONTROL}
echo "Maintainer: Noname" >> ${CONTROL}
echo "Architecture: all" >> ${CONTROL}
echo "Homepage: http://ooo.xxx.vvv/svn/trunk" >> ${CONTROL}
echo "Tags: group::unknown" >> ${CONTROL}
echo "Depends: ooxxooxx" >> ${CONTROL}
echo "Source: http://ooxxooxx.ooxx.vvvoo/" >> ${CONTROL}
then tar -czf ../_ipkg_tar/control.tar.gz .
step 5. in _ipkg_tar create debian-binary file contents 2.0
echo "2.0" > debian-binary
step 6. in _ipkg_tar ar the ipkg file
ar -crf ooxx_0.1_arm.ipkg debian-binary data.tar.gz control.tar.gz

Done :-)

reference http://code.google.com/p/comic-reader/source/browse/trunk/packer/pack_eet2ipk.sh

2008年7月3日 星期四

Icescream

和大家分享一個好物: ICE SCREAM



它是一個分散式的 compiler 架構…
在Debian 和 Ubuntu 下相當好安裝… 只要
sudo aptitude install icecc icecc-monitor
然後
export PATH=/usr/lib/icecc/bin:$PATH
就好了

在同一個網域下,把一台機器設成 scheduler (一台就好)
cat /etc/default/icecc
# Defaults for icecc initscript
# sourced by /etc/init.d/icecc
START_ICECC="true"
START_ICECC_SCHEDULER="false"

把 false 改成 true
sudo /etc/init.d/icecc restart
一切就搞定了…

今天下午用了 10 台 4 CPU 的機器玩了一下 compile qtopia
make -j 20
本來要一個 CPU 要compile 快兩個小時的東西,十幾分鐘就搞定了。

^_^