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