ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

Firmware Description


Circuit Cellar Online
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.

Archive

A $25 WEB SERVER

by Steve Freyder, David Helland, Bruce Lightner

StartNetwork AdapterFirmware DescriptionSoftware DevelopmentFirmware Development EnvironmentThe Next Generation And BeyondSources

FIRMWARE DESCRIPTION

The PicoWeb server’s demonstration firmware supports a simple kernel, a tiny debug monitor, a p-code interpreter, a network adapter driver, a TCP/IP stack, and an HTTP server (i.e., web server). Let’s look at what kinds of network messages the PicoWeb server responds to and what the responses are.

At the lowest level, the PicoWeb server responds to network ARP requests identifying it as an active device on the network with an assigned IP Address. Every PicoWeb server is assigned a unique Ethernet address that is sent as part of the ARP reply packet.

Next, we’ll look at the BOOTP request. An IP address can be assigned to the device statically by storing the device’s IP address in the microcontroller’s flash memory or dynamically by using the BOOTP protocol. When configured for dynamic IP address assignment, the PicoWeb server will begin sending periodic BOOTP requests after powerup until an appropriate reply is received.

The PicoWeb server’s unique Ethernet address is broadcast as part of the BOOTP request packet. If a valid BOOTP response is received, the PicoWeb server uses the contents of the response to set its IP address. A Windows 95/98/NT version of a BOOTP server program is also available. This program uses a text file that maps PicoWeb server Ethernet addresses into assigned IP addresses.

The PicoWeb server also responds to ICMP echo, or ping, requests. The server responds to ICMP echo requests by responding with an echo reply. ICMP echo requests are typically generated by using a program called ping on a remote host. The ping program enables users to quickly test network connectivity with the PicoWeb server and evaluate the round trip time (RTT) of the echo request/replies.

The PicoWeb server can send and receive UDP packets. However, the breadboard prototype’s demonstration firmware does not make use of this capability.

At the TCP/IP level, the PicoWeb server responds to HTTP GET requests that are addressed to its IP address. HTTP GET requests are sent by web browsers such as Netscape Communicator or Microsoft’s Internet Explorer. Our web server responds to these requests by sending back HTML documents, text, images, and so on, just like a "real" web server. The only difference is that we don’t need a giant OS with its attendant large memories, fancy TCP/IP stacks, expensive microprocessors, and high power consumption to get the same results!

The demonstration firmware purposely restricts the maximum size of an HTTP GET response to a single Ethernet packet (i.e., no more than 1400 bytes of TCP/IP payload) to conserve memory resources. In the context of an embedded web server using this class of low-cost microcontroller, this restriction is not an unreasonable tradeoff. A number of HTML coding techniques can be used to work within these limits, including the use of HTML frames and the "gluing together" of multiple GIF and JPEG images using things like HTML tables.

The demonstration firmware’s basic response to an HTTP GET request is shown in Photo 2. The basic response is to return a web page that shows a title, two radio buttons, an update button, and a few JPEG images. The two radio buttons show the state of the LED on the demonstration board.

Photo 2—Everything on this web page is delivered directly by the PicoWeb server including the JPEG images. A user can change the state of the PicoWeb’s diagnostic LED using the radio buttons. The temperature shown is from a Dallas DS1621 two-wire digital thermometer chip attached to the PicoWeb using a couple of unused digital I/O lines.

 

The user can click the radio buttons to change the state of the LEDs (i.e., to on or off) and then click the Set LED button to send the new state information to the PicoWeb server. The server responds by setting the LEDs according to the request and then updates the returned web page to reflect the current state of the LEDs. Those of you familiar with server-side web programming will recognize this as the typical behavior of a cgi-bin script. The images shown on the sample web page are also supplied by the PicoWeb server.

The PicoWeb server demonstration firmware contains a simple, extensible debugger that provides for things like memory dumps, EEPROM alteration, p-code and network tracing control, and more. Debugger commands such as those in Table 2 can be entered via the serial port, or via the network using a web browser and a URL that references a special TCP port (i.e., port 911).

Command Description
dm XXXX nn dump SRAM from XXXX...XXXX+nn-1
de XXXX nn dump EEPROM from XXXX...XXXX+nn-1
ds XXXX nn dump serial EEPROM from XXXX...XXXX+nn-1
wm XXXX YY write SRAM address XXXX with byte YY
we XXXX YY write serial EEPROM address XXXX with byte YY
ws XXXX YY write EEPROM address XXXX with byte YY
l toggle TCP packet logging on/off
pd n control p-code debug trace (0=off; 1=on)
PC XXXX call p-code routine at address XXXX
R reset processor
^C reset processor (serial port only)

Table 2—Debugger commands like these can be sent over the network using a web browser or via the PicoWeb’s serial port.

 

The format of a debugger command URL is http://IPaddress:911/command[[+parameter1]+parameter2]

Any results from executing a debug command will be returned as a web page. For example, http://IPaddress:911/dm+60+80 will list the contents of the first 128 bytes of the microcontroller’s SRAM. New debugger commands can easily be added (or deleted to save program code space).

The PicoWeb server’s prime function is to return web pages and images in response to HTTP GET requests directed to URLs targeting its HTTP server. The PicoWeb server’s firmware responds to URL queries directed to TCP port 80 in a conventional manner. Because the PicoWeb server doesn’t have a true file system, URLs trigger dedicated routines in the firmware as opposed to simply returning the contents of a disk file.

A summary of the standard URLs implemented in the PicoWeb server’s demonstration firmware are shown in Table 3 (note that the http://IPaddress part of the URL does not appear in the table). Either http://IPaddress or http://IPaddress/ii00.html will retrieve the default web page (home page) from the PicoWeb server.

URL Description
/ Return document ii00.
/iihh Return document number hh to user. Documents numbers are two-digit hex values. Anything after hh in the URL is ignored.
/iuhh Call firmware routine number hh. Mostly useful for testing "html include" routines.
/x?n=value Set digital I/O port bit n to value where value is either 0 or 1. Because the breadboard LED’s anode is connected to bit 0, the command "/x?2=0" turns on the LED.
Table 3—Certain PicoWeb server firmware routines can be activated by referencing special URLs. This arrangement provides simple remote control of the Atmel micro’s digital I/O lines.

PREVIOUSNEXT


Circuit Cellar provides up-to-date information for engineers. Visit www.circuitcellar.com for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com or subscribe online. ęCircuit Cellar, the Magazine for Computer Applications. Posted with permission.

 

 

Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ