2012年11月16日 星期五

不能對美國心存幻想

美國雖然是民主國家,嘴裡也口口聲聲說要支持民主,但是在國家利益之下,只要不是美國人,都是可以犧牲的。其實這樣做也很正常,美國人也常常把國家利益掛在嘴邊,只是就台派來說,司法部針對扁家在美資產逕自沒入還是很誇張。

我想中國的高官貪官在美國置產入籍多不勝數,也不曾聽說美國司法部沒入哪個貪官的資產。國民黨藏汙納垢那麼多年,落跑的人一堆,以及興票案之類不明不白的資產,都不曾被沒入。

美國司法部的新聞稿稱這是"alleged bribe",只是alleged就可以這樣搞,要說不是政治事件還真令人難以相信。我相信美國司法部會用alleged,其實也心知肚明KMT在搞什麼。

可憐的台灣人只有靠自己了,美國為了自身利益隨時可以把你給賣了。 還有,這該不會是給小金子的見面禮吧?

QEMU and ARM Linux

我是以Ububtu Linux上的qemu-system-arm來進行實驗,先要安裝qemu-system-arm

sudo apt-get install qemu-user-static qemu-system

想知道支援的CPU型號列表:

qemu-system-arm -cpu ?

想知道支援的系統列表:

qemu-system-arm -machine ?

這裡用的是ARM Versatile這個系統當範例,這塊板子的CPU是ARM926EJ-S

Toolchain


首先要解決的是toolchain,這裡是直接下載現成的CodeSourcery CodeBench Lite 2012.03-57 for ARM GNU/Linux.

假設解開到~/test-qemu-arm/, 這時就需要把它的路徑加到PATH

export PATH=$PATH:~/test-qemu-arm/arm-2012.03/bin

寫個小程式來試試看QEMU, 這裡我用個老掉牙的Hello world C程式做測試

qemu-arm-static -L ~/test-qemu-arm/arm-2012.03/arm-none-linux-gnueabi/libc/ ./hello_world

Kernel


寫個script來設定編譯Linux kernel所需的環境變數:

export PATH=$PATH:/home/victor/test_qemu-arm/arm-2012.03/bin
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabi-


根據我們使用的平台,載入default config:

make versatile_defconfig

接著做個小修改:

make menuconfig

在"Kernel Features"這一頁,打開"Use the ARM EABI to compile the kernel"

離開前記得要存下設定。

接著就可以開始編譯,這個會稍微花點時間,但以現今PC的能力來說,其實才幾分鐘而已。

make uImage

檢視一下這個uImage file:

file arch/arm/boot/uImage

大致上會看到這樣的輸出:

arch/arm/boot/uImage: u-boot legacy uImage, Linux-3.6.3, Linux/ARM, OS Kernel Image (Not
compressed), 1986896 bytes, Mon Oct 22 17:52:05 2012, Load Address: 0x00008000, Entry Point:
0x00008000, Header CRC: 0x7EF0365B, Data CRC: 0xAE2513DE


現在可以用QEMU來測試kernel:

qemu-system-arm -M versatilepb -m 128M -kernel arch/arm/boot/uImage

Root Filesystem


我們借助於buildroot來建立所需要的root filesystem。
我下載的是buildroot-2012.08.tar.bz2
網址是 http://buildroot.uclibc.org/

下面是在編譯前需要做的設定:

  • Set toolchain as an External, Custom, Pre-installed toolchain.
  • Set toolchain path = ~/test_qemu-arm/arm-2012.03/
  • Set toolchain prefix = arm-none-linux-gnueabi
  • Set serial port from ttyS0 to ttyAMA0
  • Enable "cpio the root filesystem"
  • And set "Compress method" to gzip.

有些套件可能需要安裝才能順利編過
  • bison
  • flex
  • texinfo(for makeinfo)

編出來的root filesystem是在output/images/rootfs.cpio.gz

現在把kernel跟root filesystem放在一起跑:

qemu-system-arm -M versatilepb -m 128M -kernel uImage -initrd rootfs.cpio.gz -serial stdio

這套系統可以用root登入

下面是我參考的網頁:

http://www.linuxforu.com/2011/06/qemu-for-embedded-systems-development-part-1/
http://www.linuxforu.com/2011/07/qemu-for-embedded-systems-development-part-2/
http://www.linuxforu.com/2011/08/qemu-for-embedded-systems-development-part-3/
http://elasticsheep.com/2011/01/building-and-emulating-a-basic-arm-linux-system/