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