Project:HUGnet:Core Firmware

From HUG Wiki

Jump to: navigation, search

This is the firmware that is in the embedded PC that is our data collector. It is stored in the flash memory that is the only permanent storage for the data collector.

It is now based on OpenWrt Kamikaze. It was previously based on embedded Gentoo. This change was made because OpenWrt has everything already set up, whereas embedded Gentoo everything has to be set up. This is fine for me, but confusing for other people not as familiar with Gentoo.

Contents

Building the Firmware

Use the following to build OpenWrt:

Setup

The following will check out the SVN code:

# svn -q checkout https://svn.hugllc.com/HUGnet/trunk/Core Core

Building

The following will build the software:

# cd Core
# make world

The Result

You result will be stored in kamikaze/bin/

The image you want is called openwrt-x86-jffs2-128k.image

This can be moved to a flash card (in Linux) using:

# dd if=kamikaze/bin/openwrt-x86-jffs2-128k.image of=/path/to/flash/card/device

Emulating

Make the image the right size

(taken from http://wiki.openwrt.org/RunningKamikazeOnQEMUHowTo?highlight=%28qemu%29)

$ fdisk openwrt-x86-jffs2-128k.image
You must set cylinders.
You can do this from the extra functions menu.

Command (m for help): p

Disk openwrt-x86-2.6-jffs2-128k.image: 0 MB, 0 bytes
16 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

                           Device Boot      Start         End      Blocks   Id System
openwrt-x86-jffs2-128k.image1   *           1           9        4504+  83 Linux
openwrt-x86-jffs2-128k.image2              10          42       16600+  83 Linux

Command (m for help): q

$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
42*1008
42336

$ dd if=/dev/null of=openwrt-x86-2.6-jffs2-128k.image seek=42336
0+0 records in
0+0 records out
0 bytes (0 B) copied, 2.5e-05 seconds, 0 B/s

$ ls -l openwrt-x86-jffs2-128k.image
-rw-r--r-- 1 yourname yourname 21676032 2007-10-23 11:20

Emulating

# make emulate

BusyBox httpd

The following is taken from httpd.c in busybox v1.90.

* Copyright (C) 2002,2003 Glenn Engel <glenne@engel.org>
* Copyright (C) 2003-2006 Vladimir Oleynik <dzo@simtreas.ru>
*****************************************************************************
*
* Typical usage:
*   for non root user
* httpd -p 8080 -h $HOME/public_html
*   or for daemon start from rc script with uid=0:
* httpd -u www
* This is equivalent if www user have uid=80 to
* httpd -p 80 -u 80 -h /www -c /etc/httpd.conf -r "Web Server Authentication"
*
*
* When a url starts by "/cgi-bin/" it is assumed to be a cgi script.  The
* server changes directory to the location of the script and executes it
* after setting QUERY_STRING and other environment variables.
*
* Doc:
* "CGI Environment Variables": http://hoohoo.ncsa.uiuc.edu/cgi/env.html
*
* The server can also be invoked as a url arg decoder and html text encoder
* as follows:
*  foo=`httpd -d $foo`           # decode "Hello%20World" as "Hello World"
*  bar=`httpd -e "<Hello World>"`  # encode as "&#60Hello&#32World&#62"
* Note that url encoding for arguments is not the same as html encoding for
* presentation.  -d decodes a url-encoded argument while -e encodes in html
* for page display.
*
* httpd.conf has the following format:
*
* A:172.20.         # Allow address from 172.20.0.0/16
* A:10.0.0.0/25     # Allow any address from 10.0.0.0-10.0.0.127
* A:10.0.0.0/255.255.255.128  # Allow any address that previous set
* A:127.0.0.1       # Allow local loopback connections
* D:*               # Deny from other IP connections
* E404:/path/e404.html # /path/e404.html is the 404 (not found) error page
*
* P:/url:[http://]hostname[:port]/new/path
*                   # When /urlXXXXXX is requested, reverse proxy
*                   # it to http://hostname[:port]/new/pathXXXXXX
*
* /cgi-bin:foo:bar  # Require user foo, pwd bar on urls starting with /cgi-bin/
* /adm:admin:setup  # Require user admin, pwd setup on urls starting with /adm/
* /adm:toor:PaSsWd  # or user toor, pwd PaSsWd on urls starting with /adm/
* .au:audio/basic   # additional mime type for audio.au files
* *.php:/path/php   # running cgi.php scripts through an interpreter
*
* A/D may be as a/d or allow/deny - first char case insensitive
* Deny IP rules take precedence over allow rules.
*
*
* The Deny/Allow IP logic:
*
*  - Default is to allow all.  No addresses are denied unless
*         denied with a D: rule.
*  - Order of Deny/Allow rules is significant
*  - Deny rules take precedence over allow rules.
*  - If a deny all rule (D:*) is used it acts as a catch-all for unmatched
*       addresses.
*  - Specification of Allow all (A:*) is a no-op
*
* Example:
*   1. Allow only specified addresses
*     A:172.20          # Allow any address that begins with 172.20.
*     A:10.10.          # Allow any address that begins with 10.10.
*     A:127.0.0.1       # Allow local loopback connections
*     D:*               # Deny from other IP connections
*
*   2. Only deny specified addresses
*     D:1.2.3.        # deny from 1.2.3.0 - 1.2.3.255
*     D:2.3.4.        # deny from 2.3.4.0 - 2.3.4.255
*     A:*             # (optional line added for clarity)
*
* If a sub directory contains a config file it is parsed and merged with
* any existing settings as if it was appended to the original configuration.
*
* subdir paths are relative to the containing subdir and thus cannot
* affect the parent rules.
*
* Note that since the sub dir is parsed in the forked thread servicing the
* subdir http request, any merge is discarded when the process exits.  As a
* result, the subdir settings only have a lifetime of a single request.
*
* Custom error pages can contain an absolute path or be relative to
* 'home_httpd'. Error pages are to be static files (no CGI or script). Error
* page can only be defined in the root configuration file and are not taken
* into account in local (directories) config files.
*
* If -c is not set, an attempt will be made to open the default
* root configuration file.  If -c is set and the file is not found, the
* server exits with an error.

SVN Access

The svn file path for this is:

  • Trunk : /HUGnet/trunk/OpenWrt/
  • Tags : /HUGnet/tags/OpenWrt/

See SVN Code Repository for more information

See Also