7
\$\begingroup\$

I need to make a robot within a month for a competition. I used to use Arduinos for my projects, but graduated to just flashing code with avrdude to standalone AVR microcontrollers.

I was thinking, just because I don't use the Arduino hardware anymore, is there any reason not to burn an Arduino bootloader on to my microcontrollers for some projects? Are there scenarios (like my current task) in which doing so would actually be advantageous?

It is a little easier to write code for an Arduino, and there are several open source libraries. I am sure there are other key advantages (and disadvantages) which I am not aware of, but would like to know about.

Essentially, under which scenario(s) would it be a good idea to burn an Arduino bootloader to my micrcontroller.

\$\endgroup\$
  • 2
    \$\begingroup\$ You seem to be confusing the Arduino bootloader and the Arduino runtime libraries, or else asking two distinct questions run together. They are two entirely separate pieces of software, and you can use either one without the other. As for the bootloader, it could be quite helpful unless it won't fit, you can't tolerate the startup delay, or you need to lock things down. \$\endgroup\$ – Chris Stratton Feb 11 '13 at 2:16
  • \$\begingroup\$ @ChrisStratton I see. I may be confusing those two, but that is not the essence of my question. Basically, I want to know when/why I should consider using the Arduino bootloader as opposed to how I currently use my microcontrollers. In other words, except for the three reasons you gave, why wouldn't someone want to use the Arduino bootloader? I see so many AVR projects where people don't use it, and aren't bound by those three constraints (size, delay, permanence). Thanks. \$\endgroup\$ – capcom Feb 11 '13 at 2:55
10
\$\begingroup\$

The basic answer is that some people don't want to buy or make a programmer. They just need a serial port to program the IC using a bootloader. It's cheaper.

Or sometime you want to be able to upgrade your code on the field without using your expensive programmer. Then a bootloader is fine.

But if you think about the usage of your system and don't find a need for a bootloader, then there is no reason to keep it. It takes flash space for nothing.

The Arduino bootloader is just a bootloader: something that allows the chip to program itself with new data on boot. Nothing else. Thus having it or not doesn't impact your code performance (except for the available flash space or start-up delay).

Thus answering your question:

  • If you don't have a programmer -> keep the bootlaoder
  • If you have a programmer -> up to you, it depends if you want to be able to upgrade without the programmer or not.
\$\endgroup\$
  • \$\begingroup\$ I see. I guess I didn't really understand what a bootloader is in the context of my question. Though I still don't understand how it can program the MCU over serial. Is that just the main function of the Arduino bootloader? It receives the data over a serial link, and flashes it internally? I may be completely off here. Also, I do have a programmer. I use the USBasp, so nothing fancy, but still perfectly functional. \$\endgroup\$ – capcom Feb 11 '13 at 13:07
  • \$\begingroup\$ The bootloader is placed at the entry point of execution of your MCU. It runs at the very beginning. Its purpose is to detect if someone want to communicate with it on the serial port. If not, it calls your software. If yes, it uses the self flash programming feature of the MCU to reprogram its flash (except itself!!) with the data you give to him via the serial port. \$\endgroup\$ – Blup1980 Feb 11 '13 at 13:14
  • \$\begingroup\$ @capcom: that's not just the main function of a bootloader, it is the ONLY function! So as Blup1980 says, if you don't need the bootloader for that function, there is no reason at all to keep using it. \$\endgroup\$ – Wouter van Ooijen Feb 11 '13 at 13:17
  • \$\begingroup\$ Awesome, thanks. And just to get my understanding straight, I can use the libraries that people write for Arduinos straight on my MCU? \$\endgroup\$ – capcom Feb 11 '13 at 13:19
  • \$\begingroup\$ @WoutervanOoijen Thanks for the very clear response. \$\endgroup\$ – capcom Feb 11 '13 at 13:20
7
\$\begingroup\$

This might seem a bit glib, but if you find yourself not needing the Arduino bootloader (because you do not need to reflash your AtmegaXXX over a serial link in-circuit) then you don't need a bootloader. That is all a bootloader does for you.

Generally I've found that keeping the Arduino bootloader on my Atmega microcontrollers makes them more flexible in the field. But mine aren't used for detached robots; they are used in equipment and facility controllers, usually at the end of long RS-232 links. I can sit at my main computer and upload new firmware to them at my whim, and it feels a little like I'm uploading firmware to a Martian probe. I wouldn't want it any other way.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.