星期日(昨天)上 模組D嵌入式系統專案實作, 完成 Boa 移植至 ARM-PXA270,也完成移植 SQLite ,同時間寫一支可以控制子板上的LED之CGI程式,控制 LED 閃爍是透過 驅動程式 LED.ko( 這一支程式 在 模組C Step by Step講授嵌入式開發板Linux驅動程式實務班 已經完成,這裡只是拿來使用) 。 有關 Boa移植步驟如下:
第一步:自www.boa.org下載Boa原始程式,將其解壓縮,之後進入原始碼目錄的src子目錄。
# tar xzf boa-0.94.13.tar.gz
# cd boa-0.94.13/src
第二步:接著建立Makefile文件,並修改其內容
# ./configure
修改Makefile文件,找到CC=gcc和CPP=gcc -E,分別將其改為CC=arm-linux-gcc和CPP=arm-linux-gcc –E,之後存檔退出。
第三步:運行make進行Boa編譯,得到可執行程式boa
# make
但我在實作時,希望Boa是在 /tmp/boadir 目錄下執行,配置檔也是在此目錄。
所以增加修改步驟如下:
第一步:在 boa.h 檔加上 #define SERVER_ROOT "/tmp/boadir"
第二步:修改 src/compat.h,
找到 #define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
將其修改成
#define TIMEZONE_OFFSET(foo) (foo)->tm_gmtoff
再行make即可。
有關 Boa的配置:
將boa.conf複製到 /tmp/boadir,之後進行Boa的配置。
1.Group nogroup修改成Group 0,User nobody修改成User 0。
2.ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 修改成 ScriptAlias /cgi-bin/ /tmp/boadir/cgi-bin/
3. ErrorLog 的後面改為 /tmp/boadir/error_log
4. AccessLog的後面改為 /tmp/boadir/access_log
5. DocumentRoot的後面改為 /tmp/boadir
6. DirectoryMaker的後面改為 /tmp/boadir/boa_indexer
7. MimeTypes的後面改為 /tmp/boadir/mime.types
其他默認設置即可。
這樣的設定,靜態網頁(html)存放的目錄在/tmp/boadir, CGI腳本所在目錄是/tmp/boadir/cgi-bin/。另外請將mime.types檔複製/tmp/boadir目錄下。
測試靜態HTML網頁:
在目標板上運行boa程式,將主機與目標板的ip設成同一網段,然後打開任一個流覽器(linux或window下都可),輸入目標板的ip位址(http://192.168.10.222)即可打開/tmp/boadir/index.html網頁
設定執行畫面如下:
接著在 瀏覽器 上輸入 http://192.168.10.222/,即可透過網路,由BoaParse index.html到瀏覽器,瀏覽器畫面如下:
CGI腳本測試:
下面是一個簡單的LED Cgi程式測試,在瀏覽器上鍵入 http://192.168.10.222/index_byCGI.html,。
之後在 可input 的EDIT裡,鍵入如上圖所示,在按下"送出",此時ARM-PXA270的IO子版之LED,便開始交互閃爍。下圖先依照 10101010 讓LED 亮暗亮暗亮暗亮暗。
接著在 依照 01010101 讓LED 暗亮暗亮暗亮暗亮。
之後網頁顯示剛剛輸入的鍵值畫面:
改成輸入 00001111及11110000,讓LED一次左右同時亮暗四個。
CGI程式如下:
/*
*myTest.c - A CGI Test program.
*Authored by YiHua,Chiang
*EMail: microcyh@seed.net.tw
*CYH' Blog: http://tw.myblog.yahoo.com/yh-chiang
*
*Copyright(C) 2009/01/07 http://tw.myblog.yahoo.com/yh-chiang
*
*This program is free software. you can redistribute it and/or
*modify it under the terms of the GNU Public License as published
*by the Free Software Foundation: version 2 of the license.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU Lesser Public License for more details.
*/
#include
#include
#include
#include
#include
int main()
{
char *ShowStr1, *ShowStr2;
cgiVar *cgi;
int fd, n;
cgi = (cgiVar *)cgiInit();
ShowStr1 = (char *)malloc( 9 );
ShowStr2 = (char *)malloc( 9 );
strcpy( ShowStr1 , (char *)cgiGetString(cgi, "a1") );
strcpy( ShowStr2 , (char *)cgiGetString(cgi, "a2") );
printf("%s%c%c\n","Content-Type:text/html;charset=iso-8859-1",13,10);
printf("");
printf("");
printf(" myTest.cgi ");
printf("");
printf("");
printf("sizeof(cgi)=%d
", sizeof(cgi) );
printf("a1=%s
", ShowStr1 );
printf("a2=%s
", ShowStr2 );
printf("");
printf("");
cgiFree( cgi );
fd = open( "/dev/LED", O_RDWR ); // call open:LEDopen
for( n=0; n<=10; n++)
{
write( fd, ShowStr1,9 );
sleep( 1 );
write( fd, ShowStr2 ,9 );
sleep( 1 );
}
close( fd );
free( ShowStr1 );
free( ShowStr2 );
return 0;
}
你好
回覆刪除我依你的步驟做完後
再版子執行./boa &後 ps aux 沒看到boa 執行常駐
不知為何?
嗯 .... 是否執行 ./boa & 後,有出現訊息( 錯誤的訊息 )?
回覆刪除在上模組D 的課程時,全部的學員都有完成 這個 BOA 的移植實作,應該沒問題囉^^