Home > Linux, Linux 2.4, Programming, Sigma Designs EM862X > HTTP Server for uCLinux

HTTP Server for uCLinux

December 22nd, 2010 Leave a comment Go to comments

You may need a web server on your no-MMU embedded system in order to allow remote configuration or possibly provide external access to some files.

Usually, you’ll need a lightweight webserver (e.g. not Apache) with the required features and in case of no-mmu system, source that can accommodates uClinux limitations such as no fork support. You’ll also take into account the programming language or the server: e.g. C/C++. Java, Ruby, Perl… If your system does not support Java or Perl for example, that may not be the best solution to add one of those only for the web server and it also depends on the resources (Flash/RAM) available.

Router Web Configuration

Network Configuration Page rendered by a Web Server

There are plenty of C/C++ lightweight http servers such as thttpd or lighttpd, however those are using fork in their code.

One open source http server that is lightweight and uses vfork (instead of fork) is mathopd.

At the time of writing, the latest version is mathopd 1.5p6.

mathopd supports the following:

  • HTTP/1.1 including persistent connections, partial responses and pipelining.
  • CGI/1.1

To cross-compile it (e.g. using arm-elf-gcc for Sigma Designs EM862X), go to mathopd-1.5p6/src and edit the Makefile as follows:

BIN = mathopd
CC = arm-elf-gcc
CFLAGS = -O -Wall
CPPFLAGS =
LDFLAGS = -Wl,-elf2flt
LIBS = -lcrypt
PREFIX = /usr/local
SBINDIR = $(PREFIX)/sbin

and run make. That’s it !

In your target you’ll need to create /etc/mathopd.conf to configure mathopd. It you want to have you web files in www, it could look like:

 User nobody

 Control {
     Types {
         text/html { .htm }
         text/html { .html }
         text/plain { .txt }
         image/gif { .gif }
         image/png { .png }
         image/jpeg { .jpg }
         text/css { .css }
         application/octet-stream { * }
     }
     IndexNames { index.htm }
 }

 Server {
     Virtual {
         AnyHost
         Control {
             Alias /
             Location /www
        }
     }
 }

Finally copy mathopd to your path, copy your web pages, pictures and cgi in www and run it in your target board as follows:

mathopd -f /etc/mathopd.cfg

To try it, simply access your board though your browser as follows:

http://board_ip

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

  1. No comments yet.
  1. No trackbacks yet.