2009年9月24日 星期四

OMAP3530 DSP Howto

沿襲TI一貫的傳統,Software package & document一堆但都缺乏最基本的Step-by-Step.
在網路上搜尋到一些resource先記下來

GSG: OMAP35x DVEVM Software Setup

BeagleBoard/DSP Howto

BeagleBoard/gst-openmax

http://groups.google.com/group/beagleboard/browse_thread/thread/05557a0d149fb225

gst-openmax demo on the beagleboard

1.Install TI dspbridge libraries

cd ${HOME}/OMAP3530

git clone git://gitorious.org/ti-dspbridge/userspace.git ti_dspbridge

cd ti_dspbridge
cp -a binaries/lib/lib* ../beagle-cupcake/out/target/product/beagleboard/root/lib
cp source/samples/utils/uninstall_bridge ../beagle-cupcake/out/target/product/beagleboard/root/dspbridge/

mkdir ../beagle-cupcake/out/target/product/beagleboard/root/dspbridge
cp source/samples/utils/install_bridge ../beagle-cupcake/out/target/product/beagleboard/root/dspbridge/

cd ..

2.Install TI OpenMAX IL

Download tiopenmax-0.4.1

cd tiopenmax-0.4.1

Append below to Makefile

export OMXROOT=$(shell /bin/pwd)
export CROSS=arm-none-linux-gnueabi-
export PKGDIR=$(shell /bin/pwd)
export PREFIX=$(shell /bin/pwd)
#export TARGETDIR=${PREFIX}/rootfs
export TARGETDIR=${HOME}/OMAP3530/beagle-cupcake/out/target/product/beagleboard/root
export BRIDGEINCLUDEDIR=${HOME}/OMAP3530/ti_dspbridge/source/mpu_api/inc
export BRIDGELIBDIR=${TARGETDIR}/lib

mkdir ../beagle-cupcake/out/target/product/beagleboard/root/omx
make avplay.clobber avplay

cp bin/cexec.out ../beagle-cupcake/out/target/product/beagleboard/root/dspbridge

mkdir ../beagle-cupcake/out/target/product/beagleboard/root/share
cp -a share/* ../beagle-cupcake/out/target/product/beagleboard/root/share/

3.Install DSP Binary

Download Android_DSP_Binaries-1.2-Linux-x86-Install.tar.gz

/**********/

Install DSP Binaries to ${HOME}/OMAP3530/beagle-cupcake/out/target/product/beagleboard/root/lib/dsp

gigijoe@gigijoe-laptop:~/OMAP3530/beagle-cupcake/out/target/product/beagleboard/root/lib/dsp$ ls
baseimage.dof       h264vdec_sn.dll64P  m4venc_sn.dll64P       postprocessor.dll64P          usn.dll64P
conversions.dll64P  jpegdec_sn.dll64P   mp4vdec_sn.dll64P      postprocessor_dualout.dll64P  vpp_sn.dll64P
dctn_dyn.dll64P     jpegenc_sn.dll64P   mpeg4aacdec_sn.dll64P  ringio.dll64P

/**********/




2009年9月23日 星期三

OMAP3530 MINI V3 + 0xdroid

ICETEK OMAP3530 MINI V3號稱硬體跟beagle board相容.
由於mini board有512MB nand flash & DM9000 ethernet所以捨棄了beagle board.
但風險就是萬一硬體有不相容的地方就得自己搞了

http://code.google.com/p/beagleboard/wiki/BeagleSoftCompile

1.OMAP3530 boot
Boot對Embedded System是一件大事,就像生命的起源一般.
OMAP3530可以從nand flash or SD card boot,由x-loader開始.
x-loader負責初始化CUP,包含memory & nand flash,之後會載入並執行u-boot.

預設供電後由nand flash載入x-loader.
按住user button + reset button就會由SD card載入x-loader.

2.Compile x-loader

修改xloader/include/configs/omap3530Mini.h

/* NAND is partitioned:
 * 0x00000000 - 0x0007FFFF  Booting Image
 * 0x00080000 - 0x0025FFFF  U-Boot Image
 * 0x00260000 - 0x0027FFFF  U-Boot Env Data (X-loader doesn't care)
 * 0x00280000 - 0x0067FFFF  Kernel Image
 * 0x00680000 - 0x08000000  depends on application
 */
#define NAND_UBOOT_START    0x0080000 /* Leaving first 4 blocks for x-load */
#define NAND_UBOOT_END        0x0260000 /* Giving a space of 2 blocks = 256KB */
#define NAND_BLOCK_SIZE        0x20000

make
./signGP x-load.bin
mv x-load.bin.ift MLO

Build x-loader for nand boot

http://elinux.org/BeagleBoardNAND

Modify include/configs/omap3530mini.h

Disable CONFIG_MMC
//#define CONFIG_MMC 1

make
./signGP x-load.bin
Copy x-load.bin.ift to nand

3.Format SD Card

http://elinux.org/BeagleBoardBeginners

有一些細節要注意,就不再贅述
將MLO copy 到SD card FAT partition (FAT partition一定要是乾淨的)
將x-load.bin.ift copy到 FAT partition

4.Install pre-built 0xdroid images

複製uImage / 0xkernel-beagle.bin / android-beagle.ubi 到SD card FAT parition
退出SD card
Boot from SD card
進入u-boot command

由SD card更新nand flash上的檔案

Refresh x-load.bin.ift

OMAP3 MiniBoard # mmcinit
OMAP3 MiniBoard # fatload mmc 0 ${loadaddr} x-load.bin.ift
reading x-load.bin.ift

11332 bytes read
OMAP3 MiniBoard # nand unlock
Usage:
nand - NAND sub-system

OMAP3 MiniBoard # nand erase 0 40000

NAND erase: device 0 offset 0x0, size 0x40000
Erasing at 0x20000 -- 100% complete.
OK
OMAP3 MiniBoard # nandecc hw
HW ECC selected
OMAP3 MiniBoard # nand write ${loadaddr} 0 40000

NAND write: device 0 offset 0x0, size 0x40000
 262144 bytes written: OK
OMAP3 MiniBoard # nand lock
Usage:
nand - NAND sub-system

Refresh u-boot

OMAP3 MiniBoard # mmcinit
OMAP3 MiniBoard # fatload mmc 0 ${loadaddr} u-boot.bin
reading u-boot.bin

275904 bytes read
OMAP3 MiniBoard # nand erase 80000 1e0000

NAND erase: device 0 offset 0x80000, size 0x1e0000
Erasing at 0x140000 -- 100% complete.
OK
OMAP3 MiniBoard # nand write ${loadaddr} 80000 1e0000

NAND write: device 0 offset 0x80000, size 0x1e0000
 917504 bytes written: OK
OMAP3 MiniBoard #

Refresh uImage.bin

OMAP3 Miniboard # mmcinit
OMAP3 Miniboard # fatload mmc 0 ${loadaddr} uImage-beagle.bin
reading uImage-beagle.bin

2140524 bytes read
OMAP3 Miniboard # nand erase 280000 400000

NAND erase: device 0 offset 0x280000, size 0x400000
Erasing at 0x660000 -- 100% complete.
OK
OMAP3 Miniboard # nand write ${loadaddr} 280000 400000

NAND write: device 0 offset 0x280000, size 0x400000
 4194304 bytes written: OK

5.取出SD card, reboot to install 0xdroid automaticlly.
完成後reboot

6.u-boot environment variable

setenv ubifsargs 'setenv bootargs console=${console} init=/init omapdss.def_disp=dvi omapfb.mode=dvi:1280x1024MR-24@60 root=ubi0:rootfs ubi.mtd=4 rw rootfstype=ubifs'

setenv nandboot 'echo Booting from nand ...; run ubifsargs; nand read ${loadaddr} 280000 400000; bootm ${loadaddr}'

7.0xdroid works

Texas Instruments X-Loader 1.4.2 (Sep 24 2009 - 17:05:57)
MiniBoard V2.0: Run Xloader from SD card
Loading u-boot.bin from nand


U-Boot 2009.08-00217-g30d7aae-dirty ( 9月 24 2009 - 20:23:31)

OMAP3530-GP ES2.1, CPU-OPP2 L3-165MHz
OMAP3 Beagle board + LPDDR/NAND
DRAM:  256 MB
NAND:  512 MiB
In:    serial
Out:   serial
Err:   serial
Beagle Board rev C
Die ID #4b9a00020000000004031c1307010007
Hit any key to stop autoboot:  0
Unknown command 'mmcinit' - try 'help'
Booting from nand ...

NAND read: device 0 offset 0x280000, size 0x400000
 4194304 bytes read: OK
## Booting kernel from Legacy Image at 80200000 ...
   Image Name:   Linux-2.6.29-omap1-g327a826
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2165760 Bytes =  2.1 MB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...




2009年9月15日 星期二

GIT : Remote Repository

0.環境描述

git config --global user.name "Steve Chang"
git config --global user.email stevegigijoe@yahoo.com.tw

gigijoe@user-desktop:~/myandroid$ git config -l
color.ui=auto
user.name=Steve Chang
user.email=stevegigijoe@yahoo.com.tw

sdaemon2專案原始碼在Client端.
建立Client端GIT專案sdaemon2
設定GIT遠端伺服器並建立GIT專案 sdaemon2.
將sdaemon2提交伺服器端

1.伺服器端設定

adduser git
su git
mkdir sdaemon2.git
cd sdaemon2.git
git --bare init

之後會看到以下訊息
Initialized empty Git repository in /home/git/sdaemon2.git

2.Client端GIT專案

cd sdaemon2
git add .
git commit

git log

commit 86c36413882cc8e364c7764e47c025b4c8930437
Author: Steve Chang
Date:   Tue Sep 15 16:03:15 2009 +0800

    Initial version of sdaemon2

git remote add origin git@[server]:sdaemon2.git
git push origin master

The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is 22:f6:c8:69:bb:36:d2:fb:99:5a:f9:62:32:68:75:c3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
git@localhost's password:
Counting objects: 34, done.
Compressing objects: 100% (34/34), done.
Writing objects: 100% (34/34), 43.87 KiB, done.
Total 34 (delta 0), reused 0 (delta 0)
To git@localhost:sdaemon2.git
 * [new branch]      master -> master

git config -l

color.ui=auto
user.name=Steve Chang
user.email=stevegigijoe@yahoo.com.tw
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@localhost:sdaemon2.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

3.其他的Client取得GIT專案

git clone git@[server]:sdaemon2.git

Initialized empty Git repository in /home/gigijoe/VT300/sdaemon2/.git/
git@localhost's password:
remote: Counting objects: 34, done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 34 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (34/34), 43.87 KiB, done.

這時會在目前位置複製一份sdaemon2目錄及原始碼

4.提交更動(commit)

git commit -a

Created commit 9c91092: Add debug message on state machine
 1 files changed, 10 insertions(+), 10 deletions(-)

git push origin master

git@localhost's password:
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 421 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To git@localhost:sdaemon2.git
   86c3641..9c91092  master -> master

5.提取更新

git pull

git@localhost's password:
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From git@localhost:sdaemon2
   86c3641..9c91092  master     -> origin/master
Updating 86c3641..9c91092
Fast forward
 networking.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

6.差異比較

與前一版的差異
git diff HEAD^

or

git show HEAD

與前兩版的差異
git diff HEAD^^

or

git show HEAD^


與前前前前一版的差異
git diff HEAD~4

or

git show HEAD~3


Referance

http://www.wretch.cc/blog/michaeloil/22286355

http://plog.longwin.com.tw/my_note-unix/2009/05/19/git-learn-initial-command-2009

http://www.qweruiop.org/nchcrails/posts/49



2009年9月14日 星期一

UBIFS - Next generation of the JFFS2 file-system

UBIFS 是由NOKIA Engineers開發用於Flash memory的檔案系統.
UBIFS可以視為下一代的Jffs2 file system.
與Jffs2一樣,UBIFS建構於MTD device之上而與一般的block device是不相容的.

1.Jffs2的架構與限制
Jffs2在mount時會scan整個flash所有的資料,再將檔案系統目錄儲存在system memory.
這種作法帶來的缺點是mount動作會消耗很多時間.
而當flash size越大所需的時間及system memory都將成線性倍數成長

Jffs2沒有write-back機制.(write-back : 先cache寫入的資料到一定的量再一次作write動作)
當Application寫入資料,Jffs2幾乎是同步將資料寫入實體flash.
會說幾乎是因為Jffs2的確有一塊NAND page size大小的buffer用來紀錄最後寫入的資料.
沒有write-back機制的缺點是對flash I/O的動作頻繁

Jffs2檔案存取所需要的時間跟檔案大小呈線性倍數成長

Jffs2如果歷經許多檔案小部份修改寫入動作,Jffs2的運作效率會逐漸變差.

2.UBIFS帶來的改進

UBIFS有個子系統UBI用以處理與MTD device之間的動作.
UBIFS檔案系統目錄儲存在flash上.這代表UBIFS mount時不需要scan整個flash的資料來重新建立檔案目錄.
因此mount所需時間約為幾百個ms而且不隨著flash size增加.

UBIFS support write-back.
寫入的資料會被cache住直到有必要寫入時才寫到flash.
這樣的作法降低分散小區塊數量及I/O效率.

但write-back非同步的寫入行為使得Application在寫入檔案時要謹慎處理同步問題.
重要的檔案使用fsync強迫UBIFS將資料寫入flash.

UBIFS supports on-the-flight compression.
UBIFS可壓縮檔案資料而且可選擇性壓縮部份檔案.

UBIFS具有日誌紀錄(journal)以減少檔案目錄更新的頻率


Referance

http://www.linux-mtd.infradead.org/doc/ubifs.html

2009年9月9日 星期三

Linux system time and time zone

Linux上設定time zone的方式有
1.設定環境變數TZ
  TZ=GMT-8

2.編輯/etc/TZ
  echo GMT-8 > /etc/TZ

http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html

以台灣為例,GMT或UTC時區為+8:00(超前8小時)
但TZ環境變數中的超前為負號,故要設為GMT-8, UTC-8 or GMT-8:00也可以
(其實任意XXX-8都可以)

http://linux.vbird.org/linux_server/0440ntp.php

GMT : Greenwich Mean Time (格林威治時間)
UTC : Coordinated Universal Time (協和標準時間)
CST : China Standard Time
epoch : The Unix epoch is the time 00:00:00 UTC on January 1 1970

系統時間可以透過NTP來校正.
而所得到的時間為再透過time zone設定就是local time了

2009年9月4日 星期五

Process handle tips

一些處理行程的技巧

1.防止zombie process產生

http://home.educities.edu.tw/shirock/comp/Anti_zombie_process.htm

linux上的正解

int child_stat;
void reapchild() { 
while( wait(&child_stat) <= 0 )
/*NOTHING or your code*/;
}
. . . 
struct sigaction act;
act.sa_handler = reapchild;
act.sa_flags = SA_NOCLDSTOP; /* Do not signal while process paused */
sigaction( SIGCHLD, &act, NULL);

這個方式不適合在寫library時用
只要用library的人去重設signal就完了

2.system(const char *string)的傳回值

system這個function的return value傳回的是fork process的return value
並不是所執行的程式傳回值.

要拿到執行的程式傳回值要用以下方式

#include

int r;
r = system("ifconfig eth0");
if(WEXITSTATUS(r) == 1) /*Fail*/
return;


2.Fork

pid_t pid;
if((pid = vfork()) == 0) { /*Child*/
execl("/bin/ping", "ping", "-c", "3", ip, (char *)0);
_exit(127);
} else if(pid < 0)
perror("fork");
else /*Parent*/
dev->ping->pid = pid;

.......
.......

int status;
pid_t pid = waitpid(dev->ping->pid, &status, WNOHANG);
if(pid > 0)
if(WIFEXITED(status)) {
dev->ping->pid = 0;
if(WEXITSTATUS(status) != 0) { /*ping without response*/
SxNetDev_Fail(dev, "Ping fail");
return;
} else {
SxNetDev_Connect(dev);
SxNetDev_Ping(dev, config->pppoe.ping);
}
}