0

As I know, CPU can access RAM directly. Device RAM is empty on start and CPU don't know from where to load bootloader into the RAM for executing it. Even it can do nothing because call stack should be empty too as I think. Yet how is bootloader program copied into the RAM for further execution?

This should happening with embedded devices such as smartphones. On a x86 PCs BIOS is responsible for loading MBR section from disk to RAM as I know.

Alex
  • 28
  • 1
  • 8
  • 1
    There's a little piece of ROM on chip with hard coded initial bootloader. That will direct the CPU to load next stage boot loader from the boot device (configured by pulling up/down CPU pins) into on chip SRAM and run it. Then 2nd stage will initialize more hardware e.g. off chip DRAM and file system of the boot device and get 3rd boot loader into DRAM and run it. After 3rd stage the CPU should be able to load the OS kernel and run it. Sometimes there's an additional 2.5 stage to squeeze a partial 3rd stage into on chip SRAM before the whole 3rd stage is loaded into DRAM. – user3528438 Jan 21 '17 at 19:47
  • Which particular ARM architecture are you referring to? They do not all work in quite the same way. Additionally often it is vendor specific - different ARM licensees have different implementations. – Clifford Jan 21 '17 at 21:02
  • @Clifford I referred about ARMv7 – Alex Jan 22 '17 at 22:21
  • @Alex : That may still refer to ARMv7-M, ARMv7E-M, ARMv7-R or ARMv7-A. Perhaps it does not matter if you only want a general answer. – Clifford Jan 23 '17 at 15:07

2 Answers2

1

A bootloader in RAM is a secondary bootloader; invariably there is code in a ROM of some kind containing a primary bootstrap that loads the secondary bootstrap. Often that ROM is mask-ROM on the chip it self.

Typically on an ARM application processor such as a Cortex-A the primary bootstrap will load code to RAM from NAND flash or SD card. ARM Cortex-M often run code directly from ROM in any case.

Clifford
  • 88,407
  • 13
  • 85
  • 165
0

you have the same problem with an x86. and the same solution in general (as with any other processor as well), you put a rom/flash in the address space where the processor boots and/or where its vector table is.

there are some other solutions like having other logic that reads from some non volatile storage and places it in the boot/vector space, or other logic that provides an interface for some other processor/computer to download into the board/chip and then release reset.

old_timer
  • 69,149
  • 8
  • 89
  • 168