]>
Commit | Line | Data |
---|---|---|
3e1b3939 SB |
1 | U-Boot Falcon Mode |
2 | ==================== | |
3 | ||
4 | Introduction | |
5 | ------------ | |
6 | ||
7 | This document provides an overview of how to add support for Falcon Mode | |
8 | to a board. | |
9 | ||
10 | Falcon Mode is introduced to speed up the booting process, allowing | |
11 | to boot a Linux kernel (or whatever image) without a full blown U-Boot. | |
12 | ||
13 | Falcon Mode relies on the SPL framework. In fact, to make booting faster, | |
14 | U-Boot is split into two parts: the SPL (Secondary Program Loader) and U-Boot | |
15 | image. In most implementations, SPL is used to start U-Boot when booting from | |
16 | a mass storage, such as NAND or SD-Card. SPL has now support for other media, | |
17 | and can generally be seen as a way to start an image performing the minimum | |
18 | required initialization. SPL mainly initializes the RAM controller, and then | |
19 | copies U-Boot image into the memory. | |
20 | ||
21 | The Falcon Mode extends this way allowing to start the Linux kernel directly | |
22 | from SPL. A new command is added to U-Boot to prepare the parameters that SPL | |
23 | must pass to the kernel, using ATAGS or Device Tree. | |
24 | ||
25 | In normal mode, these parameters are generated each time before | |
26 | loading the kernel, passing to Linux the address in memory where | |
27 | the parameters can be read. | |
28 | With Falcon Mode, this snapshot can be saved into persistent storage and SPL is | |
29 | informed to load it before running the kernel. | |
30 | ||
31 | To boot the kernel, these steps under a Falcon-aware U-Boot are required: | |
32 | ||
33 | 1. Boot the board into U-Boot. | |
cfd6de9c TR |
34 | After loading the desired legacy-format kernel image into memory (and DT as |
35 | well, if used), use the "spl export" command to generate the kernel parameters | |
36 | area or the DT. U-Boot runs as when it boots the kernel, but stops before | |
37 | passing the control to the kernel. | |
3e1b3939 SB |
38 | |
39 | 2. Save the prepared snapshot into persistent media. | |
40 | The address where to save it must be configured into board configuration | |
41 | file (CONFIG_CMD_SPL_NAND_OFS for NAND). | |
42 | ||
43 | 3. Boot the board into Falcon Mode. SPL will load the kernel and copy | |
44 | the parameters which are saved in the persistent area to the required address. | |
d118d766 TR |
45 | If a valid uImage is not found at the defined location, U-Boot will be |
46 | booted instead. | |
3e1b3939 SB |
47 | |
48 | It is required to implement a custom mechanism to select if SPL loads U-Boot | |
49 | or another image. | |
50 | ||
51 | The value of a GPIO is a simple way to operate the selection, as well as | |
52 | reading a character from the SPL console if CONFIG_SPL_CONSOLE is set. | |
53 | ||
54 | Falcon Mode is generally activated by setting CONFIG_SPL_OS_BOOT. This tells | |
55 | SPL that U-Boot is not the only available image that SPL is able to start. | |
56 | ||
57 | Configuration | |
58 | ---------------------------- | |
59 | CONFIG_CMD_SPL Enable the "spl export" command. | |
60 | The command "spl export" is then available in U-Boot | |
61 | mode | |
62 | CONFIG_SYS_SPL_ARGS_ADDR Address in RAM where the parameters must be | |
63 | copied by SPL. | |
64 | In most cases, it is <start_of_ram> + 0x100 | |
65 | ||
66 | CONFIG_SYS_NAND_SPL_KERNEL_OFFS Offset in NAND where the kernel is stored | |
67 | ||
68 | CONFIG_CMD_SPL_NAND_OFS Offset in NAND where the parameters area was saved. | |
69 | ||
259bd3a0 LM |
70 | CONFIG_CMD_SPL_NOR_OFS Offset in NOR where the parameters area was saved. |
71 | ||
3e1b3939 SB |
72 | CONFIG_CMD_SPL_WRITE_SIZE Size of the parameters area to be copied |
73 | ||
74 | CONFIG_SPL_OS_BOOT Activate Falcon Mode. | |
75 | ||
76 | Function that a board must implement | |
77 | ------------------------------------ | |
78 | ||
79 | void spl_board_prepare_for_linux(void) : optional | |
80 | Called from SPL before starting the kernel | |
81 | ||
82 | spl_start_uboot() : required | |
83 | Returns "0" if SPL should start the kernel, "1" if U-Boot | |
84 | must be started. | |
85 | ||
3523df00 TR |
86 | Environment variables |
87 | --------------------- | |
88 | ||
89 | A board may chose to look at the environment for decisions about falcon | |
90 | mode. In this case the following variables may be supported: | |
91 | ||
92 | boot_os : Set to yes/Yes/true/True/1 to enable booting to OS, | |
93 | any other value to fall back to U-Boot (including | |
94 | unset) | |
ae1590ed TR |
95 | falcon_args_file : Filename to load as the 'args' portion of falcon mode |
96 | rather than the hard-coded value. | |
97 | falcon_image_file : Filename to load as the OS image portion of falcon | |
98 | mode rather than the hard-coded value. | |
3e1b3939 SB |
99 | |
100 | Using spl command | |
101 | ----------------- | |
102 | ||
103 | spl - SPL configuration | |
104 | ||
105 | Usage: | |
106 | ||
107 | spl export <img=atags|fdt> [kernel_addr] [initrd_addr] [fdt_addr ] | |
108 | ||
109 | img : "atags" or "fdt" | |
110 | kernel_addr : kernel is loaded as part of the boot process, but it is not started. | |
111 | This is the address where a kernel image is stored. | |
112 | initrd_addr : Address of initial ramdisk | |
113 | can be set to "-" if fdt_addr without initrd_addr is used | |
114 | fdt_addr : in case of fdt, the address of the device tree. | |
115 | ||
116 | The spl export command does not write to a storage media. The user is | |
117 | responsible to transfer the gathered information (assembled ATAGS list | |
118 | or prepared FDT) from temporary storage in RAM into persistant storage | |
119 | after each run of 'spl export'. Unfortunately the position of temporary | |
120 | storage can not be predicted nor provided at commandline, it depends | |
121 | highly on your system setup and your provided data (ATAGS or FDT). | |
122 | However at the end of an succesful 'spl export' run it will print the | |
767cb74a AG |
123 | RAM address of temporary storage. The RAM address of FDT will also be |
124 | set in the environment variable 'fdtargsaddr', the new length of the | |
125 | prepared FDT will be set in the environment variable 'fdtargslen'. | |
126 | These environment variables can be used in scripts for writing updated | |
127 | FDT to persistent storage. | |
128 | ||
3e1b3939 SB |
129 | Now the user have to save the generated BLOB from that printed address |
130 | to the pre-defined address in persistent storage | |
131 | (CONFIG_CMD_SPL_NAND_OFS in case of NAND). | |
132 | The following example shows how to prepare the data for Falcon Mode on | |
133 | twister board with ATAGS BLOB. | |
134 | ||
135 | The "spl export" command is prepared to work with ATAGS and FDT. However, | |
136 | using FDT is at the moment untested. The ppc port (see a3m071 example | |
137 | later) prepares the fdt blob with the fdt command instead. | |
138 | ||
139 | ||
140 | Usage on the twister board: | |
141 | -------------------------------- | |
142 | ||
143 | Using mtd names with the following (default) configuration | |
144 | for mtdparts: | |
145 | ||
146 | device nand0 <omap2-nand.0>, # parts = 9 | |
147 | #: name size offset mask_flags | |
148 | 0: MLO 0x00080000 0x00000000 0 | |
149 | 1: u-boot 0x00100000 0x00080000 0 | |
150 | 2: env1 0x00040000 0x00180000 0 | |
151 | 3: env2 0x00040000 0x001c0000 0 | |
152 | 4: kernel 0x00600000 0x00200000 0 | |
153 | 5: bootparms 0x00040000 0x00800000 0 | |
154 | 6: splashimg 0x00200000 0x00840000 0 | |
155 | 7: mini 0x02800000 0x00a40000 0 | |
156 | 8: rootfs 0x1cdc0000 0x03240000 0 | |
157 | ||
158 | ||
159 | twister => nand read 82000000 kernel | |
160 | ||
161 | NAND read: device 0 offset 0x200000, size 0x600000 | |
162 | 6291456 bytes read: OK | |
163 | ||
164 | Now the kernel is in RAM at address 0x82000000 | |
165 | ||
166 | twister => spl export atags 0x82000000 | |
167 | ## Booting kernel from Legacy Image at 82000000 ... | |
168 | Image Name: Linux-3.5.0-rc4-14089-gda0b7f4 | |
169 | Image Type: ARM Linux Kernel Image (uncompressed) | |
170 | Data Size: 3654808 Bytes = 3.5 MiB | |
171 | Load Address: 80008000 | |
172 | Entry Point: 80008000 | |
173 | Verifying Checksum ... OK | |
174 | Loading Kernel Image ... OK | |
175 | OK | |
176 | cmdline subcommand not supported | |
177 | bdt subcommand not supported | |
178 | Argument image is now in RAM at: 0x80000100 | |
179 | ||
180 | The result can be checked at address 0x80000100: | |
181 | ||
182 | twister => md 0x80000100 | |
183 | 80000100: 00000005 54410001 00000000 00000000 ......AT........ | |
184 | 80000110: 00000000 00000067 54410009 746f6f72 ....g.....ATroot | |
185 | 80000120: 65642f3d 666e2f76 77722073 73666e20 =/dev/nfs rw nfs | |
186 | ||
187 | The parameters generated with this step can be saved into NAND at the offset | |
188 | 0x800000 (value for twister for CONFIG_CMD_SPL_NAND_OFS) | |
189 | ||
190 | nand erase.part bootparms | |
191 | nand write 0x80000100 bootparms 0x4000 | |
192 | ||
193 | Now the parameters are stored into the NAND flash at the address | |
194 | CONFIG_CMD_SPL_NAND_OFS (=0x800000). | |
195 | ||
196 | Next time, the board can be started into Falcon Mode moving the | |
197 | setting the gpio (on twister gpio 55 is used) to kernel mode. | |
198 | ||
199 | The kernel is loaded directly by the SPL without passing through U-Boot. | |
200 | ||
201 | Example with FDT: a3m071 board | |
202 | ------------------------------- | |
203 | ||
204 | To boot the Linux kernel from the SPL, the DT blob (fdt) needs to get | |
205 | prepard/patched first. U-Boot usually inserts some dynamic values into | |
206 | the DT binary (blob), e.g. autodetected memory size, MAC addresses, | |
207 | clocks speeds etc. To generate this patched DT blob, you can use | |
208 | the following command: | |
209 | ||
210 | 1. Load fdt blob to SDRAM: | |
211 | => tftp 1800000 a3m071/a3m071.dtb | |
212 | ||
213 | 2. Set bootargs as desired for Linux booting (e.g. flash_mtd): | |
214 | => run mtdargs addip2 addtty | |
215 | ||
216 | 3. Use "fdt" commands to patch the DT blob: | |
217 | => fdt addr 1800000 | |
218 | => fdt boardsetup | |
219 | => fdt chosen | |
220 | ||
221 | 4. Display patched DT blob (optional): | |
222 | => fdt print | |
223 | ||
224 | 5. Save fdt to NOR flash: | |
225 | => erase fc060000 fc07ffff | |
226 | => cp.b 1800000 fc060000 10000 | |
227 | ... | |
228 | ||
229 | ||
230 | Falcon Mode was presented at the RMLL 2012. Slides are available at: | |
231 | ||
232 | http://schedule2012.rmll.info/IMG/pdf/LSM2012_UbootFalconMode_Babic.pdf |