newbie bootloader question

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,
I am new to micros . I'd really appreciate it if I could get some education about bootloaders from AVRfreaks. :-)
From all the searching on the net, I see that bootloaders are mostly written to make it easier to program the micro. I'd like to know if there are other uses too...
If yes, could you please give some examples?

Basically, I would like to learn about booting up a micro: what it means, how is it done, and how can a 'booted' up micro be better than a dumb, power-on-reset micro.
Also, can all micros use a bootloader? I'm planning to practice on mega 8515 on AVR studio before buying or building a board.
Thanks in advance! :-)

-Aashish.
If you don't see it coming, you'll never know what hit you...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Normally a bootloader portion of code memory is able to reprogram the application portion of code memory. While you can download just the application via ISP cable or other methods, you can make a bootloader that can receive or read the application portion from anywhere, like serial port, infrared link or memory card. So yes makes programming the micro easier, other uses, I can't think of any.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Jepael!
Okay, so if I understood this correctly, a bootloader can be written to talk to ethernet, USB, serial, etc, and flash the program received from that link. Hmm...that makes sense. I have seen webpages talking about a "USB bootloader" and didn't exactly know what that meant.

Can all micros use a bootloader? I mean, any special requirements for a micro to be able to use one?

-Aashish.
If you don't see it coming, you'll never know what hit you...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Back in the 'old days', we'd call it a 'bootstrap'. It was the code that executes as soon as the power is applied. What it did, and how it did it, was of little consequence. All we cared about was that it allowed the computer to 'start up'. These day's especially in terms of mcUs it's still a bit of code that allow's the mcU to start up. It does this by looking for a signal, somewhere, that says; 'Load up the following program'! If it does not find this signal, it executes what ever code it's been programmed to (the 'application'). If it does see this signal, it starts to download the 'application code' into it's memory, and then starts up the downloaded application.
So, yes, a boot loader can 'make it easier' for you if you have, say, a program on flash memory that you want to 'load in', or maybe some code that will be downloaded via USB from a PC, or any other way of getting your 'application' into the mcU. On the other hand... ICSP (in circuit serial programming) is even more popular (I think), but requires another piece of hardware to do the initial programming.

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

Last Edited: Sat. Feb 12, 2011 - 09:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Can all micros use a bootloader? I mean, any special requirements for a micro to be able to use one?

It has to have an instruction/mechanism that allows it's own program code to be reprogrammed at run time. The AVRs have the SPM opcode (Self Program Memory).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jepael wrote:
So yes makes programming the micro easier, other uses, I can't think of any.

Of course you can ;-)

A boot loader can also be an application that is responsible for loading and starting the operating system (edit: or main application). E.g. U-Boot is one common boot loader in Linux environments. I have an AT91SAM9263-based CPU module which uses U-Boot.

Have a look at http://en.wikipedia.org/wiki/Boo...

/Jakob Selbing

Last Edited: Sat. Feb 12, 2011 - 09:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Okay, so if I understood this correctly, a bootloader can be written to talk to ethernet, USB, serial, etc, and flash the program received from that link.
Yes! You understand.
Now, writing one... :)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The other big use for bootloaders is updating the firmware of products out in the world in customers' hands. Bootloaders allow a company to add features or fix bugs without the massive expense of having the customer send back the unit for upgrading.

The AVR programming tools, for example, have bootloaders and new firmware can be downloaded to them from AVR Studio to upgrade them.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a LOT for all the great responses! :-)
Uhhmm... now how does one go about writing a bootloader, say, one that reads from the serial port? I'm not asking for the smallest of details (or a readymade program) right away, but some basic guidelines should get me started.
Or, if the topic has been discussed at length in other threads, then may I have a link to some of those?

-Aashish.
If you don't see it coming, you'll never know what hit you...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

aashish_delhi wrote:
Thanks a LOT for all the great responses! :-)
Uhhmm... now how does one go about writing a bootloader, say, one that reads from the serial port? I'm not asking for the smallest of details (or a readymade program) right away, but some basic guidelines should get me started.
Or, if the topic has been discussed at length in other threads, then may I have a link to some of those?
NOrmally, one installs an existing bootloader. On AVRs, there are quite a few free one, including those here in the Projects section. Mine, "BLIPS", is popular and includes both the AVR and PC sides. Another popular one is AVRdude.

You should get/use a bootstrap before deciding you need to reinvent your own.

A catch-22 though: If you have a bare naked AVR without a bootstrap, how do you install the bootstrap (write it to flash)? You'll need an in-system-programmer (ISP) device such as the Atmel Mark II. Or someone that owns one and can program your chips.

Or, get an AVR with a pre-installed bootloader, such as the popular/inexpensive Arduino based devices.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try Googling: bootloader site:avrfreaks.net

You get loads of results.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, a bootloader program is not the same as any other (application) program in the micro's flash: a bootloader needs to be stored in a special location in the flash. Got it...

-Aashish.
If you don't see it coming, you'll never know what hit you...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
a bootloader needs to be stored in a special location in the flash

Just to be pedantic, the location of the SPM instruction(s) is all that is critical. The main code of the bootloader could reside anywhere, as long as it gets into the bootloader section to actually write the flash. It's most practical to have it all together in the BLS, but it's not absolutely required if you're very careful.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Just to be pedantic, the location of the SPM instruction(s) is all that is critical. The main code of the bootloader could reside anywhere, as long as it gets into the bootloader section to actually write the flash. It's most practical to have it all together in the BLS, but it's not absolutely required if you're very careful.

You do lose the protection of the Bootloader protection lock bits if you do something mad like that though. It would be VERY unwise!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
It would be VERY unwise!

I totally agree. My point was that the restriction is on the instruction, not the operation of the bootloader in general. The fact that there is the additional functional support for the standard bootloader model through the lock bits makes deviation even sillier. Thanks for the reminder, Cliff.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And for the OP- the techniques for self-programming as discussed here differ greatly among the many manufacturers' microprocessors.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Back in the 'old days', we'd call it a 'bootstrap'. It was the code that executes as soon as the power is applied.

In the 'real old days' we had to key in the bootstrap program from the front panel switches. It kind of sucked when troubleshooting hardware problems, but it didn't take long before the 20 hex instructions were burned into one's human ROM. On the other hand core memory was the rule and often the program would still be in memory after a power down/up sequence.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I hope this is not a silly question... (newbie alert! ;))

I'm ASSuming a bootloader is not required to place a program onto an AVR. You would burn the program to the MCU with a programmer like the USBasp I have?

For example I could download the .hex file for the Arduino 'blink' program to a virgin ATmegaxx8 directly?

Thank you.

M.S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mr.Swarf wrote:

For example I could download the .hex file for the Arduino 'blink' program to a virgin ATmegaxx8 directly?
Thank you.

Yes, there are many AVR "ISP" devices.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you. That is what I wanted to know.

M.S.