2
\$\begingroup\$

I'm currently attending a basic course on real-time embedded systems. Recently, we have been talking about embedded systems memory architecture. When doing some extra studying on memory maps, I came across the memory map for the ATmega328P microcontroller. As can be seen from the image, the flash is divided into a boot section and an application section.

enter image description here

Why is the boot section not starting from address 0? As I've understood it, the microcontroller application won't run without a bootloader. So why doesn't the bootloader occupy the lower addresses if everything else relies on it?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

Your assumption is wrong, there is no need for any bootloader if you just want to run your normal programs. However you may just be accustomed to Arduinos and the like, which need a bootloader to be able to easily upload a new program via UART, as that is not possible without a bootloader.

When the MCU is configured to boot a bootloader instead of normal program, it will start executing from bootloader address. So this MCU has support for a specific bootloader section, while some other MCUs may not be.

It's designed like that and the addresses are what they are.

This enables the normal program to be like any standard program, and the bootloader needs to know it is located at special address.

On another systems that have no separate bootloader section, the bootloader needs to be loaded in the normal program section, and the normal programs need to be specially compiled to be relocated after the bootloader.

\$\endgroup\$
3
\$\begingroup\$

There are lots of ways of programming ATMegas (and most microcontrollers).

First: ask yourself "what exactly is a boot section". The answer is: an area of code with separate lock bits or other controls, that allows a microcontroller to program its own "main" code section.

The most frequently used method during development is to use a bootloader which accepts some code and the device programs its own main memory.

But you can also just program it, with, for example, parallel or serial programming. These are most commonly used method for production units. Then you don't need a boot section at all, and can reset to address 0. (In ATMega, see BOOTRST control bit.)

\$\endgroup\$
2
  • \$\begingroup\$ So the bootloader is just there to enable easier programming through for example UART. Does this mean the actual application code stays the same, but the method of programming is different? \$\endgroup\$
    – user294957
    Commented Oct 2, 2022 at 17:06
  • \$\begingroup\$ Yes, the main program would be the same, and it arrives by bootload or other programming method according to what's convenient. \$\endgroup\$
    – jonathanjo
    Commented Oct 2, 2022 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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