Booting 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. Call the kernel image.
  17. 1. Setup and initialise RAM
  18. ---------------------------
  19. Existing boot loaders: MANDATORY
  20. New boot loaders: MANDATORY
  21. The boot loader is expected to find and initialise all RAM that the
  22. kernel will use for volatile data storage in the system. It performs
  23. this in a machine dependent manner. (It may use internal algorithms
  24. to automatically locate and size all RAM, or it may use knowledge of
  25. the RAM in the machine, or any other method the boot loader designer
  26. sees fit.)
  27. 2. Initialise one serial port
  28. -----------------------------
  29. Existing boot loaders: OPTIONAL, RECOMMENDED
  30. New boot loaders: OPTIONAL, RECOMMENDED
  31. The boot loader should initialise and enable one serial port on the
  32. target. This allows the kernel serial driver to automatically detect
  33. which serial port it should use for the kernel console (generally
  34. used for debugging purposes, or communication with the target.)
  35. As an alternative, the boot loader can pass the relevant 'console='
  36. option to the kernel via the tagged lists specifying the port, and
  37. serial format options as described in
  38. Documentation/kernel-parameters.txt.
  39. 3. Detect the machine type
  40. --------------------------
  41. Existing boot loaders: OPTIONAL
  42. New boot loaders: MANDATORY
  43. The boot loader should detect the machine type its running on by some
  44. method. Whether this is a hard coded value or some algorithm that
  45. looks at the connected hardware is beyond the scope of this document.
  46. The boot loader must ultimately be able to provide a MACH_TYPE_xxx
  47. value to the kernel. (see linux/arch/arm/tools/mach-types).
  48. 4. Setup boot data
  49. ------------------
  50. Existing boot loaders: OPTIONAL, HIGHLY RECOMMENDED
  51. New boot loaders: MANDATORY
  52. The boot loader must provide either a tagged list or a dtb image for
  53. passing configuration data to the kernel. The physical address of the
  54. boot data is passed to the kernel in register r2.
  55. 4a. Setup the kernel tagged list
  56. --------------------------------
  57. The boot loader must create and initialise the kernel tagged list.
  58. A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE.
  59. The ATAG_CORE tag may or may not be empty. An empty ATAG_CORE tag
  60. has the size field set to '2' (0x00000002). The ATAG_NONE must set
  61. the size field to zero.
  62. Any number of tags can be placed in the list. It is undefined
  63. whether a repeated tag appends to the information carried by the
  64. previous tag, or whether it replaces the information in its
  65. entirety; some tags behave as the former, others the latter.
  66. The boot loader must pass at a minimum the size and location of
  67. the system memory, and root filesystem location. Therefore, the
  68. minimum tagged list should look:
  69. +-----------+
  70. base -> | ATAG_CORE | |
  71. +-----------+ |
  72. | ATAG_MEM | | increasing address
  73. +-----------+ |
  74. | ATAG_NONE | |
  75. +-----------+ v
  76. The tagged list should be stored in system RAM.
  77. The tagged list must be placed in a region of memory where neither
  78. the kernel decompressor nor initrd 'bootp' program will overwrite
  79. it. The recommended placement is in the first 16KiB of RAM.
  80. 4b. Setup the device tree
  81. -------------------------
  82. The boot loader must load a device tree image (dtb) into system ram
  83. at a 64bit aligned address and initialize it with the boot data. The
  84. dtb format is documented in Documentation/devicetree/booting-without-of.txt.
  85. The kernel will look for the dtb magic value of 0xd00dfeed at the dtb
  86. physical address to determine if a dtb has been passed instead of a
  87. tagged list.
  88. The boot loader must pass at a minimum the size and location of the
  89. system memory, and the root filesystem location. The dtb must be
  90. placed in a region of memory where the kernel decompressor will not
  91. overwrite it. The recommended placement is in the first 16KiB of RAM
  92. with the caveat that it may not be located at physical address 0 since
  93. the kernel interprets a value of 0 in r2 to mean neither a tagged list
  94. nor a dtb were passed.
  95. 5. Calling the kernel image
  96. ---------------------------
  97. Existing boot loaders: MANDATORY
  98. New boot loaders: MANDATORY
  99. There are two options for calling the kernel zImage. If the zImage
  100. is stored in flash, and is linked correctly to be run from flash,
  101. then it is legal for the boot loader to call the zImage in flash
  102. directly.
  103. The zImage may also be placed in system RAM (at any location) and
  104. called there. Note that the kernel uses 16K of RAM below the image
  105. to store page tables. The recommended placement is 32KiB into RAM.
  106. In either case, the following conditions must be met:
  107. - Quiesce all DMA capable devices so that memory does not get
  108. corrupted by bogus network packets or disk data. This will save
  109. you many hours of debug.
  110. - CPU register settings
  111. r0 = 0,
  112. r1 = machine type number discovered in (3) above.
  113. r2 = physical address of tagged list in system RAM, or
  114. physical address of device tree block (dtb) in system RAM
  115. - CPU mode
  116. All forms of interrupts must be disabled (IRQs and FIQs)
  117. The CPU must be in SVC mode. (A special exception exists for Angel)
  118. - Caches, MMUs
  119. The MMU must be off.
  120. Instruction cache may be on or off.
  121. Data cache must be off.
  122. - The boot loader is expected to call the kernel image by jumping
  123. directly to the first instruction of the kernel image.
  124. On CPUs supporting the ARM instruction set, the entry must be
  125. made in ARM state, even for a Thumb-2 kernel.
  126. On CPUs supporting only the Thumb instruction set such as
  127. Cortex-M class CPUs, the entry must be made in Thumb state.