blob: 3d7296ad913e7446d24d101e1394c3e6931127a2 [file] [log] [blame]
Simon Glassd49ff7e2023-06-23 13:22:08 +01001.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot FDT Overlay FIT usage
4============================
5
6Introduction
7------------
8
9In many cases it is desirable to have a single FIT image support a multitude
10of similar boards and their expansion options. The same kernel on DT enabled
11platforms can support this easily enough by providing a DT blob upon boot
12that matches the desired configuration.
13
14This document focuses on specifically using overlays as part of a FIT image.
15General information regarding overlays including its syntax and building it
16can be found in doc/README.fdt-overlays
17
18Configuration without overlays
19------------------------------
20
21Take a hypothetical board named 'foo' where there are different supported
22revisions, reva and revb. Assume that both board revisions can use add a bar
23add-on board, while only the revb board can use a baz add-on board.
24
25Without using overlays the configuration would be as follows for every case::
26
27 /dts-v1/;
28 / {
29 images {
30 kernel {
31 data = /incbin/("./zImage");
32 type = "kernel";
33 arch = "arm";
34 os = "linux";
35 load = <0x82000000>;
36 entry = <0x82000000>;
37 };
38 fdt-1 {
39 data = /incbin/("./foo-reva.dtb");
40 type = "flat_dt";
41 arch = "arm";
42 };
43 fdt-2 {
44 data = /incbin/("./foo-revb.dtb");
45 type = "flat_dt";
46 arch = "arm";
47 };
48 fdt-3 {
49 data = /incbin/("./foo-reva-bar.dtb");
50 type = "flat_dt";
51 arch = "arm";
52 };
53 fdt-4 {
54 data = /incbin/("./foo-revb-bar.dtb");
55 type = "flat_dt";
56 arch = "arm";
57 };
58 fdt-5 {
59 data = /incbin/("./foo-revb-baz.dtb");
60 type = "flat_dt";
61 arch = "arm";
62 };
63 fdt-6 {
64 data = /incbin/("./foo-revb-bar-baz.dtb");
65 type = "flat_dt";
66 arch = "arm";
67 };
68 };
69
70 configurations {
71 default = "foo-reva.dtb;
72 foo-reva.dtb {
73 kernel = "kernel";
74 fdt = "fdt-1";
75 };
76 foo-revb.dtb {
77 kernel = "kernel";
78 fdt = "fdt-2";
79 };
80 foo-reva-bar.dtb {
81 kernel = "kernel";
82 fdt = "fdt-3";
83 };
84 foo-revb-bar.dtb {
85 kernel = "kernel";
86 fdt = "fdt-4";
87 };
88 foo-revb-baz.dtb {
89 kernel = "kernel";
90 fdt = "fdt-5";
91 };
92 foo-revb-bar-baz.dtb {
93 kernel = "kernel";
94 fdt = "fdt-6";
95 };
96 };
97 };
98
99Note the blob needs to be compiled for each case and the combinatorial explosion of
100configurations. A typical device tree blob is in the low hunderds of kbytes so a
101multitude of configuration grows the image quite a bit.
102
103Booting this image is done by using::
104
105 # bootm <addr>#<config>
106
107Where config is one of::
108
109 foo-reva.dtb, foo-revb.dtb, foo-reva-bar.dtb, foo-revb-bar.dtb,
110 foo-revb-baz.dtb, foo-revb-bar-baz.dtb
111
112This selects the DTB to use when booting.
113
Heinrich Schuchardt6abe4692025-03-26 11:10:24 +0100114.. _fit_configuration_using_overlays:
115
Simon Glassd49ff7e2023-06-23 13:22:08 +0100116Configuration using overlays
117----------------------------
118
119Device tree overlays can be applied to a base DT and result in the same blob
120being passed to the booting kernel. This saves on space and avoid the combinatorial
121explosion problem::
122
123 /dts-v1/;
124 / {
125 images {
126 kernel {
127 data = /incbin/("./zImage");
128 type = "kernel";
129 arch = "arm";
130 os = "linux";
131 load = <0x82000000>;
132 entry = <0x82000000>;
133 };
134 fdt-1 {
135 data = /incbin/("./foo.dtb");
136 type = "flat_dt";
137 arch = "arm";
138 load = <0x87f00000>;
139 };
140 fdt-2 {
141 data = /incbin/("./reva.dtbo");
142 type = "flat_dt";
143 arch = "arm";
144 load = <0x87fc0000>;
145 };
146 fdt-3 {
147 data = /incbin/("./revb.dtbo");
148 type = "flat_dt";
149 arch = "arm";
150 load = <0x87fc0000>;
151 };
152 fdt-4 {
153 data = /incbin/("./bar.dtbo");
154 type = "flat_dt";
155 arch = "arm";
156 load = <0x87fc0000>;
157 };
158 fdt-5 {
159 data = /incbin/("./baz.dtbo");
160 type = "flat_dt";
161 arch = "arm";
162 load = <0x87fc0000>;
163 };
164 };
165
166 configurations {
167 default = "foo-reva.dtb;
168 foo-reva.dtb {
169 kernel = "kernel";
170 fdt = "fdt-1", "fdt-2";
171 };
172 foo-revb.dtb {
173 kernel = "kernel";
174 fdt = "fdt-1", "fdt-3";
175 };
176 foo-reva-bar.dtb {
177 kernel = "kernel";
178 fdt = "fdt-1", "fdt-2", "fdt-4";
179 };
180 foo-revb-bar.dtb {
181 kernel = "kernel";
182 fdt = "fdt-1", "fdt-3", "fdt-4";
183 };
184 foo-revb-baz.dtb {
185 kernel = "kernel";
186 fdt = "fdt-1", "fdt-3", "fdt-5";
187 };
188 foo-revb-bar-baz.dtb {
189 kernel = "kernel";
190 fdt = "fdt-1", "fdt-3", "fdt-4", "fdt-5";
191 };
192 bar {
193 fdt = "fdt-4";
194 };
195 baz {
196 fdt = "fdt-5";
197 };
198 };
199 };
200
201Booting this image is exactly the same as the non-overlay example.
202u-boot will retrieve the base blob and apply the overlays in sequence as
203they are declared in the configuration.
204
205Note the minimum amount of different DT blobs, as well as the requirement for
206the DT blobs to have a load address; the overlay application requires the blobs
207to be writeable.
208
209Configuration using overlays and feature selection
210--------------------------------------------------
211
212Although the configuration in the previous section works is a bit inflexible
213since it requires all possible configuration options to be laid out before
214hand in the FIT image. For the add-on boards the extra config selection method
215might make sense.
216
217Note the two bar & baz configuration nodes. To boot a reva board with
218the bar add-on board enabled simply use::
219
220 => bootm <addr>#foo-reva.dtb#bar
221
222While booting a revb with bar and baz is as follows::
223
224 => bootm <addr>#foo-revb.dtb#bar#baz
225
226The limitation for a feature selection configuration node is that a single
227fdt option is currently supported.
228
229.. sectionauthor:: Pantelis Antoniou <pantelis.antoniou@konsulko.com>, 12/6/2017