星期日, 十二月 06, 2009

Cross-Compiling Made Easy - with Gentoo Linux

用 Gentoo 最開心的地方,就是它非常的 developer friendly。

交叉工具鍊 - Cross-Toolchain

個人認為這個翻譯很糟糕... 不過要在 Gentoo 下要生出一個可用的 cross-compiler,只需要兩行指令:

$ sudo emerge crossdev
$ sudo crossdev -t ARCH-VENDOR-OS-LIBC

請將 ARCH-VENDOR-OS-LIBC 取代成對應的軟硬體設置,具體請參考 `crossdev -t help`。

不過在這之前,最好先有個本機上的 PORTDIR_OVERLAY. 不然 crossdev 會建立一些檔案根目錄在 PORTDIR_OVERLAY 裡面找到的第一個目錄下。您可以用以下指令直接修改 /etc/make.conf(注意單引號跟雙引號):

$ sudo bash -c 'echo PORTDIR_OVERLAY=\"/path/to/overlay \${PORTDIR_OVERLAY}\" >> /etc/make.conf'

雖然要等一段時間,不過過程可是全自動的!

做完以後,就會得到一整排的工具了。例如 ARCH-VENDOR-OS-LIBC-{gcc,g++,as,ld,strip,...} 等等。

目標檔案系統 - Target Filesystem

基本上也是三個指令,不過要等更久...

$ sudo emerge crossdev-wrappers
$ sudo emerge-wrapper --init
emerge-ARCH-VENDOR-OS-LIBC system -v

然後系統就會出現在 /usr/ARCH-VENDOR-OS-LIBC 目錄下了。注意喔,千萬別把它移走!即使移走也要作個 symlink 回來,不然 cross-emerge 會找不到路徑。

星期五, 十二月 04, 2009

接觸不良

由於憂鬱症的關係,我從大約四個月前開始服用 惠氏速悅持續性膠囊(Effexor XR),其主成分為Venlafaxine。醫師開給我的處方劑量,由一開始的每日一顆,逐步增加到目前的每日三顆。

藥本身還算有用,下面做成清單不是為了賣弄我知道 html 的 <ul> 與 <li> 標籤,純粹只是我討厭在一長段文字裡面敘述這種明明做成清單就可以一目了然、寫成一大段就看得不清不楚的概念:

  • 每日 75mg:30% 療效
  • 每日 150mg:50% 療效
  • 每日 225mg:70% 療效

這裡的「療效」指的是,我自認與正常沒有神經病的人相比的相似程度 - 之於我也就是可以在固定的時間固定的事情,以及不會莫名其妙就想些雜七雜八事情的能力。

但是... 雖然醫生有給我開連續處方籤,但是你不能期待一個神經病會自己去拿藥來吃是吧?所以每隔一個月左右,我總會有幾天想吃藥卻沒藥吃的時候(例如現在 XD)。

服用高劑量卻突然「斷糧」的結果,是會有突然停藥的強大副作用 @@ 感覺就好像是類比電視突然被突波干擾,畫面瞬間跳掉又回來那樣。可是這種狀況發生在你的視覺、聽覺、觸覺上。

唔...「為什麼你不去拿藥吃就好了呢?」


btw,照這個比例來講我吃五顆就會變成超人了是吧?

星期四, 十一月 26, 2009

rtc-davinci-evm for dm6446 on linux-davinci.git

中文版

從 2.6.27-davinci1 開始,由於引進了新的 i2c framework,導致 dm6446evm 上許多走 msp430 的週邊都不能用了,例如 rtc-davinci-evm 與 IR receiver 等等。到今天 2.6.32 都快 release 了,還是沒有人把 driver port 過去...

沒辦法,公司產品需要,所以咧... 只好自己動手啦!(這也是 Open Source 社群最有趣的地方!)

悲慘的是,寫好 driver、測試成功以後,居然 linux-davinci 的 mailing-list 不給我寄 @@ 所以只好先放在公司的 git repository 上啦。不過這個網址只是暫時的,也許過一陣子會改...

English Version

Start from 2.6.27-davinci1, linux introduced the new i2c framework, which causes many peripherals of the msp430 chip on dm6446evm stop working, such as rtc-davinci-evm and the IR receiver. As for today, although the 2.6.32 is about to get released, but the driver is still stays unusable...

Too bad, my company just uses dm6446 in our product, which I just have to port them by my own! (Which is the major fun for an Open Source community!)

But what bothers me is that, after I successfully wrote the driver, and verified it's working great, I cannot submit it on the linux-davinci mailing-list due to some unknown error (used to be able to send a mail there...) @@ so i just have to put the files on my company's local git server. However this is a temporary domain name, it may or may not be changed later, anyway.

星期三, 九月 16, 2009

Calm down, please. My heart!

If sorry is all you gonna say, I've heard enough.

Yes, like you can never do nothing for me.
Damn me.
Yes, like you just never willing to do nothing for me.
Damn me, once again.

You'll never have no idea how much you ruined my life.
You'll never have no idea how much you messed up my mind.

How can you be so mean?
How can you be so selfish?
How can you be so fucked up?
Why are you bothering my heart whenever I finally got some calm and peace?
Why can't you just tell me that you don't even wanna give a shit about me at all?

Why do I still love you so damn much?

星期一, 八月 31, 2009

救災順利!成功救活四名專題做不出來的學弟!

我大學時代的專題老師,今年叫學弟們做 ARM Linux + RFID 相關的專題,主要是用來管理冰箱裡面的東西的保存期限的。

可是呢,這群學弟...

「ARM 是什麼?可以吃嗎?」
「Linux 我們不太會耶!」
「RFID Reader 只有 Windows driver (還是 VB.Net 寫的) 耶,可以拿去 Linux 上編嗎?」

所以,不知道他們從哪裡找到我,突然來問我要怎麼辦。

我想說,既然是以前的專題老師,要是這組學弟做不出來或做的不好,他也很丟臉... 而且順便也想看看 RFID 在 Linux 上到底會不會動,所以就決定下去台中一趟幫他們看看。

不看還好,一看之下才發現,他們使用的 ARM 是 s3c2410 配上一套有夠舊的 Linux(kernel 是 2.4.x......),可是使用的 SUMMIT U-Reader 在我的機器上倒是抓的到也有 driver,只是沒有 user-space tool 去 access 它而已。所以我乾脆就叫他們說,先在 PC Linux 上做,然後把移植到 arm 上當成一個「願景」。盡量使用嵌入式系統上容易找到的軟體(如 boa),如果真的要移植的話也比較方便。

SUMMIT U-Reader 其實是一個 pc210x 的 USB-to-RS232 晶片,加上他們自己家的 HF 讀卡模組(使用 RS232 介面,Windows 的 VB.Net 程式也是使用 Serial subsystem 去 access)。既然如此,事情就簡單啦!我只要弄個 serial 程式去操作它就可以了!

我目前幫他們寫到可以抓到卡號,讀取以及寫入 RFID Block 就要靠他們自己了。以下是 example code(BSD License!):

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>

#include <iostream>

#define TTYDEVICE "/dev/ttyUSB0"
#define BAUD  B19200

int open_port(void)
{
 int fd = open(TTYDEVICE, O_RDWR | O_NOCTTY | O_NDELAY);
 if (fd == -1)
 {
  perror("open_port: Unable to open " TTYDEVICE);
  return fd;
 }
 fcntl(fd, F_SETFL, 0);

 // port settings
 struct termios options;
 tcgetattr(fd, &options);
 cfsetispeed(&options, BAUD);
 cfsetospeed(&options, BAUD);
 options.c_cflag  |= (CLOCAL | CREAD);
 options.c_lflag  &= ~(ICANON | ECHO | ECHOE | ISIG);
 options.c_oflag  &= ~OPOST;
 options.c_iflag  |= (INPCK | ISTRIP) & ~(IXON | IXOFF | IXANY);
 options.c_cc[VMIN] = 0;
 options.c_cc[VTIME] = 10;
 tcsetattr(fd, TCSANOW, &options);

 // clear I/O buffer
 tcflush(fd, TCIOFLUSH);

 return fd;
}

int main()
{
 // get the file descriptor from open_port()
 int fd = open_port();

 // I/O buffer, let it be the 'I' command initially
 char buf[256] = { 0x1b, 'I', '\r', 0 };

 int n;

 // write() the 'I' command
 if ((n = write(fd, buf, 3)) < 3)
  std::cerr << "write() of 3 bytes failed!\n";
 else
 {
  std::cout << "write() " << n << " bytes: ";
  for (int i = 0;i < n;++i)
  {
   std::cout << "0x";
   std::cout.width(2);
   std::cout.fill('0');
   std::cout << std::hex << static_cast<int>(buf[i]) << ' ';
  }
  std::cout << std::endl;
 }

 // read the result  n = read(fd, buf, 255);
 if (n < 0)
  fputs("read() failed!\n", stderr);
 else
 {
  std::cout << "read() " << n << " bytes: ";
  for (int i = 0;i < n;++i)
  {
   std::cout << "0x";
   std::cout.width(2);
   std::cout.fill('0');
   std::cout << std::hex << static_cast<int>(buf[i]) << ' ';
  }
  std::cout << std::endl;
 }

 close(fd);

 return 0;
}

星期一, 三月 30, 2009

Bug wranglers know this bug by heart now

之前更新 gcc-4.3.3-r1 之後,編 mplayer 會吐 ICE 出來。今天 emerge world -ua 的時候看到 gcc-4.3.3-r2,在裝之前想說看一下 ChangeLog 有沒有修好這個 bug:

27 Mar 2009; Peter Alfredsen -gcc-4.3.3-r1.ebuild, +gcc-4.3.3-r2.ebuild: Revbump with broken patch disabled to stop duplicates of bug 262567 from flowing in. Bug wranglers know this bug by heart now.

這個 #262567 file 的就是這個 bug。點進去看一下... 挖咧!二十幾個 duplicates = = 難怪 Bug wranglers 會 know this bug by heart 了 XD~

底下是一段 Quote:

At last, rev-bumped.

Btw, maybe all those duplicates are not the user's inability to search, but their ability to tell you "please *always* rev-bump fixes that are not build-related to the package itself" :P

- Nikos Chantziaras

星期四, 三月 26, 2009

言論自由

阿克頓勳爵曾經說過:「我不喜歡你的言論,但我誓死保護你的言論自由。」

若查證「郭冠英」就是「范蘭欽」屬實,那麼他的確該下台,因為他違反公務人員應行政中立的基本規範。但是「范蘭欽」發表的文章倒是沒有任何問題,那是言論自由。雖然美國有針對種族歧視言論的法律,但是很抱歉中華民國剛好沒有... 所以他也沒犯法。

我不懂的是這些新聞媒體幹嘛拿「高級的外省人」做文章,這也沒什麼大不了。很多產品不是也會在包裝上寫「高級蜜餞」或「高級水果禮盒」嗎?那這些廠商是不是也通通要上新聞接受批判一下?況且他只有說「我是高級的外省人」而已,不知道這些媒體是從哪裡得來「台灣人是低級」的結論。你說「這是部好看的電影」或「這是本內容豐富的書」的時候,也不表示其他的電影不好看、其他的書沒內容啊...

另外,蔡英文同學,言論自由是憲法保障的,不是你說有就有,你說沒有就沒有的好嗎?