Circuit Cellar Magazine is a magazine devoted to embedded hardware design, mainly with low-end microcontrollers. It was started by my hardware hero Steve Ciarcia (of Byte Magazine fame) around 15 years ago, and I read it every month even though I haven't done any real MCU design since I was in college.
The September 2002 issue (#146) has a stunning feature article by Jim Brady: Build Your Own 8051 Web Server.
The Intel 8051 is a workhorse 8-bit microcontroller, and it's been in use for more than 20 years. Though getting a web server on an 8051 is a great feat in any case, when I read the headline I was sure that Jim had "cheated" by using one of the external networking chipsets that implements Ethernet and TCP/IP in firmware, and the main MCU talks to the network chipset over a serial connection. I read the article. No way.
He did a TCP/IP stack and web server on an eight-bit microcontroller in 22 kilobytes of codespace and 2 kilobytes of RAM. This is just spectactular. He implemented ARP, IP and TCP (no UDP), as these are all that are required for a working web server. The source code suggests that the stack handles ICMP as well, though this is not mentioned in the article.
One of the points that particularly caught my fancy was this:
Can a CPU with only 2 KB of RAM really handle large Ethernet messages and the complexities of protocols such as TCP and ARP? Surprisingly, it turns out that even a few hundred bytes would suffice. Small RAM footprints work with TCP because you can tell the other end to limit the message size. TCP can, for example, advertise a maximum segment size of only 100 bytes.
This solves a hardware problem (limited RAM) in software. I love it.
To be fair, the stack doesn’t appear to be anywhere near a full one: plenty of things look unimplemented, such as fragmentation and many of the TCP options. I note with amusement that “Respect other end's max segment size” is not implemented. I doubt that the device would fare well in a hostile environment, such as directly connected to the internet, but none of these limitations take away for the magnitude of the accomplishment: when you teach a dog to talk, you don’t worry so much about bad grammar.
The source code is quite readable and the hardware design is straightforward: just nothing about this not to like.
Jim Brady – you da man!
Posted by Steve at September 10, 2002 07:04 AM | TrackBackI need Your Project
Posted by: Khothibul Umam on March 14, 2003 05:39 PMHi Jim.
I am very interesting in your project, Could you share them for me? Thanks.
this is really great work.Most people write such code in C and cross compile only to generate bulk code.this is a good approach and more useful.
Posted by: madhu malhar on November 14, 2003 02:37 AMHi dear
I am very interesting in your project, Could you share them for me? Thanks.