Embedded web server is all about clever formatting

embedded-web-server

Take a look around here and you’ll find all kinds of embedded web servers. This one doesn’t look all that interesting, especially because it’s just a NIC plugged into a development board. But for us the interesting part is in how [Andrew Rossignol] chose to format the webpage assets to best utilize the under-powered server.

The project was spawned as part of a class in Internet Embedded Systems which [Andrew] is taking. The board has an ATmega16 microcontroller and he’s using the ever popular ENC28J60 on that Ethernet adapter board. The TuxGraphics TCP/IP Stack takes care of communications with the network.

One constraint which [Andrew] imposed upon himself was to use just a single response which the available RAM limits to about  700 bytes. Any decent webpage needs to have at least some graphics but that’s tough with the size limit. He managed to display an AVR logo by optimizing an SVG in Inkscape then stripped the rest of the cruft using VIM (explained in the demo after the break). With that piece of Linux-fu in his pocket he set to work streamlining the CSS file. The webpage isn’t just static either. He displays the server up-time and even allows the relays and LEDs on the Olimex board to be controlled.

Despite the limitations of the ATmega family they still seem to do some amazing Internet-connected stuff. Here’s one used as a Minecraft server.

Comments

  1. Sprite_tm says:

    …or you could just stream the files from storage, instead of loading them up into the limited RAM first?

    • aliveoneee says:

      “One constraint which [Andrew] imposed upon himself” read much?

      • Arlet says:

        The original article says: “One severe limitation of this hardware is the 1kB of RAM. This limits the response size to approximately 700 bytes.”

        He doesn’t talk about directly sending a single response from flash, so it’s possible he didn’t think of that option.

        • Andrew says:

          I did consider this option, but decided not to go this route. At some point, program memory is going to become a concern as well so I might as well minimize as much as possible. The image is already about 11kB out of the total 16kB.

          It was more “because I can” when limiting myself to the small buffer size.

          • Sprite_tm says:

            I don’t think that’d be an issue anyway: the data has to come from somewhere before it goes into RAM, so it could just as well be streamed from that location without putting a RAM-buffer in between. I respect your ‘because I can’, by the way, it’s always good to practice, just saying this probably isn’t the most optimal way to get low RAM usage.

          • Marko says:

            ATMEGA324 or ATMEGA644 will drop in where a 16 goes, if you ever need more ROM. I think they have more RAM as well, but don’t remember off hand.

  2. wetomelo says:

    Reminds me the smallest web server in the world using the now defunct Fairchild’s ACE microcontroller

    http://d116.com/ace/

  3. AS says:

    Did you (Andrew) look into doing some compression to get a bit more space. RLE takes basically no memory for decode/encode and can be just about as fast as direct memcpy.

    • computerwiz222 says:

      I had thought about using runs, but gzipping done at compile time and provides better compression ratios. I don’t think run length encoding gzipped content would be a good idea.

      I basically have a web folder full of my js, css and html files that are gzipped and converted into h file includes. This system has no notion of a file system.

    • smee says:

      Basically no memory eh? Like the joke about recursive compression until you reach infinite storage….

  4. chadberg says:

    I wish I had courses like that when I was in school.

    • Al says:

      Yea, schools tend to teach way too much theory and not enough practical stuff. They should go hand in hand. I still get irritated about that from my old school dayz.

      • Drone says:

        I disagree, a good university Engineering education concentrates on the underlying mathematics and physics that make all these wonderful technologies possible. You don’t want to spend much of your precious university time banging on software and hardware that will be obsolete in a few years. Yes, some lab work is necessary in school to bring theory to life, but that’s not the focus. After you get a job – that’s when your education continues at the nuts & bolts level you desire.

  5. Drone says:

    As for limited storage, Why not just put an SD flash card on the thing and use a couple of pins to get stuff in and out. I think there are at least a few pre-built SD card FS library options for AVR out there.

  6. cmholm says:

    While the old the5k.org entries wouldn’t have had a prayer on this device, perhaps the current js1k.com competitors could squeeze their code just a *bit* tighter.

  7. Gaurav says:

    hey andrew,
    Can you please share your code.. I am trying to implement the same thing with Mega16 running on 8 MHz and ENC28j60 breakout module..i am not able to taste the sucess..please help…I am using AVRSTUDIO 5.0 on XP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 92,428 other followers