2014年8月28日 星期四

cross compile mtdev for TI DM8134

while making mtdev, the error log shows that



'const struct input_absinfo' has no member named 'resolution'

so check the include file first

go to the include directory, and type the command : $CC -M mtdev.h to get the path of all header files

the result is as follows



we can find that the file input.h is from CodeSourcery directory. We want to reference it from our source tree(/media/DM8134/src/...). So I set the env parameter

export C_INCLUDE_PATH=/media/DM8134/src/board-support/linux-2.6.37-psp04.04.00.01/include

observe the parameter



C_INCLUDE_PATH is now set

make again



OK, we got a new error message. 

error: asm/bitsperlong.h: No such file or directory

check my include path again, I find there is a "asm-generic" directory in it but no "asm" directory.

brute force!! copy asm-generic to asm



OK

make again



so it seems that it can be built now

go to upper (mtdev) directory, make and install

make

lot of warnings...



make install

remember to set PATH parameter when using sudo to make install

sudo env PATH=$PATH make install



all files are installed into corresponding directories under /usr/local/lib/mtdev/




done!!

見招拆招!!


2014年6月17日 星期二

記錄一下自己vim的hotkey

Tabs相關

  • 產生新tab:<Ctrl-T><Ctrl-T>
  • 關掉目前的tab:<Ctrl-T><Ctrl-W>
  • 移到前ㄧ個tab:<Shift-H>
  • 移到下ㄧ個tab:<Shift-L>

Split(分割視窗)相關

  • 移到左split:<Ctrl-w>H
  • 移到右split:<Ctrl-w>L
  • 移到上split:<Ctrl-w>K
  • 移到下split:<Ctrl-w>J

開啓/關閉NERDTree:<Fn><F6>

開啓/關閉TagBar:<Fn><F7>

ctags

  • 搜尋游標所在變數、函式定義:<Ctrl-w>]
  • 回到搜尋處:<Ctrl-w>t

cscope

  • <Fn>s   symbol: find all references to the token under cursor
  • <Fn>g   global: find global definition(s) of the token under cursor
  • <Fn>c   calls:  find all calls to the function name under cursor
  • <Fn>t   text:   find all instances of the text under cursor
  • <Fn>e   egrep:  egrep search for the word under cursor
  • <Fn>f   file:   open the filename under cursor
  • <Fn>i   includes: find files that include the filename under cursor
  • <Fn>d   called: find functions that function under cursor calls

script to generate cscope and ctags files

因為工作需要,所以寫了一個簡單的shell script來幫忙產生新的ctags以及cscope檔案



# put this script to the top directory of source code
CSCOPE_PATH=`pwd`
CTAGS_PATH=`pwd`
# remove cscope files
echo "remove cscpoe.out"
if [ -f $CSCOPE_PATH/cscope.out ]; then
    rm cscope.out
fi
echo "remove cscpoe.in.out"
if [ -f $CSCOPE_PATH/cscope.in.out ]; then
    rm cscope.in.out
fi
echo "remove cscpoe.po.out"
if [ -f $CSCOPE_PATH/cscope.po.out ]; then
    rm cscope.po.out
fi
# remove ctags files
echo "remove tags"
if [ -f $CTAGS_PATH/tags ]; then
    rm tags
fi
# recreate cscpoe files
cscope -Rbkq
ctags -R
# use the following script instead of 'cscpoe -Rbkq' to add .cc into cscope
#find . -name "*.h" -o -name "*.c"-o -name "*.cc" > cscope.files
#cscope -bkq -i cscope.files

其實用for loop來寫比較簡潔,不過這樣寫比較容易懂,所以算了 XD

另外好像應該找一個可以模擬script的css來用比較好讀

2014年5月9日 星期五

老鄭心之俳句之 Simple Factory Pattern

剛剛腦袋突然靈光一現,想到了Simple Factory的比喻,趕快記下來~


比如說工程師要叫料,最不好的情況是每個工程師都需要知道廠商的電話以及賣的東西。如果有新的工程師進來,他也必須要熟悉這個list。如果有新的廠商的話每個工程師也都需要更新自己的list,說起來不是很方便。

Simple Factory舉個例子來說就是部門裡面請了一個正妹助理,把所有的廠商資料都交代給這位助理,以後工程師需要某個料的時候找這位助理就可以了。如果廠商資料有更新的話也只需要這位助理了解就可以。

有空再補圖

2014年4月23日 星期三

Ubuntu上cross compile DM813x qt binary

假設已經下載回ezsdk


  1. 執行{EZSDK}目錄下的./setup.sh,這是為了設定環境
  2. 在程式目錄下(ex. ~/Workspace/demo)執行qmake -project,產生.pro檔案
  3. 執行qmake,產生make檔
  4. 執行make

memo用~~

2013年12月10日 星期二

在Ubuntu上cross compile Chromium然後放到Pandaboard上執行

最近接到個任務,需要在embedded system上面跑HTML5的程式。目前對HTML5支援最高的非Google的Chrome莫屬,只不過Google沒有提供arm架構的Chrome,所以如果有需要的話只能自己build。

Chrome有個雙胞胎弟弟叫做Chromium,可以視為Chrome的beta版本。Google提供Chromium的原始碼以及編譯工具,有需要的人可以自己下載回來編譯。

這篇文章會一步一步的介紹編譯的過程,到最後把Chromium的程式放到embedded system上跑起來為止。

我的環境是透過Mac上面的VM跑Ubuntu 12.04,然後所有的編譯動作都在Ubuntu上執行。因此首先需要安裝Ubuntu 12.04,詳細的過程在此就不多做介紹。

特別需要注意的是,抓回來的原始碼檔案大概有8G,加上編譯的時候需要的空間會佔掉許多,個人建議不要小於20G的空間。

編譯Chromium


Google為Chrome的編譯準備了許多的工具,包含了下載原始檔的script、設定工具、cross compile等等,這些工具可以透過git來抓取,但是在這之前必須要先把git升級到1.7.5以上:

ㄧ、下載(更新)git
$ apt-get install git

安裝好之後,接下來就可以準備下載工具了。為了之後管理方便,我另外掛了一個虛擬硬碟上去,把所有跟Chrome有關的檔案都放在裡面,目錄是/media/Chromium,後面都會預設裝載這個資料夾下。

二、下載depot_tools
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git 

執行結束之後會在當前目錄下產生一個目錄depot_tools,裡面放著許多之後會用到的小工具。

工具抓完之後記得把depot_tools加入PATH下,比較方便。除此之外,方便起見也可以順便寫到自己的.bashrc裡面。
$ export PATH="$PATH":`pwd`/depot_tools 

完成之後接下來就可以利用depot_tools裡面的fetch來下載原始碼了。

三、 下載chrome
$ fetch chrome --nosvn=True

由於我不會貢獻程式碼,所以在後面加入參數 --nosvn=True。相關的參數設定很多,有需要的請參照這裡

通常下載程式碼需要好幾個小時以上(我自己是花了大概6hr),所以這時候可以去打茫一下。

下載結束之後,會看到/media/Chromium下面多了個 src 資料夾,所有抓回來的程式都在這資料夾下面


進入/media/Chromium/src裡面看看抓回來的東西


好了,東西抓回來之後可以開始build code了。由於我之後是要將chromium放到Pandaboard上面,Pandaboard是個 ARM 架構的嵌入式系統,所以必須透過 cross compiler來編譯chromium。幸運的是depot_tools裡面已經提供了相關的工具,我們只要設定好環境參數,再執行相關的script就可以完成。

四、 下載ARM架構的相關tool chain
$ cd src
$ ./build/install-build-deps.sh --arm

五、 設定tool chain路徑以及相關參數
export GYP_DEFINES="target_arch=arm arm_float_abi=hard"
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export AR=arm-linux-gnueabihf-ar
export CC_host=gcc
export CXX_host=g++

建議上面這些參數也可以寫到自己的.bashrc裡面,省得以後還要重打。如果想要知道更多的資訊可以參考這裡


在編譯之前先執行以下指令,目的是為了要準備好編譯的環境
$ gclient runhooks

最後就可以執行編譯了
$ ninja -C out/Release chrome

上面的指令會在src目錄下新增一個out/Release 目錄,所有編譯出來的東西都放在這裡面。chromium的編譯分為Debug版本以及Release版本,這例子編譯的是Release版本,如果要編譯Debug版本只要把Release改為Debug就可以了
$ ninja -C out/Debug chrome

chromium的執行需要一個sandbox的binary,在編譯的時候也可以一起產生,命令如下:
$ ninja -C out/Release chrome chrome_sandbox

這樣就會在編譯完後在Release目錄下產生chrome_sandbox檔案


Deploy到Pandaboard上

程式碼build完之後,接下來把Release裡面所有的資料copy到Pandaboard的file system上,我是放在~/Chrome/Release裡面方便管理。

第一次在執行程式的時候,很有可能會遇到library找不到的問題,像我就遇到了一個
$ ./chrome
libxss.so.1 cannot open shared object file, no such file or directory

解決的方法就是把找到對應的檔案,並且安裝好。Linux上面有一個工具apt-file可以幫我們找到檔案對應的套件是哪個,知道之後再利用apt-get install來安裝這個套件


ㄧ、 首先先安裝apt-file,由於apt-get版本好像太舊的關係,所以要先更新apt-get再利用apt-get來安裝apt-file
$ apt-get update
$ apt-get upgrade

apt-upgrade會更新所有的程式,個人覺得應該不必要

二、 安裝apt-file
$ apt-get install apt-file

三、 找到缺少的lib
$ apt-file search libxss.so.1

上面這行訊息回給我libxss1,所以這下就知道要安裝這個套件
$ apt-get install libxss1

再次執行chromium,出現"Running without the SUID sandbox!"錯誤訊息,這問題先取消使用sandbox來work around
$ chrome --no-sandbox

這樣就可以執行起來了

暫時寫到這邊,剩下的等到有空再寫






2013年12月9日 星期一

在Pandaboard上面安裝Chromium


  1. 把cross compile完的chrome放到PandaBoard上
  2. 執行時系統出現 libxss.so.1 cannot open shared object file no such file or directory
  3. 安裝apt-file,在這之前要先更新apt-get
  4. 執行apt-get update
  5. 執行apt-get upgrade
  6. 執行apt-get install apt-file
  7. 執行ldd /usr/bin/chrome來找出缺少的lib,找到缺少libXss.so.1
  8. 執行apt-file search libXss.so來找出這個lib存在哪個檔案,找到libxss1
  9. 透過apt-get install libxss1來安裝相關lib
  10. 再次執行chrome,出現running without the suid sandbox


reference:
  1. http://askubuntu.com/questions/59703/skype-error-while-loading-shared-libraries-libxss-so-1-cannot-open-shared-obj
  2. http://www.360doc.com/content/11/0420/16/11586_111051270.shtml
  3. http://blog.sina.com.cn/s/blog_49b2f03a0100o6qa.html
  4. http://cysec.org/blog/2012/03/19/missing-libraries-for-skype-on-ubuntu-12-04-lts-precise-pangolin/
  5. http://mayecn.com/blog/2013/04/25/ubuntu-64-robocup/