S3C44B0(1):uclinux中boa web server的配置

来源:互联网 发布:vb elseif 用法 编辑:程序博客网 时间:2024/05/22 04:48

uclinuxboa web server的配置

(转贴并修改)

一、环境准备

编译环境:arm-elf-tools-20040427.sh

编译工具:arm-elf-*

板子型号:s3c44b0 公测板

 

二、编译配置

1、选择Kernel/Library/Defaults Selection -> Customize Vendor/User Settings -> Network Applications -> boa

选择 Kernel/Library/Defaults Selection -> Customize Vendor/User Settings -> BusyBox -> modprobe

选择 Kernel/Library/Defaults Selection -> Customize Kernel Settings -> Networking options -> Unix domain sockets

具体原因见 (. 调试)

 

2、配置boa web server:

2.1、修改文件uClinux-dist/user/boa/src/defines.h

#define SERVER_ROOT "/home/httpd"改成#define SERVER_ROOT "/etc/boa"

意思是设定boa web serverServerRoot路径为/etc/boa

 

2.2、编辑配置文件uClinux-dist/user/boa/examples/boa.conf,如下

Port 80

User 0

Group 0

DocumentRoot /home/web

UserDir public_html

DirectoryIndex index.html

KeepAliveMax 1000

KeepAliveTimeout 10

DefaultType text/html

AddType application/x-httpd-cgi cgi

ScriptAlias /cgi-bin/ /home/web/cgi-bin/

AddType image/jpeg jpg

(注意:一定不能选var目录,因为romfs文件系统的var目录启动后,会被清空。)

 

关于配置文件的几点说明:

1)所以的*Log选项都被注释掉了,否则启动boa的时候提示说不识别这些*Log标记;

2)没有添加"mime.types"选项,原因详见boa测试图片显示乱码;

3)配置文件boa.conf需拷贝到ServerRoot,可以手动,也可以通过修改Makefile文件(uClinux-dist/vendors/PHILIPS/lpc2200/Makefile)进行;

如果配置文件boa.conf的位置不正确,则会得到形如“Authentication password file for /cgi-bin/ not found!”之类的错误!

2.3建目录

由于uClinux默认的根文件系统romfs是只读的,不能用mkdir等命令来新建目录,故应在编译内核前先建好要用到的目录,这通过修改/uClinux-dist/vendors/Samsung/44B0/makefile文件来实现。在ROMFS_DIRS=bin dev etc home lib mnt proc usr var的后边增加home/web home/web/cgi-bin etc/boa,这样修改后编译内核,编译好的根文件系统romfs中就包含这些目录了。

 

 

三、编译和烧写

进入到uClinux-dist 目录下执行:

make dep

make clean

make lib_only

make user_only

make romfs

这个时候在uClinux-dist/romfs目录下就会出现我们所设置的目录,将romfs/home/index.html拷贝到romfs/home/web目录下,将/uClinux-dist/user/boa/util/cgi-test.cgi 拷贝到 romfs/home/web/cgi-bin/目录下,改为test.cgi

 

make image

make

 

然后将uClinux-dist/images/uclinux_rom.bin拷贝到WINDOWS系统中与tftp server程序同目录下。

1)启动tftp 程序。

 (2) 开发板加电启动,进入到u-boot界面,用print命令查看网络设置是否正常。

3)在u-boot界面中

itsn_44b0=>print

bootargs=devfs=mount root=ramfs console=ttyS0,9600

bootcmd=bootm 0x50000

bootdelay=3

baudrate=115200

ethaddr=00:50:c2:1e:af:fb

ipaddr=192.168.0.30

netmask=255.255.255.0

serverip=192.168.0.105

bootfile="uclinux_rom.bin"

stdin=serial

stdout=serial

stderr=serial

 

Environment size: 260/65532 bytes

itsn_44b0=>tftp 0xc208000               

#因为不想过早的磨损FLASH芯片,所以下到RAM中运行,因为一般内核都不会大于2M,所以放在2M位置的高地址。

TFTP from server 192.168.0.105; our IP address is 192.168.0.30

Filename 'uclinux_rom.bin'.

Load address: 0xc208000

Loading: #################################################################

         #################################################################

         #################################################################

         #################################################################

         ###########

done

Bytes transferred = 1382687 (15191f hex)

itsn_44b0=>bootm 0xc208000

#直接用u-boot来引导。开发板不能重启呀,否则这个内核就被清除掉了。

然后在IE中输入http://开发板地址/  就可以看到界面了。

 

四、调试 (原作者撰写)

1、如果现在运行boa & (或者运行boa -c /var/www &,但我们已指定DocumentRoot /var/www,所以运行外面的命令就行),会得到错误信息“kmod: failed to exec /sbin/modprobe -s -k net-pf-1, errno = 2,此时boa web server还不可用!

2、增加编译Kernel/Library/Defaults Selection -> Customize Vendor/User Settings -> BusyBox -> modprobe并重新编译,此时运行boa &又会得到如下错误信息:

__alloc_pages: 6-order allocation failed (gfp=0x1f0/0)

Allocation of length 164704 from process 193 failed

Buffer memory: 52kB

Cache memory: 1076kB

Free pages: 876kB ( 0kB HighMem)

Zone:DMA freepages: 0kB

Zone:Normal freepages: 876kB

Zone:HighMem freepages: 0kB

( Active: 94, inactive: 188, free: 219 )

= 0kB)

25*4kB 21*8kB 12*16kB 5*32kB 2*64kB 1*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB = 876kB)

= 0kB)

Unable to mmap process text, errno 12

kmod: failed to exec /sbin/modprobe -s -k net-pf-1, errno = 12

__alloc_pages: 6-order allocation failed (gfp=0x1f0/0)

Allocation of length 164704 from process 195 failed

Buffer memory: 52kB

Cache memory: 1076kB

Free pages: 700kB ( 0kB HighMem)

Zone:DMA freepages: 0kB

Zone:Normal freepages: 700kB

Zone:HighMem freepages: 0kB

( Active: 47, inactive: 235, free: 175 )

= 0kB)

25*4kB 19*8kB 12*16kB 4*32kB 2*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB = 700kB)

= 0kB)

Unable to mmap process text, errno 12

munmap of non-mmaped memory by process 195 (insmod): 817fb000

munmap of non-mmaped memory by process 195 (insmod): 815863a0

Unhandled fault: external abort on linefetch (F4) at 0x00000001

fault-common.c(97): start_code=0x81380040, start_stack=0x815bff74)

pid 182: failed 256

好像是内存分配错误!但此时boa web server已经可以访问!

3、增加编译Kernel/Library/Defaults Selection -> Customize Kernel Settings -> Networking options -> Unix domain sockets并从新编译,则boa web server再启动时除了一个pid外,没任何多余的信息了!(此选项到底有什么作用,我还是不知道!)

 

五、其它说明(原作者撰写)

1、我的uclinux的大部分配置都是“默认”的,但这里的“默认”可能是已被硬件厂商修改过的(我用的uClinux-dist-20040427.tar.gz是附带光盘里面的)!

2web测试时,html文件应放在/var/www目录下,cgi程序应放在/var/www/cgi-bin目录下,这些在配置文件中都写的很明确!

3、也可以通过nfs进行web测试(这样会免去多次烧写的麻烦)nfs的配置详见http://wzc0066.blog.hexun.com/6582493_d.html中的第一点。

 

五、现存问题(原作者撰写)

现在cgijavascript、图片浏览等测试都良好!

但在测mp3的时候,还不行,原因可能是还不支持大文件!

我看网上说uclinux好像默认每次分配的最大内存是128K,所以要是运行大于128K的文件就会出错,不知是不是这样!

 

我还看到一条信息说选择Kernel hacking中的一项配置后就可支持大文件了,但我现在的2.4.x内核中没找到网上说的那一项!

现在点击一mp3文件(二点几M大小)的链接时终端出现的错误信息为:

Allocation of length 2502723 from process 24 failed

Buffer memory:       56kB

Cache memory:     2744kB

Free pages:        2420kB (     0kB HighMem)

Zone:DMA freepages:     0kB

Zone:Normal freepages:  2420kB

Zone:HighMem freepages:     0kB

( Active: 98, inactive: 602, free: 605 )

= 0kB)

7*4kB 9*8kB 11*16kB 7*32kB 4*64kB 1*128kB 0*256kB 1*512kB 1*1024kB 0*2048kB = 2420kB)

= 0kB)

munmap of non-mmaped memory by process 24 (boa): ffffffff

 

当运行一个超过1M的应用程序时,uclinux系统会报内存分配错误!
在编译内核时需要选中“Allow allocating large blocks (> 1MB) of memory”这一选项后就可以解决问题!
但是要找到这个选项的位置对于新手来说还不是太容易, 下面是详细操作过程:

该配置选项所对应的宏定义是:CONFIG_NO_MMU_LARGE_ALLOCS
首先需要选中Code maturity level options 中的 Prompt for development and/or incomplete code/drivers
然后在Kernel hacking 中才可以看到 Non power-of-2 kernel allocator (EXPERIMENTAL)选项,
选中该选项之后就可以看到Allow allocating large blocks (> 1MB) of memory, 选中即可!

原创粉丝点击