Is it possible to write an Arduino Bootloader for a Tiny AVR?
Is it worthwhile to write a Arduino Bootloader for an Tiny AVR? (more subjective, contingent on 1)
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
It's not worthwhile to write a new one. There are plenty of existing serial bootloaders for the Tiny AVR and it would be pretty trivial to port the actual Arduino bootloader. It's not even necessary to speak the same protocol to work with the Arduino environment. The Arduino IDE can be configured to upload to any programmer supported by avrdude.
I would say it worthwhile if for no other reason as an educational experience. Just because a chip has a default or popular bootloader doesnt make it good or mean you have to use it. If you have never written one I would highly recommend it, if nothing else modify the existing/popular one.
Now saying that, it is best to do this on a platform where you have a recovery path. So boards/devices where you have a jtag interface and experience using that jtag are preferred. Or to just get through inventing/using a protocol, have the default bootloader launch your (secondary) bootloader and work through the bootloader/programmer experience (using the original bootloader as your recover path). But there is another half to the problem that you wont get, and that is the chip initialisation stuff, and that can be difficult to get right and takes many iterations (and most of those iterations result in a nonfunctional bootloader requiring the backdoor recovery path).
The arduino in particular suffered from the transition from 32 to 64 bit (on the host) for a while there so the choice was to change my day to day habits for this board, or step out of the sandbox and do my own thing with this board? You find this very often in the microcontroller or eval board world, the canned sandboxes are usually windows first then maybe mac and then sometimes linux. Even today pre-vista or pre windows 7 works but you may not have access to those on your development machine, may not want or be able to buy a copy just to play with a $20 toy. Linux is usually the last host environment supported, so I often find myself writing a bootloader, using windows or whatever briefly, to load it then I can work in an environment I am more comfortable with to continue to use or evaluate the product. In the case of the arduino it was easier to write a programmer that worked with the existing bootloader on the current Linux than to write a new or modified bootloader using an older or 32 bit linux or windows. For the devices that have well designed built in bootloaders either in hardware or in a protected flash, it is often better to replace the programmer than the bootloader. Which is is part of the bootloader development process anyway, so here again an educational experience as well as sometimes a practical solution.
The corollary to your question is Am I forced to use the IDE/sandbox provided with an eval or developer board, or can I use other tools or create my own? Do I have to use such and such library to do something or can I write and use my own?