Booting 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. Booting ARM Linux
  2. =================
  3. Author: Russell King
  4. Date : 18 May 2002
  5. The following documentation is relevant to 2.4.18-rmk6 and beyond.
  6. In order to boot ARM Linux, you require a boot loader, which is a small
  7. program that runs before the main kernel. The boot loader is expected
  8. to initialise various devices, and eventually call the Linux kernel,
  9. passing information to the kernel.
  10. Essentially, the boot loader should provide (as a minimum) the
  11. following:
  12. 1. Setup and initialise the RAM.
  13. 2. Initialise one serial port.
  14. 3. Detect the machine type.
  15. 4. Setup the kernel tagged list.
  16. 5. Load initramfs.
  17. 6. Call the kernel image.
  18. 1. Setup and initialise RAM
  19. ---------------------------
  20. Existing boot loaders: MANDATORY
  21. New boot loaders: MANDATORY
  22. The boot loader is expected to find and initialise all RAM that the
  23. kernel will use for volatile data storage in the system. It performs
  24. this in a machine dependent manner. (It may use internal algorithms
  25. to automatically locate and size all RAM, or it may use knowledge of
  26. the RAM in the machine, or any other method the boot loader designer
  27. sees fit.)
  28. 2. Initialise one serial port
  29. -----------------------------
  30. Existing boot loaders: OPTIONAL, RECOMMENDED
  31. New boot loaders: OPTIONAL, RECOMMENDED
  32. The boot loader should initialise and enable one serial port on the
  33. target. This allows the kernel serial driver to automatically detect
  34. which serial port it should use for the kernel console (generally
  35. used for debugging purposes, or communication with the target.)
  36. As an alternative, the boot loader can pass the relevant 'console='
  37. option to the kernel via the tagged lists specifying the port, and
  38. serial format options as described in
  39. Documentation/kernel-parameters.txt.
  40. 3. Detect the machine type
  41. --------------------------
  42. Existing boot loaders: OPTIONAL
  43. New boot loaders: MANDATORY except for DT-only platforms
  44. The boot loader should detect the machine type its running on by some
  45. method. Whether this is a hard coded value or some algorithm that
  46. looks at the connected hardware is beyond the scope of this document.
  47. The boot loader must ultimately be able to provide a MACH_TYPE_xxx
  48. value to the kernel. (see linux/arch/arm/tools/mach-types). This
  49. should be passed to the kernel in register r1.
  50. For DT-only platforms, the machine type will be determined by device
  51. tree. set the machine type to all ones (~0). This is not strictly
  52. necessary, but assures that it will not match any existing types.
  53. 4. Setup boot data
  54. ------------------
  55. Existing boot loaders: OPTIONAL, HIGHLY RECOMMENDED
  56. New boot loaders: MANDATORY
  57. The boot loader must provide either a tagged list or a dtb image for
  58. passing configuration data to the kernel. The physical address of the
  59. boot data is passed to the kernel in register r2.
  60. 4a. Setup the kernel tagged list
  61. --------------------------------
  62. The boot loader must create and initialise the kernel tagged list.
  63. A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE.
  64. The ATAG_CORE tag may or may not be empty. An empty ATAG_CORE tag
  65. has the size field set to '2' (0x00000002). The ATAG_NONE must set
  66. the size field to zero.
  67. Any number of tags can be placed in the list. It is undefined
  68. whether a repeated tag appends to the information carried by the
  69. previous tag, or whether it replaces the information in its
  70. entirety; some tags behave as the former, others the latter.
  71. The boot loader must pass at a minimum the size and location of
  72. the system memory, and root filesystem location. Therefore, the
  73. minimum tagged list should look:
  74. +-----------+
  75. base -> | ATAG_CORE | |
  76. +-----------+ |
  77. | ATAG_MEM | | increasing address
  78. +-----------+ |
  79. | ATAG_NONE | |
  80. +-----------+ v
  81. The tagged list should be stored in system RAM.
  82. The tagged list must be placed in a region of memory where neither
  83. the kernel decompressor nor initrd 'bootp' program will overwrite
  84. it. The recommended placement is in the first 16KiB of RAM.
  85. 4b. Setup the device tree
  86. -------------------------
  87. The boot loader must load a device tree image (dtb) into system ram
  88. at a 64bit aligned address and initialize it with the boot data. The
  89. dtb format is documented in Documentation/devicetree/booting-without-of.txt.
  90. The kernel will look for the dtb magic value of 0xd00dfeed at the dtb
  91. physical address to determine if a dtb has been passed instead of a
  92. tagged list.
  93. The boot loader must pass at a minimum the size and location of the
  94. system memory, and the root filesystem location. The dtb must be
  95. placed in a region of memory where the kernel decompressor will not
  96. overwrite it, whilst remaining within the region which will be covered
  97. by the kernel's low-memory mapping.
  98. A safe location is just above the 128MiB boundary from start of RAM.
  99. 5. Load initramfs.
  100. ------------------
  101. Existing boot loaders: OPTIONAL
  102. New boot loaders: OPTIONAL
  103. If an initramfs is in use then, as with the dtb, it must be placed in
  104. a region of memory where the kernel decompressor will not overwrite it
  105. while also with the region which will be covered by the kernel's
  106. low-memory mapping.
  107. A safe location is just above the device tree blob which itself will
  108. be loaded just above the 128MiB boundary from the start of RAM as
  109. recommended above.
  110. 6. Calling the kernel image
  111. ---------------------------
  112. Existing boot loaders: MANDATORY
  113. New boot loaders: MANDATORY
  114. There are two options for calling the kernel zImage. If the zImage
  115. is stored in flash, and is linked correctly to be run from flash,
  116. then it is legal for the boot loader to call the zImage in flash
  117. directly.
  118. The zImage may also be placed in system RAM and called there. The
  119. kernel should be placed in the first 128MiB of RAM. It is recommended
  120. that it is loaded above 32MiB in order to avoid the need to relocate
  121. prior to decompression, which will make the boot process slightly
  122. faster.
  123. When booting a raw (non-zImage) kernel the constraints are tighter.
  124. In this case the kernel must be loaded at an offset into system equal
  125. to TEXT_OFFSET - PAGE_OFFSET.
  126. In any case, the following conditions must be met:
  127. - Quiesce all DMA capable devices so that memory does not get
  128. corrupted by bogus network packets or disk data. This will save
  129. you many hours of debug.
  130. - CPU register settings
  131. r0 = 0,
  132. r1 = machine type number discovered in (3) above.
  133. r2 = physical address of tagged list in system RAM, or
  134. physical address of device tree block (dtb) in system RAM
  135. - CPU mode
  136. All forms of interrupts must be disabled (IRQs and FIQs)
  137. For CPUs which do not include the ARM virtualization extensions, the
  138. CPU must be in SVC mode. (A special exception exists for Angel)
  139. CPUs which include support for the virtualization extensions can be
  140. entered in HYP mode in order to enable the kernel to make full use of
  141. these extensions. This is the recommended boot method for such CPUs,
  142. unless the virtualisations are already in use by a pre-installed
  143. hypervisor.
  144. If the kernel is not entered in HYP mode for any reason, it must be
  145. entered in SVC mode.
  146. - Caches, MMUs
  147. The MMU must be off.
  148. Instruction cache may be on or off.
  149. Data cache must be off.
  150. If the kernel is entered in HYP mode, the above requirements apply to
  151. the HYP mode configuration in addition to the ordinary PL1 (privileged
  152. kernel modes) configuration. In addition, all traps into the
  153. hypervisor must be disabled, and PL1 access must be granted for all
  154. peripherals and CPU resources for which this is architecturally
  155. possible. Except for entering in HYP mode, the system configuration
  156. should be such that a kernel which does not include support for the
  157. virtualization extensions can boot correctly without extra help.
  158. - The boot loader is expected to call the kernel image by jumping
  159. directly to the first instruction of the kernel image.
  160. On CPUs supporting the ARM instruction set, the entry must be
  161. made in ARM state, even for a Thumb-2 kernel.
  162. On CPUs supporting only the Thumb instruction set such as
  163. Cortex-M class CPUs, the entry must be made in Thumb state.