Want To Learn Ethernet? Write Your Own Darn AVR Bootloader!

There’s a school of thought that says that to fully understand something, you need to build it yourself. OK, we’re not sure it’s really a school of thought, but that describes a heck of a lot of projects around these parts.

[Tim] aka [mitxela] wrote kiloboot partly because he wanted an Ethernet-capable Trivial File Transfer Protocol (TFTP) bootloader for an ATMega-powered project, and partly because he wanted to understand the Internet. See, if you’re writing a bootloader, you’ve got a limited amount of space and no device drivers or libraries of any kind to fall back on, so you’re going to learn your topic of choice the hard way.

[Tim]’s writeup of the odyssey of cramming so much into 1,000 bytes of code is fantastic. While explaining the Internet takes significantly more space than the Ethernet-capable bootloader itself, we’d wager that you’ll enjoy the compressed overview of UDP, IP, TFTP, and AVR bootloader wizardry as much as we did. And yes, at the end of the day, you’ve also got an Internet-flashable Arduino, which is just what the doctor ordered if you’re building a simple wired IoT device and you get tired of running down to the basement to upload new firmware.

Oh, and in case you hadn’t noticed, cramming an Ethernet bootloader into 1 kB is amazing.

Speaking of bootloaders, if you’re building an I2C slave device out of an ATtiny85¸ you’ll want to check out this bootloader that runs on the tiny chip.

25 thoughts on “Want To Learn Ethernet? Write Your Own Darn AVR Bootloader!

  1. I’d say rather than school of thought, it’s a natural law. If you can’t build it, you don’t understand it. If you try to build it, you’ll inevitably discover you didn’t quite understand it.

    1. And even then only building it is not always enough to fully understand it. Software is a pretty good example of this. To fully understand something you should be able to break it.

    2. If you build it from scratch on your own with nothing but manufacturer’s datasheet, app notes etc, then you’ll learn a lot more *even* when you fail. Having to bridge the gap yourself from nothing to coming up with a design is great learning. It is a lot cheaper than a course in school.

  2. That is an impressive write up as well as the proof that determination can get you places; however, my reaction to a problem like that would be “F… That, I’ll use an ESP8266 with OTA updates”.

    I must say though that it is articles like this that make me look at tasks such as this one, that seem and are complex, as achievable challenges.

  3. I am tempted to grumble about the 1K challenge, but I won’t — though it doesn’t appeal to me. The sort of coding tricks and skills involved in that sort of thing just aren’t what I want to hone in my skill set. But I only complain if it is an artificial restriction (like shuffling a deck of cards with one hand tied behind your back). If you actually must cram your code into 1K and there is no way around it, that is a different bag of worms. In the case of AVR, just say no and get an ARM.

    1. Here’s the deal: the limited-resources challenges push people to do more with less, which in many cases inspires creativity. And really, the word “challenge” is in the name.

      Some people climb Mt Everest. Some people run 26.2 miles, only to end up (futility!) right where they started. Don’t get me started on golf — there has to be a more efficient way to put balls in holes.

      (Some people enjoy challenges. Humans!)

      But really. Have a look at the 1 Square Inch or 1 kB challenge results. There is a fantastic density of great projects that came out of them. If you’re willing to go meta with me — pretend that the goal was to add to the universe’s supply of awesome, useful, open projects. Imposing the constraints seems to have fooled a bunch of people into doing great work, and enjoying themselves along the way. It’s more productive than running marathons, anyway.

  4. Reminds me of a 3kB DHCP/TFTP bootloader (4kB if you include Optiboot and the stage 1 bootloader / flasher) I wrote for the Etherten (ATMega32 + W5100) a few years ago. It looks like they didn’t implement DHCP – probably because it wouldn’t have fit in the 1kB required.

Leave a Reply to OstracusCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.