Electronic – Is a boot-loader needed to dump the flash memory to RAM? Why

bootloadermicrocontroller

When a micro-controller is booting, does it fetch the instructions directly from the flash memory? But sometimes a boot-loader is used.

If so why do we use a boot-loader to dump the flash memory data into RAM?

How can I know whether the micro controller fetches the first boot instructions directly from the flash memory or through RAM?

Edit: My question is about bootloader! This is not duplicate at all.

Best Answer

"Boot loader" has many different meanings.

  • In some (generally slower) microcontrollers the instruction data is stored within on-chip flash memory and executed directly from there. This obviously requires that the flash can be read as fast as the MCU executes instructions. A boot loader in these chips is a chunk of code in a reserved address range which is executed before the main program and whose purpose is to rewrite the rest of the program flash when necessary. For example, AVR-based arduinos contain a bootloader that allows the chips to reprogram themselves over the UART when uploading a "sketch".

  • In other (generally faster) microcontrollers the instruction data is still stored within the on-chip flash, but it is transfered to on-chip RAM prior to execution. This is because designing flash fast enough to run from directly would be impractical. In these cases the bootloader still refers to a piece of code for rewriting the flash, as the data transfer is done in hardware.

  • In others still there is just enough flash(or ROM/EEPROM) for storing the bootloader, whose sole purpose is to copy instructions from external memory (usually SPI/I2C flash) into RAM prior to execution.