blob: 8009d2907b1042414347f424ff949551c674aca0 [file] [log] [blame]
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02001# SPDX-License-Identifier: GPL-2.0+
Tom Rini10e47792018-05-06 17:58:06 -04002# Copyright (c) 2013, Google Inc.
Simon Glassdb749192013-05-16 13:53:28 +00003#
Simon Glassfe394112017-08-05 10:28:40 -06004# Sanity check of the FIT handling in U-Boot
Simon Glassdb749192013-05-16 13:53:28 +00005
Paul Burton00f2d202017-09-14 14:34:43 -07006from __future__ import print_function
7
Simon Glassdb749192013-05-16 13:53:28 +00008import os
Simon Glassfe394112017-08-05 10:28:40 -06009import pytest
Simon Glassdb749192013-05-16 13:53:28 +000010import struct
Simon Glassfe394112017-08-05 10:28:40 -060011import u_boot_utils as util
Simon Glassdb749192013-05-16 13:53:28 +000012
13# Define a base ITS which we can adjust using % and a dictionary
14base_its = '''
15/dts-v1/;
16
17/ {
18 description = "Chrome OS kernel image with one or more FDT blobs";
19 #address-cells = <1>;
20
21 images {
22 kernel@1 {
23 data = /incbin/("%(kernel)s");
24 type = "kernel";
25 arch = "sandbox";
26 os = "linux";
Julius Werner97b09cd2019-07-24 19:37:55 -070027 compression = "%(compression)s";
Simon Glassdb749192013-05-16 13:53:28 +000028 load = <0x40000>;
29 entry = <0x8>;
30 };
Karl Apsiteaad8dd72015-05-21 09:52:50 -040031 kernel@2 {
32 data = /incbin/("%(loadables1)s");
33 type = "kernel";
34 arch = "sandbox";
35 os = "linux";
36 compression = "none";
37 %(loadables1_load)s
38 entry = <0x0>;
39 };
Simon Glassdb749192013-05-16 13:53:28 +000040 fdt@1 {
41 description = "snow";
Julius Werner97b09cd2019-07-24 19:37:55 -070042 data = /incbin/("%(fdt)s");
Simon Glassdb749192013-05-16 13:53:28 +000043 type = "flat_dt";
44 arch = "sandbox";
45 %(fdt_load)s
Julius Werner97b09cd2019-07-24 19:37:55 -070046 compression = "%(compression)s";
Simon Glassdb749192013-05-16 13:53:28 +000047 signature@1 {
48 algo = "sha1,rsa2048";
49 key-name-hint = "dev";
50 };
51 };
52 ramdisk@1 {
53 description = "snow";
54 data = /incbin/("%(ramdisk)s");
55 type = "ramdisk";
56 arch = "sandbox";
57 os = "linux";
58 %(ramdisk_load)s
Julius Werner97b09cd2019-07-24 19:37:55 -070059 compression = "%(compression)s";
Simon Glassdb749192013-05-16 13:53:28 +000060 };
Karl Apsiteaad8dd72015-05-21 09:52:50 -040061 ramdisk@2 {
62 description = "snow";
63 data = /incbin/("%(loadables2)s");
64 type = "ramdisk";
65 arch = "sandbox";
66 os = "linux";
67 %(loadables2_load)s
68 compression = "none";
69 };
Simon Glassdb749192013-05-16 13:53:28 +000070 };
71 configurations {
72 default = "conf@1";
73 conf@1 {
74 kernel = "kernel@1";
75 fdt = "fdt@1";
76 %(ramdisk_config)s
Karl Apsiteaad8dd72015-05-21 09:52:50 -040077 %(loadables_config)s
Simon Glassdb749192013-05-16 13:53:28 +000078 };
79 };
80};
81'''
82
83# Define a base FDT - currently we don't use anything in this
84base_fdt = '''
85/dts-v1/;
86
87/ {
88 model = "Sandbox Verified Boot Test";
89 compatible = "sandbox";
90
Simon Glass546bab12016-02-24 09:14:44 -070091 reset@0 {
92 compatible = "sandbox,reset";
93 };
94
Simon Glassdb749192013-05-16 13:53:28 +000095};
96'''
97
Robert P. J. Day8445f732017-03-13 06:50:55 -040098# This is the U-Boot script that is run for each test. First load the FIT,
99# then run the 'bootm' command, then save out memory from the places where
Simon Glassdb749192013-05-16 13:53:28 +0000100# we expect 'bootm' to write things. Then quit.
101base_script = '''
Simon Glassf250d472018-11-15 18:44:02 -0700102host load hostfs 0 %(fit_addr)x %(fit)s
Simon Glassdb749192013-05-16 13:53:28 +0000103fdt addr %(fit_addr)x
104bootm start %(fit_addr)x
105bootm loados
Simon Glassf250d472018-11-15 18:44:02 -0700106host save hostfs 0 %(kernel_addr)x %(kernel_out)s %(kernel_size)x
107host save hostfs 0 %(fdt_addr)x %(fdt_out)s %(fdt_size)x
108host save hostfs 0 %(ramdisk_addr)x %(ramdisk_out)s %(ramdisk_size)x
109host save hostfs 0 %(loadables1_addr)x %(loadables1_out)s %(loadables1_size)x
110host save hostfs 0 %(loadables2_addr)x %(loadables2_out)s %(loadables2_size)x
Simon Glassdb749192013-05-16 13:53:28 +0000111'''
112
Simon Glassfe394112017-08-05 10:28:40 -0600113@pytest.mark.boardspec('sandbox')
114@pytest.mark.buildconfigspec('fit_signature')
Stephen Warren2079db32017-09-18 11:11:49 -0600115@pytest.mark.requiredtool('dtc')
Simon Glassfe394112017-08-05 10:28:40 -0600116def test_fit(u_boot_console):
Simon Glass6867ec02017-08-05 10:28:39 -0600117 def make_fname(leaf):
118 """Make a temporary filename
Simon Glassdb749192013-05-16 13:53:28 +0000119
Simon Glass6867ec02017-08-05 10:28:39 -0600120 Args:
121 leaf: Leaf name of file to create (within temporary directory)
122 Return:
123 Temporary filename
124 """
Simon Glassdb749192013-05-16 13:53:28 +0000125
Simon Glassfe394112017-08-05 10:28:40 -0600126 return os.path.join(cons.config.build_dir, leaf)
Simon Glassdb749192013-05-16 13:53:28 +0000127
Simon Glass6867ec02017-08-05 10:28:39 -0600128 def filesize(fname):
129 """Get the size of a file
Simon Glassdb749192013-05-16 13:53:28 +0000130
Simon Glass6867ec02017-08-05 10:28:39 -0600131 Args:
132 fname: Filename to check
133 Return:
134 Size of file in bytes
135 """
136 return os.stat(fname).st_size
Simon Glassdb749192013-05-16 13:53:28 +0000137
Simon Glass6867ec02017-08-05 10:28:39 -0600138 def read_file(fname):
139 """Read the contents of a file
Simon Glassdb749192013-05-16 13:53:28 +0000140
Simon Glass6867ec02017-08-05 10:28:39 -0600141 Args:
142 fname: Filename to read
143 Returns:
144 Contents of file as a string
145 """
Paul Burton4c35e972017-09-14 14:34:48 -0700146 with open(fname, 'rb') as fd:
Simon Glass6867ec02017-08-05 10:28:39 -0600147 return fd.read()
Simon Glassdb749192013-05-16 13:53:28 +0000148
Simon Glass6867ec02017-08-05 10:28:39 -0600149 def make_dtb():
150 """Make a sample .dts file and compile it to a .dtb
Simon Glassdb749192013-05-16 13:53:28 +0000151
Simon Glass6867ec02017-08-05 10:28:39 -0600152 Returns:
153 Filename of .dtb file created
154 """
155 src = make_fname('u-boot.dts')
156 dtb = make_fname('u-boot.dtb')
157 with open(src, 'w') as fd:
Paul Burton00f2d202017-09-14 14:34:43 -0700158 print(base_fdt, file=fd)
Simon Glassfe394112017-08-05 10:28:40 -0600159 util.run_and_log(cons, ['dtc', src, '-O', 'dtb', '-o', dtb])
Simon Glass6867ec02017-08-05 10:28:39 -0600160 return dtb
Simon Glassdb749192013-05-16 13:53:28 +0000161
Simon Glass6867ec02017-08-05 10:28:39 -0600162 def make_its(params):
163 """Make a sample .its file with parameters embedded
Simon Glassdb749192013-05-16 13:53:28 +0000164
Simon Glass6867ec02017-08-05 10:28:39 -0600165 Args:
166 params: Dictionary containing parameters to embed in the %() strings
167 Returns:
168 Filename of .its file created
169 """
170 its = make_fname('test.its')
171 with open(its, 'w') as fd:
Paul Burton00f2d202017-09-14 14:34:43 -0700172 print(base_its % params, file=fd)
Simon Glass6867ec02017-08-05 10:28:39 -0600173 return its
Simon Glassdb749192013-05-16 13:53:28 +0000174
Simon Glass6867ec02017-08-05 10:28:39 -0600175 def make_fit(mkimage, params):
176 """Make a sample .fit file ready for loading
Simon Glassdb749192013-05-16 13:53:28 +0000177
Simon Glass6867ec02017-08-05 10:28:39 -0600178 This creates a .its script with the selected parameters and uses mkimage to
179 turn this into a .fit image.
Simon Glassdb749192013-05-16 13:53:28 +0000180
Simon Glass6867ec02017-08-05 10:28:39 -0600181 Args:
182 mkimage: Filename of 'mkimage' utility
183 params: Dictionary containing parameters to embed in the %() strings
184 Return:
185 Filename of .fit file created
186 """
187 fit = make_fname('test.fit')
188 its = make_its(params)
Simon Glassfe394112017-08-05 10:28:40 -0600189 util.run_and_log(cons, [mkimage, '-f', its, fit])
Simon Glass6867ec02017-08-05 10:28:39 -0600190 with open(make_fname('u-boot.dts'), 'w') as fd:
Paul Burton00f2d202017-09-14 14:34:43 -0700191 print(base_fdt, file=fd)
Simon Glass6867ec02017-08-05 10:28:39 -0600192 return fit
Simon Glassdb749192013-05-16 13:53:28 +0000193
Simon Glass6867ec02017-08-05 10:28:39 -0600194 def make_kernel(filename, text):
195 """Make a sample kernel with test data
Simon Glassdb749192013-05-16 13:53:28 +0000196
Simon Glass6867ec02017-08-05 10:28:39 -0600197 Args:
198 filename: the name of the file you want to create
199 Returns:
200 Full path and filename of the kernel it created
201 """
202 fname = make_fname(filename)
203 data = ''
204 for i in range(100):
205 data += 'this %s %d is unlikely to boot\n' % (text, i)
206 with open(fname, 'w') as fd:
Paul Burton00f2d202017-09-14 14:34:43 -0700207 print(data, file=fd)
Simon Glass6867ec02017-08-05 10:28:39 -0600208 return fname
Simon Glassdb749192013-05-16 13:53:28 +0000209
Simon Glass6867ec02017-08-05 10:28:39 -0600210 def make_ramdisk(filename, text):
211 """Make a sample ramdisk with test data
Simon Glassdb749192013-05-16 13:53:28 +0000212
Simon Glass6867ec02017-08-05 10:28:39 -0600213 Returns:
214 Filename of ramdisk created
215 """
216 fname = make_fname(filename)
217 data = ''
218 for i in range(100):
219 data += '%s %d was seldom used in the middle ages\n' % (text, i)
220 with open(fname, 'w') as fd:
Paul Burton00f2d202017-09-14 14:34:43 -0700221 print(data, file=fd)
Simon Glass6867ec02017-08-05 10:28:39 -0600222 return fname
Simon Glassdb749192013-05-16 13:53:28 +0000223
Julius Werner97b09cd2019-07-24 19:37:55 -0700224 def make_compressed(filename):
225 util.run_and_log(cons, ['gzip', '-f', '-k', filename])
226 return filename + '.gz'
227
Simon Glass6867ec02017-08-05 10:28:39 -0600228 def find_matching(text, match):
229 """Find a match in a line of text, and return the unmatched line portion
Simon Glassdb749192013-05-16 13:53:28 +0000230
Simon Glass6867ec02017-08-05 10:28:39 -0600231 This is used to extract a part of a line from some text. The match string
232 is used to locate the line - we use the first line that contains that
233 match text.
Simon Glassdb749192013-05-16 13:53:28 +0000234
Simon Glass6867ec02017-08-05 10:28:39 -0600235 Once we find a match, we discard the match string itself from the line,
236 and return what remains.
Simon Glassdb749192013-05-16 13:53:28 +0000237
Simon Glass6867ec02017-08-05 10:28:39 -0600238 TODO: If this function becomes more generally useful, we could change it
239 to use regex and return groups.
Simon Glassdb749192013-05-16 13:53:28 +0000240
Simon Glass6867ec02017-08-05 10:28:39 -0600241 Args:
Simon Glassfe394112017-08-05 10:28:40 -0600242 text: Text to check (list of strings, one for each command issued)
Simon Glass6867ec02017-08-05 10:28:39 -0600243 match: String to search for
244 Return:
245 String containing unmatched portion of line
246 Exceptions:
247 ValueError: If match is not found
Simon Glassdb749192013-05-16 13:53:28 +0000248
Simon Glassfe394112017-08-05 10:28:40 -0600249 >>> find_matching(['first line:10', 'second_line:20'], 'first line:')
Simon Glass6867ec02017-08-05 10:28:39 -0600250 '10'
Simon Glassfe394112017-08-05 10:28:40 -0600251 >>> find_matching(['first line:10', 'second_line:20'], 'second line')
Simon Glass6867ec02017-08-05 10:28:39 -0600252 Traceback (most recent call last):
253 ...
254 ValueError: Test aborted
Simon Glassfe394112017-08-05 10:28:40 -0600255 >>> find_matching('first line:10\', 'second_line:20'], 'second_line:')
Simon Glass6867ec02017-08-05 10:28:39 -0600256 '20'
Simon Glassfe394112017-08-05 10:28:40 -0600257 >>> find_matching('first line:10\', 'second_line:20\nthird_line:30'],
258 'third_line:')
259 '30'
Simon Glass6867ec02017-08-05 10:28:39 -0600260 """
Simon Glassfe394112017-08-05 10:28:40 -0600261 __tracebackhide__ = True
262 for line in '\n'.join(text).splitlines():
Simon Glass6867ec02017-08-05 10:28:39 -0600263 pos = line.find(match)
264 if pos != -1:
265 return line[:pos] + line[pos + len(match):]
Simon Glassdb749192013-05-16 13:53:28 +0000266
Simon Glassfe394112017-08-05 10:28:40 -0600267 pytest.fail("Expected '%s' but not found in output")
Simon Glassdb749192013-05-16 13:53:28 +0000268
Simon Glassfe394112017-08-05 10:28:40 -0600269 def check_equal(expected_fname, actual_fname, failure_msg):
270 """Check that a file matches its expected contents
Simon Glassdb749192013-05-16 13:53:28 +0000271
Simon Glass6867ec02017-08-05 10:28:39 -0600272 Args:
Simon Glassfe394112017-08-05 10:28:40 -0600273 expected_fname: Filename containing expected contents
274 actual_fname: Filename containing actual contents
275 failure_msg: Message to print on failure
Simon Glass6867ec02017-08-05 10:28:39 -0600276 """
Simon Glassfe394112017-08-05 10:28:40 -0600277 expected_data = read_file(expected_fname)
278 actual_data = read_file(actual_fname)
279 assert expected_data == actual_data, failure_msg
Simon Glassdb749192013-05-16 13:53:28 +0000280
Simon Glassfe394112017-08-05 10:28:40 -0600281 def check_not_equal(expected_fname, actual_fname, failure_msg):
282 """Check that a file does not match its expected contents
Simon Glassdb749192013-05-16 13:53:28 +0000283
Simon Glass6867ec02017-08-05 10:28:39 -0600284 Args:
Simon Glassfe394112017-08-05 10:28:40 -0600285 expected_fname: Filename containing expected contents
286 actual_fname: Filename containing actual contents
287 failure_msg: Message to print on failure
Simon Glass6867ec02017-08-05 10:28:39 -0600288 """
Simon Glassfe394112017-08-05 10:28:40 -0600289 expected_data = read_file(expected_fname)
290 actual_data = read_file(actual_fname)
291 assert expected_data != actual_data, failure_msg
Simon Glassdb749192013-05-16 13:53:28 +0000292
Simon Glassfe394112017-08-05 10:28:40 -0600293 def run_fit_test(mkimage):
Simon Glass6867ec02017-08-05 10:28:39 -0600294 """Basic sanity check of FIT loading in U-Boot
Simon Glassdb749192013-05-16 13:53:28 +0000295
Simon Glass6867ec02017-08-05 10:28:39 -0600296 TODO: Almost everything:
297 - hash algorithms - invalid hash/contents should be detected
298 - signature algorithms - invalid sig/contents should be detected
299 - compression
300 - checking that errors are detected like:
301 - image overwriting
302 - missing images
303 - invalid configurations
304 - incorrect os/arch/type fields
305 - empty data
306 - images too large/small
307 - invalid FDT (e.g. putting a random binary in instead)
308 - default configuration selection
309 - bootm command line parameters should have desired effect
310 - run code coverage to make sure we are testing all the code
311 """
Simon Glass6867ec02017-08-05 10:28:39 -0600312 # Set up invariant files
313 control_dtb = make_dtb()
314 kernel = make_kernel('test-kernel.bin', 'kernel')
315 ramdisk = make_ramdisk('test-ramdisk.bin', 'ramdisk')
316 loadables1 = make_kernel('test-loadables1.bin', 'lenrek')
317 loadables2 = make_ramdisk('test-loadables2.bin', 'ksidmar')
318 kernel_out = make_fname('kernel-out.bin')
Julius Werner97b09cd2019-07-24 19:37:55 -0700319 fdt = make_fname('u-boot.dtb')
Simon Glass6867ec02017-08-05 10:28:39 -0600320 fdt_out = make_fname('fdt-out.dtb')
321 ramdisk_out = make_fname('ramdisk-out.bin')
322 loadables1_out = make_fname('loadables1-out.bin')
323 loadables2_out = make_fname('loadables2-out.bin')
Simon Glassdb749192013-05-16 13:53:28 +0000324
Simon Glass6867ec02017-08-05 10:28:39 -0600325 # Set up basic parameters with default values
326 params = {
327 'fit_addr' : 0x1000,
Simon Glassdb749192013-05-16 13:53:28 +0000328
Simon Glass6867ec02017-08-05 10:28:39 -0600329 'kernel' : kernel,
330 'kernel_out' : kernel_out,
331 'kernel_addr' : 0x40000,
332 'kernel_size' : filesize(kernel),
Simon Glassdb749192013-05-16 13:53:28 +0000333
Julius Werner97b09cd2019-07-24 19:37:55 -0700334 'fdt' : fdt,
Simon Glass6867ec02017-08-05 10:28:39 -0600335 'fdt_out' : fdt_out,
336 'fdt_addr' : 0x80000,
337 'fdt_size' : filesize(control_dtb),
338 'fdt_load' : '',
Simon Glassdb749192013-05-16 13:53:28 +0000339
Simon Glass6867ec02017-08-05 10:28:39 -0600340 'ramdisk' : ramdisk,
341 'ramdisk_out' : ramdisk_out,
342 'ramdisk_addr' : 0xc0000,
343 'ramdisk_size' : filesize(ramdisk),
344 'ramdisk_load' : '',
345 'ramdisk_config' : '',
Karl Apsiteaad8dd72015-05-21 09:52:50 -0400346
Simon Glass6867ec02017-08-05 10:28:39 -0600347 'loadables1' : loadables1,
348 'loadables1_out' : loadables1_out,
349 'loadables1_addr' : 0x100000,
350 'loadables1_size' : filesize(loadables1),
351 'loadables1_load' : '',
Karl Apsiteaad8dd72015-05-21 09:52:50 -0400352
Simon Glass6867ec02017-08-05 10:28:39 -0600353 'loadables2' : loadables2,
354 'loadables2_out' : loadables2_out,
355 'loadables2_addr' : 0x140000,
356 'loadables2_size' : filesize(loadables2),
357 'loadables2_load' : '',
Karl Apsiteaad8dd72015-05-21 09:52:50 -0400358
Simon Glass6867ec02017-08-05 10:28:39 -0600359 'loadables_config' : '',
Julius Werner97b09cd2019-07-24 19:37:55 -0700360 'compression' : 'none',
Simon Glass6867ec02017-08-05 10:28:39 -0600361 }
Simon Glassdb749192013-05-16 13:53:28 +0000362
Simon Glass6867ec02017-08-05 10:28:39 -0600363 # Make a basic FIT and a script to load it
364 fit = make_fit(mkimage, params)
365 params['fit'] = fit
366 cmd = base_script % params
Simon Glassdb749192013-05-16 13:53:28 +0000367
Simon Glass6867ec02017-08-05 10:28:39 -0600368 # First check that we can load a kernel
369 # We could perhaps reduce duplication with some loss of readability
Simon Glassfe394112017-08-05 10:28:40 -0600370 cons.config.dtb = control_dtb
371 cons.restart_uboot()
372 with cons.log.section('Kernel load'):
373 output = cons.run_command_list(cmd.splitlines())
374 check_equal(kernel, kernel_out, 'Kernel not loaded')
375 check_not_equal(control_dtb, fdt_out,
376 'FDT loaded but should be ignored')
377 check_not_equal(ramdisk, ramdisk_out,
378 'Ramdisk loaded but should not be')
Simon Glassdb749192013-05-16 13:53:28 +0000379
Simon Glass6867ec02017-08-05 10:28:39 -0600380 # Find out the offset in the FIT where U-Boot has found the FDT
Simon Glassfe394112017-08-05 10:28:40 -0600381 line = find_matching(output, 'Booting using the fdt blob at ')
Simon Glass6867ec02017-08-05 10:28:39 -0600382 fit_offset = int(line, 16) - params['fit_addr']
383 fdt_magic = struct.pack('>L', 0xd00dfeed)
384 data = read_file(fit)
Simon Glassdb749192013-05-16 13:53:28 +0000385
Simon Glass6867ec02017-08-05 10:28:39 -0600386 # Now find where it actually is in the FIT (skip the first word)
387 real_fit_offset = data.find(fdt_magic, 4)
Simon Glassfe394112017-08-05 10:28:40 -0600388 assert fit_offset == real_fit_offset, (
389 'U-Boot loaded FDT from offset %#x, FDT is actually at %#x' %
390 (fit_offset, real_fit_offset))
Simon Glassdb749192013-05-16 13:53:28 +0000391
Simon Glass6867ec02017-08-05 10:28:39 -0600392 # Now a kernel and an FDT
Simon Glassfe394112017-08-05 10:28:40 -0600393 with cons.log.section('Kernel + FDT load'):
Simon Glass6867ec02017-08-05 10:28:39 -0600394 params['fdt_load'] = 'load = <%#x>;' % params['fdt_addr']
395 fit = make_fit(mkimage, params)
Simon Glassfe394112017-08-05 10:28:40 -0600396 cons.restart_uboot()
397 output = cons.run_command_list(cmd.splitlines())
398 check_equal(kernel, kernel_out, 'Kernel not loaded')
399 check_equal(control_dtb, fdt_out, 'FDT not loaded')
400 check_not_equal(ramdisk, ramdisk_out,
401 'Ramdisk loaded but should not be')
Simon Glassdb749192013-05-16 13:53:28 +0000402
Simon Glass6867ec02017-08-05 10:28:39 -0600403 # Try a ramdisk
Simon Glassfe394112017-08-05 10:28:40 -0600404 with cons.log.section('Kernel + FDT + Ramdisk load'):
Simon Glass6867ec02017-08-05 10:28:39 -0600405 params['ramdisk_config'] = 'ramdisk = "ramdisk@1";'
406 params['ramdisk_load'] = 'load = <%#x>;' % params['ramdisk_addr']
407 fit = make_fit(mkimage, params)
Simon Glassfe394112017-08-05 10:28:40 -0600408 cons.restart_uboot()
409 output = cons.run_command_list(cmd.splitlines())
410 check_equal(ramdisk, ramdisk_out, 'Ramdisk not loaded')
Simon Glassdb749192013-05-16 13:53:28 +0000411
Simon Glass6867ec02017-08-05 10:28:39 -0600412 # Configuration with some Loadables
Simon Glassfe394112017-08-05 10:28:40 -0600413 with cons.log.section('Kernel + FDT + Ramdisk load + Loadables'):
Simon Glass6867ec02017-08-05 10:28:39 -0600414 params['loadables_config'] = 'loadables = "kernel@2", "ramdisk@2";'
Simon Glassfe394112017-08-05 10:28:40 -0600415 params['loadables1_load'] = ('load = <%#x>;' %
416 params['loadables1_addr'])
417 params['loadables2_load'] = ('load = <%#x>;' %
418 params['loadables2_addr'])
Simon Glass6867ec02017-08-05 10:28:39 -0600419 fit = make_fit(mkimage, params)
Simon Glassfe394112017-08-05 10:28:40 -0600420 cons.restart_uboot()
421 output = cons.run_command_list(cmd.splitlines())
422 check_equal(loadables1, loadables1_out,
423 'Loadables1 (kernel) not loaded')
424 check_equal(loadables2, loadables2_out,
425 'Loadables2 (ramdisk) not loaded')
Simon Glassdb749192013-05-16 13:53:28 +0000426
Julius Werner97b09cd2019-07-24 19:37:55 -0700427 # Kernel, FDT and Ramdisk all compressed
428 with cons.log.section('(Kernel + FDT + Ramdisk) compressed'):
429 params['compression'] = 'gzip'
430 params['kernel'] = make_compressed(kernel)
431 params['fdt'] = make_compressed(fdt)
432 params['ramdisk'] = make_compressed(ramdisk)
433 fit = make_fit(mkimage, params)
434 cons.restart_uboot()
435 output = cons.run_command_list(cmd.splitlines())
436 check_equal(kernel, kernel_out, 'Kernel not loaded')
437 check_equal(control_dtb, fdt_out, 'FDT not loaded')
438 check_equal(ramdisk, ramdisk_out, 'Ramdisk not loaded')
439
440
Simon Glassfe394112017-08-05 10:28:40 -0600441 cons = u_boot_console
442 try:
443 # We need to use our own device tree file. Remember to restore it
444 # afterwards.
445 old_dtb = cons.config.dtb
446 mkimage = cons.config.build_dir + '/tools/mkimage'
447 run_fit_test(mkimage)
448 finally:
449 # Go back to the original U-Boot with the correct dtb.
450 cons.config.dtb = old_dtb
451 cons.restart_uboot()