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.
…or you could just stream the files from storage, instead of loading them up into the limited RAM first?
“One constraint which [Andrew] imposed upon himself” read much?
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.
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.
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.
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.
Reminds me the smallest web server in the world using the now defunct Fairchild’s ACE microcontroller
http://d116.com/ace/
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.
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.
Basically no memory eh? Like the joke about recursive compression until you reach infinite storage….
I wish I had courses like that when I was in school.
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.
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.
which would be all fine and dandy in an ideal job market where ALL employers weren’t demanding 2-5 years of practical experience…
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.
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.
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
Were you able to get it running? I’m trying to implement the same but i’m not able to do it