ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2009年2月26日 星期四

AndroidFanatic - News and Forume

有關 Android 網站。 有人在這個網站的討論區 po 出在Android 上 install debian 系統,和 xfce 環境AndroidFantaic (為什麼不是 Fantastic ?) .

2009年2月25日 星期三

mplayer -vo caca : play video on console

想試試 -vo caca 這個選項,結果 debian 的 mplayer 不會動,說是 audio enable 不起來。 所以拿 source code build 一下.. build mplayer 還蠻容易的.. ./configure --help ./configure --enable-caca ./make 就可以了 (沒有 install,因為會install 到 /var..)。 本來想 enable debug 來看一下哪裡 fail,結果,這樣就可以 run 了 :) -vo caca 還蠻有趣的, console mode player. 但是..用 ssh 連線會閃動。 還有我真的關掉 X (/etc/init.d/gdm stop) run 的話,也會閃。 大概是解析度不對吧... mplayer 網站說,只提供 svn : ,而且永遠不提供 http:/ 的 svn checkout 喔。 ..像這樣的software 一多,我們這種在firewall 後面的就完蛋了.

2009年2月16日 星期一

ARM GCC Inline Assembler

翻譯這一篇 : arm gcc inline assembler cookbok 但是這一篇(GCC-inline assembly Howto)說得比較仔細。 GCC 的 inline assembly 基本格式是:
  asm(code : output operand list : input operand list : clobber list);
也就是一堆用 ':'分開的字串。 其中 'code' 的部份要存取 output operand list , input operand 的內容,是用 % 符號:
 %0 代表存取 output operand
%1 代表存去 input operand
最後的'clobber' 是要告訴 compiler 有哪些 register 被這段 assembly code 修改了。
為了防止 compiler 把這一段 inline assembly code optimize 掉,通常都會加上 volatilr:
 asm voltaile("mov %0, ror #01" : "-r" (result) : "r" (value));
這段 inline assembly,如果之後的部份都沒有資料,就可以不寫,舉例來說:
 asm volatile("mov r0, r0");
這只是用來delay的code,沒有input, output,也沒有 register 會被修改,所以後面的 部份都不用寫。 但是如果有資料一定要寫,他的前面部份就不可以省略,舉例來說:
 asm volatile("" : : : "memory");
這段inline assembly 不包含任何 code,只是告訴 compiler memory 有可能會被修改。 一般為了好看,建議將一堆 assembly 寫成這樣:
 asm volatile(
"mov r0,r0\n\t"
"mov r0,r0\n\t"
"mov r0,r0\n\t"
);
也就是說,分行寫,但是要記得加上 "\n\t" - 這是要讓 compiler listing 時,比較好看。 Input Output Operand 這兩個區域是要告訴 compiler operand 的資料,利用以下 "Constraint" 來通知: Operand Register 的類型:
  • f : 是floating point register (有些 cpu 有專屬的 floating point register)
  • I : 立即定址 immediate operands
  • J : Indexing constants
  • K : negative value in rhs
  • L: negative value in rhs
  • M : for shift
  • r : General registers -- ARM 一般用這個
Operand Register 的 in/out:
  • = : Write-only (通常所有的 output operand 都會加這個符號)
  • + : Read-Write (inline assemnly 不支援這個符號)
  • & : Output only - 這個register 只做 output 使用
Output Operand 一定要是 Write-Only。 Input Operand 一定要是 Read-Only。 但是如果要把 input operand 修改後,作為 output operand 的話,要怎麼辦呢? inline assembly 又不支援 '+' 符號.. 用"數字" 來告訴 complier 這一個 operand 共用哪一個 operand,例如:
asm volatile("mov %0, %0, ror #1" : "=r" (value) : "0" (value));
這個 code 是將'value" right shit 1 bit。 但是用同一個 register 來作就可以。 input operand 用 "0" 告訴 compiler ,使用 第0個operand (就是 output operand)。 所以 input, output 都會用同一個 register (mov %0, %0..)。 Clobbers 把被修改的部份寫在這
asm volatile(
"amsd   r3, %1, #3  \n\t"
"eor    %0, %0, r3  \n\t"
"addne  %0, #4"
: "=r" (len)
: "0" (len)
: "cc","r3"
);
例子使用了 r3 作scratch register,所以做完這段 code 後,r3的值會被修改,以在clobber的區域要列出 "r3"。 另外,作邏輯運算後,status 區域也會修改,所以要把"cc"也列上。 還有另一個例子:
asm volatile(
"ldr  %0, [%1]  \n\t"
"str  %2, [%1, #4]  \n\t"
: "=&r" (rdv)
: "r" (&table), "r" (wdv)
: "memory"
);
這一段code會update table 的內容,所以要在....
有一點沒寫到,就是 c variable name 都寫在 operand 後面,用括號( )括起來..
在 "Assembler Instruction with C expression operand" ,範例:
asm ("fsinx %[angle],%[output]"
   : [output] "=f" (result)
   : [angle] "f" (angle));
在operand 前可以用 [name] 寫出''將會用這'name'名字稱呼''。 然後在 code 區域就可以直接用 %[name] 來引用
大概可以這樣說: assembly code 中,要引用 C 宣告的部份,就要寫在 operand (in/out) 欄位,並且寫號 constrain. 然後用 %0, %1...來使用。 如果是直接存取 register,就直接用 r1, r2, r3... 但是要記得寫在 clobber 欄位。
ref:

Lenny Released

Debain 5.0 Lenny 終於Release 了 (2/14)。 下一個版本的 codename是 "Squeeze" 所以? 可以開始改 sources.list ? Release Notes 中說得真清楚,竟然清楚列出eeepc, kuro box..

2009年2月12日 星期四

加一個以前換下來的 HD 到 Sempron26Debian..

接到 hdb 先看一下:
Disk /dev/hdb: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x9b8c9b8c

 Device Boot      Start         End      Blocks   Id  System
/dev/hdb1   *           1        2501    20089251    7  HPFS/NTFS
/dev/hdb2            2502       10011    60324075    f  W95 Ext'd (LBA)
/dev/hdb5            2502       10011    60324043+   c  W95 FAT32 (LBA)
所以用 extend 的部份就好了..

用 fdisk 刪除(d) partition 5, 2 然後再 create (n) parition:extend,create (n) partition : logical,然後就是:
Disk /dev/hdb: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x9b8c9b8c

 Device Boot      Start         End      Blocks   Id  System
/dev/hdb1   *           1        2501    20089251    7  HPFS/NTFS
/dev/hdb2            2502       10011    60324075    5  Extended
/dev/hdb5            2502       10011    60324043+  83  Linux
為了保險,重開機...

這樣 mount 都不用先format (mkfs.ext3)。

所以 mount 在 ~/myhd 中。

決定還是在裡面 create folder,再用 link 到~/下好了。

先mv .VirtualBox 到 _toVirtualBox
再建link(ln -s myhd/_toVirtualBox .VirtualBox),然後 try virtualbox 會不會動... OK!

同樣,move vboxshare 過去,建 link..

OK. 這樣兩個 hd 都剩 30G.

2009年2月9日 星期一

convert id tage

很麻煩的轉檔 id tag 轉語系,轉成 utf 有兩種:java 跟 python。 java : id3iconv - http://linuxtoy.org/archives/convert-locale.html 就是
java -jar id3iconv -e  gb2312 *.mp3
python: mid3iconv , 這個要安裝 python-mutagen。http://gearspot.blogspot.com/2007/05/mid3iconvmp3tag.html
mid3iconv -e gbk --remove-v1 *.mp3

2009年2月6日 星期五

接著到kernel 下 make menuconfig。 http://virtuallyshocking.com/2008/12/20/building-android-for-the-asus-eeepc-701/

Android mast - repo int and sync

這次照著 這個 document (Building Android(cupcake) for eee_pc)作.. 結果,做完 repo init,create local_maniterst.xml , repo sync .. 就 fail。 所以這部份還是先 follow Androidx86 的文件 repo init 後,先作一次 repo sync。
這個花很多時間..
花了5 hours ,.repo 這個folder 約 674M。 checkout 後,變成2.3G 然後再 create .repo/local_manifest.xml,再 repo sync..就沒 error 了。 為了節省以後的時間,把 .repo tar 起來... 但是不知道單純這樣解開有沒有用..
果然,zip 起來,也是 664M - 所以 .repo 真的是已經壓縮過...
測試,在另一個 folder 解開 .repo,然後在 .repo 裡repo sync 可以恢復... 為求保險,在 android-cupcake sync 一個 cupcake branch 的 repo..

Git out success ! open port 9418

感激! MIS 老闆 打開了 NAT 的 port 9418。 所以把以前設的 GIT_PROXY_COMMAN 環境變數 unset 後,repo init 就可以出去了。 但是不知道是以前的init fail 的問題還是怎樣,出現 error,說我的 email 不是 valid domain。 所以用
>git config --global user.emal "charles@gmail.com"
還刪掉 .repo。 之後,就可以 run rep init ... 了。 然後,接著的 repo sync 也 OK。

2009年2月3日 星期二

Git behind proxy

在公司用 git,因為有 proxy,所以找了一下,大部分都是說加上 http_proxy 環境變數後,原來是 git:// 的,改為 http:// 就可以了。 但是 這個是 repo,所以不能這樣用。 找到一篇:repo behine proxy copy 一下內容:
Basically the steps are:
1 - sudo apt-get install socket
2 - in your home directory, put a shell script called "proxy-cmd.sh"
containing (replace YOUR_PROXY and YOUR_PROXY_PORT with your own proxy
parameters):
#! /bin/bash
(echo "CONNECT $1:$2 HTTP/1.0"; echo; cat ) | socket YOUR_PROXY
YOUR_PROXY_PORT | (read a; read a; cat )
3 - chmod +x proxy-cmd.sh
4 - export GIT_PROXY_COMMAND=<PATH TO YOUR SCRIPT>/proxy-cmd.sh

Enjoy,
Matthieu

PS: you can export GIT_PROXY_COMMAND in your ~/.bashrc file to make
this permanent 
還沒確認有沒有效...
這一篇有說明 socket command : git via a proxy server
From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Date: 2006-05-18 18:31:32

On Wed, 2006-05-17 20:44:28 -0700, Sam Song <samlinuxkernel@yahoo.com> wrote:
> Petr Vandrovec <petr@vmware.com> wrote:
> > Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> > > Well, install some package to have `socket'
> > > available? Debian calls
> > > the packet `socket', too, so I guess Fedora may
> > > have something similar.
> >
> > Surprisingly they do not...  You should be able to
> > replace 'socket' with
> > 'netcat' - and I believe that netcat/nc package is
> > available for Fedora.  For
> > this purpose they have same command line & behavior.
>
> Ummm, I am trying on that. nc is avaiable for Fedora.
> But what could be the replacement for CONNECT in
> Fedora? :-)

Erm, you haven't understood what you're doing there, have you?

With the GIT_PROXY_COMMAND helper, you're expected to create a clean
tunnel which in turn git can use to transfer its data.

You've only got some limited internet connectivity via a HTTP proxy
available, so you need to use this. This means:

 * The proxy administrator needs to allos outgoing connections for
   the CONNECT method with git's TCP port.
 * You need to have some minimalistic program to initially speak HTTP
   with the proxy and later on just stream the raw git protocol
   through the link.
 * You may or may not need to strip anything that came into the git
   stream by accident because you tunnled it through a HTTP proxy. A
   reply message from the proxy server is an example for this.

So this little script (using "CONNECT" and netcat or socket) does the
first part: it talks in the language HTTP with the proxy server. It
may be enough to just use CONNECT, but you may need to speak some more
lines, eg. for proxy authorization.

The first `cat' in there is just for pushing the git protocol though the
HTTP proxy connection later on (hopefully after the proxy was made to
accept the the CONNECT request.)  Once the proxy accepted it, it'll
send you a HTTP/200 message (or something like that) and an empty
line. This is what the two reads are for; the next `cat' simply again
transfers all the rest (the git protocol).

To draw the line, there's not _one_ solution to HTTP proxy tunneling,
there are many, and you'll need to design one that fits your network.
It should be quite simple, given that you've got nice tools like
`strace' and `tcpdump', which will help you to understand how the
proxy reacts and so on.

MfG, JBG

--
Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


結果...
charles-chang@rbtlegacy:~/android-eee$ repo init -u git://android.git.kernel.org/platform/manifest.git
Getting repo ...
   from git://android.git.kernel.org/tools/repo.git
fatal: protocol error: bad line length character
所以是 Fail... 不知道是不是公司的squid proxy 不允許 CONNECT 這個 operation. 同樣的一篇有說:
Note: most HTTP proxy servers allow CONNECT method to a very limited
range of ports, and administrators will need to enable the git port
(9418) explicitly. 
所以要問 MIS 有沒有 允許 CONNECT method和開啟 git 要用的 9418 port。

2009年2月2日 星期一

Sempron26Debian - 手動 update kernel 到 2.6.26

奇怪 linux-image 一直維持在 2.6.22-3 上,不會隨著 update 到 2.6.26。 所以手動 update : aptitude install linux-image-2.6 就安裝了 2.6.26。

2009年2月1日 星期日

明天的備忘..

已經要上班了,看來應該是來不及作 repo sync,只好在公司作,希望 git 能通過 公司的 proxy,同時希望 repo 能用。

Bookmark - android for Virtualbox

看來要build 一版 for Virtualbox 的才行。
ref : http://groups.google.com/group/android-porting/browse_thread/thread/66862bdb52dac936/8ffe04d6b3f9d4c0
copy 一下人家寫好的 how to.
大概是follow 先前的,但是 不用 checkout branch。
build完後 copy vendor/eeepc 下的 kernel.config 到 kernel 下作 menuconfig 重新 set kernel option for virtualbox, build kernel。
最後把 installer.img convert 成 virtualbox 吃的 vdi file。
---------------------------------------
Hi, all

       How to use x86 android platform on virtualbox
       ===============================================
       Last modified by Lim,GeunSik on 8-Jan,2009

Current Work status is not finished.
But, I opened and shared  to combine with developers for this tasks
all over the world.

Why I like virtualbonx in Linux distribution like Fedora 9?

This is Major characteristics per Virtualization Software.
-------------------------------------------------------------------
Software                 Linux         WinXP     Opensource
Free       Quick Install
-------------------------------------------------------------------
M$ Virtual PC              X                O
X                   O             O
VMwareServer               O                O
X                   O             O
VMwareWorkstation          O                O
X                   X             O
Parallels                  O                O
X                  X             O
QEMU                       O                O
O                  O             O
Virtualbox                 O                O
O                  O             O
XEN                        O                X
O                  O             X
KVM                        O                X
O                  O             X
-----------------------------------------------------------------
acirc;�� 1. Development environments
  * OS: Feodra 9 ( Linux 2.6.27-9 )
  * GCC:  gcc(gcc 4.3.0) and gcc34 (gcc 3.4) <- I recommend gcc 3.4
compat-compiler to build x86 android fullsource.
  * Glibc:  glibc 2.6 (NPTL Thread Model)
  * PC: Samsung MagicStation DB-P70 Model
  * CPU : Interl Core2 Quad CPU Q9300 (2.50Ghz) , bogomips is
4,987.50 , cache size 3,072kb
  * MEM: Samsung DDR2 2G
  * Reference: Midhun & Chen Yang's posting at http://groups.google.com/
and  http://source.android.com
  * Additional information:  When i finished this task finally, I
will upload  final howto  using WYSWYG and figures
     at http://www.kandroid.org.

�2. Build kernel source for VirtualBox software.
Fedora9$ cd ~/bin_x86/mydroid
Fedora9$ cp ./vendor/asus/eee_701/kernel.config kernel/.config
Fedora9$ cd kernel
Fedora9$ make menuconfig

* Network device for virtualbox s/w
network device support ->
 Ethernet (10 or 100Mbit)  --->
     [*]   EISA, VLB, PCI and on board controllers
    <*>     AMD PCnet32 PCI support   <-  We need virtual lan infra
in  virtualization like vmware or virtualbox.

* To support FB on virtualbox environment.
Graphics support  --->
 <*>  Support for frame buffer devices  --->
        [*]   VESA VGA graphics support  <- Unfortunately, Vesa VGA
support 800X600 resolution.
Console display driver support  --->
       <*> Framebuffer Console support
       [*] Select compiled-in fonts
       [*]   VGA 8x8 font
       [*]   VGA 8x16 font

* Disable pmem allocator if your kernel is 2.6.27 base.
[*] Misc devices  --->
[ ]   Android pmem allocator (NEW)

If you are using 2.6.27 based x86 android full source, Disable  "PMEM"
feature in "make menuconfig menu.
pmem is only needed for certain devices requiring large physically
contiguous memory on the MSM7XXX (GPU,DSP, etc).  It's not currently
used by any other SoCs and its absence is not a fatal error.
-------------------------------------------------------------------
* MSM7XXX (GPU,DSP, etc): YUV --> pmem ---> VideoLayer
* Another Chip: YUV --> mEmulation(ro.kernel.qemu=1) --> /dev/fb0(RGB)
-------------------------------------------------------------------

Fedora9$ make bzImage
Fedora9$ ls ./arch/x86/boot/

Ref) If you want  to build 2.6.27 based android kernel at
http://android.git.kernel.org webstie,
     you may apply alsa related the patch at http://review.source.android.com/6751

�3. convert installer.img to installer.vmdk with virtualbox

Fedora9$ cd ~/bin_x86/mydroid/out/target/product/eee_701
Fedora9$ rpm -ivh http://download.virtualbox.org/virtualbox/2.1.0/VirtualBox-2.1.0_4114...
Fedora9$ VBoxManage --help | grep Version
VirtualBox Command Line Management Interface Version 2.1.0
Fedora9$ VBoxManage  convertfromraw -static -format VDI ./
installer.img  ./installer.vdi (X)
Fedora9$ VBoxManage  convertfromraw           -format VDI ./
installer.img  ./installer.vdi (O)

VirtualBox Command Line Management Interface Version 2.1.0
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
Wrong owner (0) of '/tmp/.vbox-invain-ipc'.
Converting from raw image file="installer.img" to file="./
installer.vdi"...
Creating dynamic image with size 406871040 bytes (389MB)...
Fedora9$ file ./installer.vdi
./installer.vdi: data

OR
Fedora9$ vditool DD installer.vdi *.img
Fedora9$ vditool SHRINK installer.vdi

�4. Setting of virtualbox
Open  "Sun VirtualBox" software ->Click on New -> Next
- Name = it as "AsusAndrioid"
- OStype=Linux
- Version=2.6
- RAM=256MB
- Hard Disks=  Slot Checked Boot Harddisk with IDE Primary Master

�5. booting android kernel in virtualbox s/w.
1) When I start the installer.vdi in virtualbox software, it hangs on
grub Loading stage 2 step.
  Below is error screenshot to help understanding.

  So, you have to push F12 key fastly as soon as start installer.vdi
with virtualbox.
  Remember "Press F12 to select boot device" message  in virtual box
window.

2) When you press F12  key and it shows the following:
             0: sys_loader
             1: recovery
             2: std_boot (* default selection)

3) Option "0: sys_loader" is selected by default when kernel boot in
virtualbox.
* Option 0: sys_loader
0: cmdline (hd0,0)/cmdline
1: kernel --use-cmd-line (hd0,0)/kernel
2: initrd (hd0,0)/ramdisk

* Option 1: recovery
0: cmdline (hd0,2)/cmdline
1: kernel --use-cmd-line (hd0,2)/kernel
2: initrd (hd0,2)/ramdisk

* Option 2: std_boot
0: cmdline (hd0,2)/cmdline
1: kernel --use-cmd-line (hd0,2)/kernel
2: initrd (hd0,2)/ramdisk

Now, I din't find "/boot/grub/menu.lst" file  for bootloader like
Feodra or Ubuntu.
Belows is process informations using top command.

#> cat /proc/version

Linux version 2.6.25-00101-gb6922fa
(dmitr...@weppard.mtv.corp.google.com) (gcc version 4.0.3
(Ubuntu 4.0.3-1ubuntu5)) #1 SMP PREEMPT Wed Nov 19 11:52:46 PST 2008

#> cat /proc/partitions
major     minor   #blocks    name
  ......... Above Omission ..........
8            0        397335   sda
8            1          4439    sda1
8            2        391872   sda2

� 5. Modify kernel cmd line like Linux: ***
Select No 2  "2: std_boot (* default selection)" after F12 key.

Remove  "--use-cmd-line" option in Linux boot display.
Append "androidboot.hardware=eee_701 vga=788" options in Linux boot
display

Highlighted entry is 2:
GNU GRUB version 0.97 (639K lower / 261056K upper memory)

0: cmdline (hd0,2)/cmdline
1: kernel --use-cmd-line (hd0,2)/kernel
2: initrd (hd0,2)/ramdisk
               .......... Omission .........
 Highlighted entry is 0:

Todo: But, bootloader is not found (hd0,2) because (hd0,2) partition
is not exist.
Booting command-list

cmdline (hd0,2)/cmdline
Error 22: No such partition

Press any key to continue ...

� 6. Mount  "* img" to /dev/block/sda2 device node.
Use installer command  /data directory.
#>  system/bin/installer -p /dev/block/sda2
  It gives an error that the total requested size is greater than
the disk size as belows.
  " Total requested size of partitins (1,644,167,168) is greater
than disk size (406,871,040)."
  (My image size is 387 MB and it is looking for around 1.5GB
space).

#> ls /data/
userdata.img
boot.img
system.img
bootldr.bin
lost+found

OR
Fedora9#> mkdir /data/boot
Fedora9#> mount -t ext2 /dev/block/sda2  /data/boot
Fedora9#> echo " vga=788" > /data/boot/cmdline
Fedora9#> umount /data/boot



這裡有 build 好的 Android for VirtualBox 的VDI 可以 download,download 後 用 VirtualBox run 就可以了 Android in VirtualBox

標籤

網誌存檔