Blame view

Documentation/arm/booting.rst 7.93 KB
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
1
2
3
  =================
  Booting ARM Linux
  =================
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
5
  
  Author:	Russell King
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
6

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  Date  : 18 May 2002
  
  The following documentation is relevant to 2.4.18-rmk6 and beyond.
  
  In order to boot ARM Linux, you require a boot loader, which is a small
  program that runs before the main kernel.  The boot loader is expected
  to initialise various devices, and eventually call the Linux kernel,
  passing information to the kernel.
  
  Essentially, the boot loader should provide (as a minimum) the
  following:
  
  1. Setup and initialise the RAM.
  2. Initialise one serial port.
  3. Detect the machine type.
  4. Setup the kernel tagged list.
83d26d111   Ian Campbell   ARM: 7824/1: upda...
23
24
  5. Load initramfs.
  6. Call the kernel image.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
27
28
  
  
  1. Setup and initialise RAM
  ---------------------------
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
29
30
31
32
  Existing boot loaders:
  	MANDATORY
  New boot loaders:
  	MANDATORY
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
34
35
36
37
38
39
40
41
42
43
  
  The boot loader is expected to find and initialise all RAM that the
  kernel will use for volatile data storage in the system.  It performs
  this in a machine dependent manner.  (It may use internal algorithms
  to automatically locate and size all RAM, or it may use knowledge of
  the RAM in the machine, or any other method the boot loader designer
  sees fit.)
  
  
  2. Initialise one serial port
  -----------------------------
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
44
45
46
47
  Existing boot loaders:
  	OPTIONAL, RECOMMENDED
  New boot loaders:
  	OPTIONAL, RECOMMENDED
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
49
50
51
52
53
54
55
56
  
  The boot loader should initialise and enable one serial port on the
  target.  This allows the kernel serial driver to automatically detect
  which serial port it should use for the kernel console (generally
  used for debugging purposes, or communication with the target.)
  
  As an alternative, the boot loader can pass the relevant 'console='
  option to the kernel via the tagged lists specifying the port, and
  serial format options as described in
8c27ceff3   Mauro Carvalho Chehab   docs: fix locatio...
57
         Documentation/admin-guide/kernel-parameters.rst.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
59
60
61
  
  
  3. Detect the machine type
  --------------------------
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
62
63
64
65
  Existing boot loaders:
  	OPTIONAL
  New boot loaders:
  	MANDATORY except for DT-only platforms
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
66
67
68
69
70
  
  The boot loader should detect the machine type its running on by some
  method.  Whether this is a hard coded value or some algorithm that
  looks at the connected hardware is beyond the scope of this document.
  The boot loader must ultimately be able to provide a MACH_TYPE_xxx
dce12391d   Gregory Fong   Documentation: ar...
71
72
73
74
75
76
  value to the kernel. (see linux/arch/arm/tools/mach-types).  This
  should be passed to the kernel in register r1.
  
  For DT-only platforms, the machine type will be determined by device
  tree.  set the machine type to all ones (~0).  This is not strictly
  necessary, but assures that it will not match any existing types.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77

ede338f4c   Grant Likely   dt: add documenta...
78
79
  4. Setup boot data
  ------------------
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
80

dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
81
82
83
84
  Existing boot loaders:
  	OPTIONAL, HIGHLY RECOMMENDED
  New boot loaders:
  	MANDATORY
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
85

ede338f4c   Grant Likely   dt: add documenta...
86
87
88
89
90
91
  The boot loader must provide either a tagged list or a dtb image for
  passing configuration data to the kernel.  The physical address of the
  boot data is passed to the kernel in register r2.
  
  4a. Setup the kernel tagged list
  --------------------------------
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
92
93
94
95
96
97
98
99
100
101
102
103
104
  The boot loader must create and initialise the kernel tagged list.
  A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE.
  The ATAG_CORE tag may or may not be empty.  An empty ATAG_CORE tag
  has the size field set to '2' (0x00000002).  The ATAG_NONE must set
  the size field to zero.
  
  Any number of tags can be placed in the list.  It is undefined
  whether a repeated tag appends to the information carried by the
  previous tag, or whether it replaces the information in its
  entirety; some tags behave as the former, others the latter.
  
  The boot loader must pass at a minimum the size and location of
  the system memory, and root filesystem location.  Therefore, the
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
105
  minimum tagged list should look::
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106

dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
107
108
109
110
111
112
113
  		+-----------+
    base ->	| ATAG_CORE |  |
  		+-----------+  |
  		| ATAG_MEM  |  | increasing address
  		+-----------+  |
  		| ATAG_NONE |  |
  		+-----------+  v
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
114
115
116
117
118
119
  
  The tagged list should be stored in system RAM.
  
  The tagged list must be placed in a region of memory where neither
  the kernel decompressor nor initrd 'bootp' program will overwrite
  it.  The recommended placement is in the first 16KiB of RAM.
ede338f4c   Grant Likely   dt: add documenta...
120
121
122
123
124
125
126
127
128
129
130
131
132
  4b. Setup the device tree
  -------------------------
  
  The boot loader must load a device tree image (dtb) into system ram
  at a 64bit aligned address and initialize it with the boot data.  The
  dtb format is documented in Documentation/devicetree/booting-without-of.txt.
  The kernel will look for the dtb magic value of 0xd00dfeed at the dtb
  physical address to determine if a dtb has been passed instead of a
  tagged list.
  
  The boot loader must pass at a minimum the size and location of the
  system memory, and the root filesystem location.  The dtb must be
  placed in a region of memory where the kernel decompressor will not
806654a96   Will Deacon   Documentation: Us...
133
  overwrite it, while remaining within the region which will be covered
83d26d111   Ian Campbell   ARM: 7824/1: upda...
134
  by the kernel's low-memory mapping.
ede338f4c   Grant Likely   dt: add documenta...
135

83d26d111   Ian Campbell   ARM: 7824/1: upda...
136
137
138
139
  A safe location is just above the 128MiB boundary from start of RAM.
  
  5. Load initramfs.
  ------------------
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
140
141
142
143
  Existing boot loaders:
  	OPTIONAL
  New boot loaders:
  	OPTIONAL
83d26d111   Ian Campbell   ARM: 7824/1: upda...
144
145
146
147
148
149
150
151
152
153
154
  
  If an initramfs is in use then, as with the dtb, it must be placed in
  a region of memory where the kernel decompressor will not overwrite it
  while also with the region which will be covered by the kernel's
  low-memory mapping.
  
  A safe location is just above the device tree blob which itself will
  be loaded just above the 128MiB boundary from the start of RAM as
  recommended above.
  
  6. Calling the kernel image
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
155
  ---------------------------
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
156
157
158
159
  Existing boot loaders:
  	MANDATORY
  New boot loaders:
  	MANDATORY
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
160
161
162
163
164
  
  There are two options for calling the kernel zImage.  If the zImage
  is stored in flash, and is linked correctly to be run from flash,
  then it is legal for the boot loader to call the zImage in flash
  directly.
83d26d111   Ian Campbell   ARM: 7824/1: upda...
165
166
167
168
169
170
171
172
173
  The zImage may also be placed in system RAM and called there.  The
  kernel should be placed in the first 128MiB of RAM.  It is recommended
  that it is loaded above 32MiB in order to avoid the need to relocate
  prior to decompression, which will make the boot process slightly
  faster.
  
  When booting a raw (non-zImage) kernel the constraints are tighter.
  In this case the kernel must be loaded at an offset into system equal
  to TEXT_OFFSET - PAGE_OFFSET.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
174

83d26d111   Ian Campbell   ARM: 7824/1: upda...
175
  In any case, the following conditions must be met:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
176

13fce8062   Andrzej Zaborowski   Fix simple typos
177
  - Quiesce all DMA capable devices so that memory does not get
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
178
179
180
181
    corrupted by bogus network packets or disk data. This will save
    you many hours of debug.
  
  - CPU register settings
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
182
183
184
185
186
  
    - r0 = 0,
    - r1 = machine type number discovered in (3) above.
    - r2 = physical address of tagged list in system RAM, or
      physical address of device tree block (dtb) in system RAM
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
187
188
  
  - CPU mode
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
189

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
190
    All forms of interrupts must be disabled (IRQs and FIQs)
6a6d55c38   Dave Martin   ARM: virt: Update...
191
192
193
194
195
196
197
198
199
200
201
202
  
    For CPUs which do not include the ARM virtualization extensions, the
    CPU must be in SVC mode.  (A special exception exists for Angel)
  
    CPUs which include support for the virtualization extensions can be
    entered in HYP mode in order to enable the kernel to make full use of
    these extensions.  This is the recommended boot method for such CPUs,
    unless the virtualisations are already in use by a pre-installed
    hypervisor.
  
    If the kernel is not entered in HYP mode for any reason, it must be
    entered in SVC mode.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
203
204
  
  - Caches, MMUs
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
205

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
206
    The MMU must be off.
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
207

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
208
    Instruction cache may be on or off.
dc7a12bdf   Mauro Carvalho Chehab   docs: arm: conver...
209

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
210
    Data cache must be off.
6a6d55c38   Dave Martin   ARM: virt: Update...
211
212
213
214
215
216
217
218
    If the kernel is entered in HYP mode, the above requirements apply to
    the HYP mode configuration in addition to the ordinary PL1 (privileged
    kernel modes) configuration.  In addition, all traps into the
    hypervisor must be disabled, and PL1 access must be granted for all
    peripherals and CPU resources for which this is architecturally
    possible.  Except for entering in HYP mode, the system configuration
    should be such that a kernel which does not include support for the
    virtualization extensions can boot correctly without extra help.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
219
220
  - The boot loader is expected to call the kernel image by jumping
    directly to the first instruction of the kernel image.
540b57387   Dave Martin   ARM: 6999/1: head...
221
222
223
224
225
    On CPUs supporting the ARM instruction set, the entry must be
    made in ARM state, even for a Thumb-2 kernel.
  
    On CPUs supporting only the Thumb instruction set such as
    Cortex-M class CPUs, the entry must be made in Thumb state.