blob: ca7ef8ea40d66a747950ee91b36dfd3d3bff4a0f [file] [log] [blame]
Michal Simek95ec8302018-05-30 13:42:22 +02001# SPDX-License-Identifier: GPL-2.0
2#
3# Copyright (c) 2018, Xilinx Inc.
4#
5# Michal Simek
6# Siva Durga Prasad Paladugu
7
8import pytest
9import re
10import random
11import u_boot_utils
12
13"""
14Note: This test relies on boardenv_* containing configuration values to define
15the network available and files to be used for testing. Without this, this test
16will be automatically skipped.
17
18For example:
19
20# True if a DHCP server is attached to the network, and should be tested.
21env__net_dhcp_server = True
22
23# A list of environment variables that should be set in order to configure a
24# static IP. In this test case we atleast need serverip for performing tftpb
25# to get required files.
26env__net_static_env_vars = [
Simon Glasse9f4d872018-12-27 08:11:13 -070027 ('ipaddr', '10.0.0.100'),
28 ('netmask', '255.255.255.0'),
29 ('serverip', '10.0.0.1'),
Michal Simek95ec8302018-05-30 13:42:22 +020030]
31
32# Details regarding the files that may be read from a TFTP server. .
33env__fpga_secure_readable_file = {
Simon Glasse9f4d872018-12-27 08:11:13 -070034 'fn': 'auth_bhdr_ppk1_bit.bin',
35 'enckupfn': 'auth_bhdr_enc_kup_load_bit.bin',
36 'addr': 0x1000000,
37 'keyaddr': 0x100000,
38 'keyfn': 'key.txt',
Michal Simek95ec8302018-05-30 13:42:22 +020039}
40
41env__fpga_under_test = {
Simon Glasse9f4d872018-12-27 08:11:13 -070042 'dev': 0,
43 'addr' : 0x1000000,
44 'bitstream_load': 'compress.bin',
45 'bitstream_load_size': 1831960,
46 'bitstream_loadp': 'compress_pr.bin',
47 'bitstream_loadp_size': 423352,
48 'bitstream_loadb': 'compress.bit',
49 'bitstream_loadb_size': 1832086,
50 'bitstream_loadbp': 'compress_pr.bit',
51 'bitstream_loadbp_size': 423491,
52 'mkimage_legacy': 'download.ub',
53 'mkimage_legacy_size': 13321468,
54 'mkimage_legacy_gz': 'download.gz.ub',
55 'mkimage_legacy_gz_size': 53632,
56 'mkimage_fit': 'download-fit.ub',
57 'mkimage_fit_size': 13322784,
58 'loadfs': 'mmc 0 compress.bin',
59 'loadfs_size': 1831960,
60 'loadfs_block_size': 0x10000,
Michal Simek95ec8302018-05-30 13:42:22 +020061}
62"""
63
64import test_net
65
66def check_dev(u_boot_console):
67 f = u_boot_console.config.env.get('env__fpga_under_test', None)
68 if not f:
69 pytest.skip('No FPGA to test')
70
71 dev = f.get('dev', -1)
72 if dev < 0:
73 pytest.fail('No dev specified via env__fpga_under_test')
74
75 return dev, f
76
77def load_file_from_var(u_boot_console, name):
78 dev, f = check_dev(u_boot_console)
79
80 addr = f.get('addr', -1)
81 if addr < 0:
82 pytest.fail('No address specified via env__fpga_under_test')
83
84 test_net.test_net_dhcp(u_boot_console)
85 test_net.test_net_setup_static(u_boot_console)
86 bit = f['%s' % (name)]
87 bit_size = f['%s_size' % (name)]
88
89 expected_tftp = 'Bytes transferred = %d' % bit_size
90 output = u_boot_console.run_command('tftpboot %x %s' % (addr, bit))
91 assert expected_tftp in output
92
93 return f, dev, addr, bit, bit_size
94
95###### FPGA FAIL test ######
96expected_usage = 'fpga - loadable FPGA image support'
97
98@pytest.mark.xfail
99@pytest.mark.buildconfigspec('cmd_fpga')
100def test_fpga_fail(u_boot_console):
101 # Test non valid fpga subcommand
102 expected = 'fpga: non existing command'
103 output = u_boot_console.run_command('fpga broken 0')
104 #assert expected in output
105 assert expected_usage in output
106
107@pytest.mark.buildconfigspec('cmd_fpga')
108def test_fpga_help(u_boot_console):
109 # Just show help
110 output = u_boot_console.run_command('fpga')
111 assert expected_usage in output
112
113
114###### FPGA DUMP tests ######
115
116@pytest.mark.buildconfigspec('cmd_fpga')
117def test_fpga_dump(u_boot_console):
118 pytest.skip('Not implemented now')
119
120@pytest.mark.buildconfigspec('cmd_fpga')
121def test_fpga_dump_variable(u_boot_console):
122 # Same as above but via "fpga" variable
123 pytest.skip('Not implemented now')
124
125###### FPGA INFO tests ######
126
127@pytest.mark.buildconfigspec('cmd_fpga')
128def test_fpga_info_fail(u_boot_console):
129 # Maybe this can be skipped completely
130 dev, f = check_dev(u_boot_console)
131
132 # Multiple parameters to fpga info should fail
133 expected = 'fpga: more parameters passed'
134 output = u_boot_console.run_command('fpga info 0 0')
135 #assert expected in output
136 assert expected_usage in output
137
138@pytest.mark.buildconfigspec('cmd_fpga')
139def test_fpga_info_list(u_boot_console):
140 # Maybe this can be skipped completely
141 dev, f = check_dev(u_boot_console)
142
143 # Code is design in a way that if fpga dev is not passed it should
144 # return list of all fpga devices in the system
145 u_boot_console.run_command('setenv fpga')
146 output = u_boot_console.run_command('fpga info')
147 assert expected_usage not in output
148
149@pytest.mark.buildconfigspec('cmd_fpga')
150def test_fpga_info(u_boot_console):
151 dev, f = check_dev(u_boot_console)
152
153 output = u_boot_console.run_command('fpga info %x' % (dev))
154 assert expected_usage not in output
155
156@pytest.mark.buildconfigspec('cmd_fpga')
157def test_fpga_info_variable(u_boot_console):
158 dev, f = check_dev(u_boot_console)
159
160 #
161 # fpga variable is storing device number which doesn't need to be passed
162 #
163 u_boot_console.run_command('setenv fpga %x' % (dev))
164
165 output = u_boot_console.run_command('fpga info')
166 # Variable cleanup
167 u_boot_console.run_command('setenv fpga')
168 assert expected_usage not in output
169
170###### FPGA LOAD tests ######
171
172@pytest.mark.buildconfigspec('cmd_fpga')
173@pytest.mark.buildconfigspec('cmd_echo')
174def test_fpga_load_fail(u_boot_console):
175 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'bitstream_load')
176
177 for cmd in ['dump', 'load', 'loadb']:
Tom Rini7f24c192019-10-24 11:59:20 -0400178 # missing dev parameter
179 expected = 'fpga: incorrect parameters passed'
180 output = u_boot_console.run_command('fpga %s %x $filesize' % (cmd, addr))
181 #assert expected in output
182 assert expected_usage in output
Michal Simek95ec8302018-05-30 13:42:22 +0200183
Tom Rini7f24c192019-10-24 11:59:20 -0400184 # more parameters - 0 at the end
185 expected = 'fpga: more parameters passed'
186 output = u_boot_console.run_command('fpga %s %x %x $filesize 0' % (cmd, dev, addr))
187 #assert expected in output
188 assert expected_usage in output
Michal Simek95ec8302018-05-30 13:42:22 +0200189
Tom Rini7f24c192019-10-24 11:59:20 -0400190 # 0 address
191 expected = 'fpga: zero fpga_data address'
192 output = u_boot_console.run_command('fpga %s %x 0 $filesize' % (cmd, dev))
193 #assert expected in output
194 assert expected_usage in output
Michal Simek95ec8302018-05-30 13:42:22 +0200195
Tom Rini7f24c192019-10-24 11:59:20 -0400196 # 0 filesize
197 expected = 'fpga: zero size'
198 output = u_boot_console.run_command('fpga %s %x %x 0' % (cmd, dev, addr))
199 #assert expected in output
200 assert expected_usage in output
Michal Simek95ec8302018-05-30 13:42:22 +0200201
202@pytest.mark.buildconfigspec('cmd_fpga')
203@pytest.mark.buildconfigspec('cmd_echo')
204def test_fpga_load(u_boot_console):
205 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'bitstream_load')
206
207 expected_text = 'FPGA loaded successfully'
208 output = u_boot_console.run_command('fpga load %x %x $filesize && echo %s' % (dev, addr, expected_text))
209 assert expected_text in output
210
211@pytest.mark.buildconfigspec('cmd_fpga')
212@pytest.mark.buildconfigspec('cmd_fpga_loadp')
213@pytest.mark.buildconfigspec('cmd_echo')
214def test_fpga_loadp(u_boot_console):
215 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'bitstream_load')
216
217 expected_text = 'FPGA loaded successfully'
218 output = u_boot_console.run_command('fpga load %x %x $filesize && echo %s' % (dev, addr, expected_text))
219 assert expected_text in output
220
221 # And load also partial bistream
222 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'bitstream_loadp')
223
224 expected_text = 'FPGA loaded successfully'
225 output = u_boot_console.run_command('fpga loadp %x %x $filesize && echo %s' % (dev, addr, expected_text))
226 assert expected_text in output
227
228@pytest.mark.buildconfigspec('cmd_fpga')
229@pytest.mark.buildconfigspec('cmd_echo')
230def test_fpga_loadb(u_boot_console):
231 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'bitstream_loadb')
232
233 expected_text = 'FPGA loaded successfully'
234 output = u_boot_console.run_command('fpga loadb %x %x $filesize && echo %s' % (dev, addr, expected_text))
235 assert expected_text in output
236
237@pytest.mark.buildconfigspec('cmd_fpga')
238@pytest.mark.buildconfigspec('cmd_fpga_loadbp')
239@pytest.mark.buildconfigspec('cmd_echo')
240def test_fpga_loadbp(u_boot_console):
241 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'bitstream_loadb')
242
243 expected_text = 'FPGA loaded successfully'
244 output = u_boot_console.run_command('fpga loadb %x %x $filesize && echo %s' % (dev, addr, expected_text))
245 assert expected_text in output
246
247 # And load also partial bistream in bit format
248 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'bitstream_loadbp')
249
250 expected_text = 'FPGA loaded successfully'
251 output = u_boot_console.run_command('fpga loadbp %x %x $filesize && echo %s' % (dev, addr, expected_text))
252 assert expected_text in output
253
254###### FPGA LOADMK tests ######
255
256@pytest.mark.buildconfigspec('cmd_fpga')
257@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
258@pytest.mark.buildconfigspec('cmd_echo')
259@pytest.mark.buildconfigspec('image_format_legacy')
260def test_fpga_loadmk_fail(u_boot_console):
261 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_legacy')
262
263 u_boot_console.run_command('imi %x' % (addr))
264
265 # load image but pass incorrect address to show error message
266 expected = 'Unknown image type'
267 output = u_boot_console.run_command('fpga loadmk %x %x' % (dev, addr + 0x10))
268 assert expected in output
269
270 # Pass more parameters then command expects - 0 at the end
271 output = u_boot_console.run_command('fpga loadmk %x %x 0' % (dev, addr))
272 #assert expected in output
273 assert expected_usage in output
274
275@pytest.mark.buildconfigspec('cmd_fpga')
276@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
277@pytest.mark.buildconfigspec('cmd_echo')
278@pytest.mark.buildconfigspec('image_format_legacy')
279def test_fpga_loadmk_legacy(u_boot_console):
280 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_legacy')
281
282 u_boot_console.run_command('imi %x' % (addr))
283
284 expected_text = 'FPGA loaded successfully'
285 output = u_boot_console.run_command('fpga loadmk %x %x && echo %s' % (dev, addr, expected_text))
286 assert expected_text in output
287
288@pytest.mark.xfail
289@pytest.mark.buildconfigspec('cmd_fpga')
290@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
291@pytest.mark.buildconfigspec('cmd_echo')
292@pytest.mark.buildconfigspec('image_format_legacy')
293def test_fpga_loadmk_legacy_variable_fpga(u_boot_console):
294 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_legacy')
295
296 u_boot_console.run_command('imi %x' % (addr))
297
298 u_boot_console.run_command('setenv fpga %x' % (dev))
299
300 # this testcase should cover case which looks like it is supported but dev pointer is broken by loading mkimage address
301 expected_text = 'FPGA loaded successfully'
302 output = u_boot_console.run_command('fpga loadmk %x && echo %s' % (addr, expected_text))
303 u_boot_console.run_command('setenv fpga')
304 assert expected_text in output
305
306@pytest.mark.buildconfigspec('cmd_fpga')
307@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
308@pytest.mark.buildconfigspec('cmd_echo')
309@pytest.mark.buildconfigspec('image_format_legacy')
310def test_fpga_loadmk_legacy_variable_fpgadata(u_boot_console):
311 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_legacy')
312
313 u_boot_console.run_command('imi %x' % (addr))
314
315 u_boot_console.run_command('setenv fpgadata %x' % (addr))
316
317 # this testcase should cover case which looks like it is supported but dev pointer is broken by loading mkimage address
318 expected_text = 'FPGA loaded successfully'
319 output = u_boot_console.run_command('fpga loadmk %x && echo %s' % (dev, expected_text))
320 u_boot_console.run_command('setenv fpgadata')
321 assert expected_text in output
322
323@pytest.mark.buildconfigspec('cmd_fpga')
324@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
325@pytest.mark.buildconfigspec('cmd_echo')
326@pytest.mark.buildconfigspec('image_format_legacy')
327def test_fpga_loadmk_legacy_variable(u_boot_console):
328 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_legacy')
329
330 u_boot_console.run_command('imi %x' % (addr))
331
332 u_boot_console.run_command('setenv fpga %x' % (dev))
333 u_boot_console.run_command('setenv fpgadata %x' % (addr))
334
335 # this testcase should cover case which looks like it is supported but dev pointer is broken by loading mkimage address
336 expected_text = 'FPGA loaded successfully'
337 output = u_boot_console.run_command('fpga loadmk && echo %s' % (expected_text))
338 u_boot_console.run_command('setenv fpga')
339 u_boot_console.run_command('setenv fpgadata')
340 assert expected_text in output
341
342@pytest.mark.buildconfigspec('cmd_fpga')
343@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
344@pytest.mark.buildconfigspec('cmd_echo')
345@pytest.mark.buildconfigspec('image_format_legacy')
346@pytest.mark.buildconfigspec('gzip')
347def test_fpga_loadmk_legacy_gz(u_boot_console):
348 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_legacy_gz')
349
350 u_boot_console.run_command('imi %x' % (addr))
351
352 expected_text = 'FPGA loaded successfully'
353 output = u_boot_console.run_command('fpga loadmk %x %x && echo %s' % (dev, addr, expected_text))
354 assert expected_text in output
355
356@pytest.mark.buildconfigspec('cmd_fpga')
357@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
358@pytest.mark.buildconfigspec('fit')
359@pytest.mark.buildconfigspec('cmd_echo')
Michal Simek9b3fe132019-02-18 13:22:56 +0100360def test_fpga_loadmk_fit_external(u_boot_console):
361 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_fit_external')
362
363 u_boot_console.run_command('imi %x' % (addr))
364
365 expected_text = 'FPGA loaded successfully'
366 output = u_boot_console.run_command('fpga loadmk %x %x:fpga && echo %s' % (dev, addr, expected_text))
367 assert expected_text in output
368
369@pytest.mark.buildconfigspec('cmd_fpga')
370@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
371@pytest.mark.buildconfigspec('fit')
372@pytest.mark.buildconfigspec('cmd_echo')
Michal Simek95ec8302018-05-30 13:42:22 +0200373def test_fpga_loadmk_fit(u_boot_console):
374 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_fit')
375
376 u_boot_console.run_command('imi %x' % (addr))
377
378 expected_text = 'FPGA loaded successfully'
379 output = u_boot_console.run_command('fpga loadmk %x %x:fpga && echo %s' % (dev, addr, expected_text))
380 assert expected_text in output
381
382@pytest.mark.buildconfigspec('cmd_fpga')
383@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
384@pytest.mark.buildconfigspec('fit')
385@pytest.mark.buildconfigspec('cmd_echo')
386def test_fpga_loadmk_fit_variable_fpga(u_boot_console):
387 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_fit')
388
389 u_boot_console.run_command('imi %x' % (addr))
390 # FIXME this should fail - broken support in past
391 u_boot_console.run_command('setenv fpga %x' % (dev))
392
393 expected_text = 'FPGA loaded successfully'
394 output = u_boot_console.run_command('fpga loadmk %x:fpga && echo %s' % (addr, expected_text))
395 u_boot_console.run_command('setenv fpga')
396 assert expected_text in output
397
398@pytest.mark.buildconfigspec('cmd_fpga')
399@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
400@pytest.mark.buildconfigspec('fit')
401@pytest.mark.buildconfigspec('cmd_echo')
402def test_fpga_loadmk_fit_variable_fpgadata(u_boot_console):
403 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_fit')
404
405 u_boot_console.run_command('imi %x' % (addr))
406 # FIXME this should fail - broken support in past
407 u_boot_console.run_command('setenv fpgadata %x:fpga' % (addr))
408
409 expected_text = 'FPGA loaded successfully'
410 output = u_boot_console.run_command('fpga loadmk %x && echo %s' % (dev, expected_text))
411 u_boot_console.run_command('setenv fpgadata')
412 assert expected_text in output
413
414@pytest.mark.buildconfigspec('cmd_fpga')
415@pytest.mark.buildconfigspec('cmd_fpga_loadmk')
416@pytest.mark.buildconfigspec('fit')
417@pytest.mark.buildconfigspec('cmd_echo')
418def test_fpga_loadmk_fit_variable(u_boot_console):
419 f, dev, addr, bit, bit_size = load_file_from_var(u_boot_console, 'mkimage_fit')
420
421 u_boot_console.run_command('imi %x' % (addr))
422
423 u_boot_console.run_command('setenv fpga %x' % (dev))
424 u_boot_console.run_command('setenv fpgadata %x:fpga' % (addr))
425
426 expected_text = 'FPGA loaded successfully'
427 output = u_boot_console.run_command('fpga loadmk && echo %s' % (expected_text))
428 u_boot_console.run_command('setenv fpga')
429 u_boot_console.run_command('setenv fpgadata')
430 assert expected_text in output
431
432###### FPGA LOAD tests ######
433
434@pytest.mark.buildconfigspec('cmd_fpga')
435def test_fpga_loadfs_fail(u_boot_console):
436 dev, f = check_dev(u_boot_console)
437
438 addr = f.get('addr', -1)
439 if addr < 0:
440 pytest.fail('No address specified via env__fpga_under_test')
441
442 bit = f['loadfs']
443 bit_size = f['loadfs_size']
444 block_size = f['loadfs_block_size']
445
446 # less params - dev number removed
447 expected = 'fpga: incorrect parameters passed'
448 output = u_boot_console.run_command('fpga loadfs %x %x %x %s' % (addr, bit_size, block_size, bit))
449 #assert expected in output
450 assert expected_usage in output
451
452 # one more param - 0 at the end
453 # This is the longest command that's why there is no message from cmd/fpga.c
454 output = u_boot_console.run_command('fpga loadfs %x %x %x %x %s 0' % (dev, addr, bit_size, block_size, bit))
455 assert expected_usage in output
456
457 # zero address 0
458 expected = 'fpga: zero fpga_data address'
459 output = u_boot_console.run_command('fpga loadfs %x %x %x %x %s' % (dev, 0, bit_size, block_size, bit))
460 #assert expected in output
461 assert expected_usage in output
462
463 # bit_size 0
464 expected = 'fpga: zero size'
465 output = u_boot_console.run_command('fpga loadfs %x %x %x %x %s' % (dev, addr, 0, block_size, bit))
466 #assert expected in output
467 assert expected_usage in output
468
469 # block size 0
470 # FIXME this should pass but it failing too
471 output = u_boot_console.run_command('fpga loadfs %x %x %x %x %s' % (dev, addr, bit_size, 0, bit))
472 assert expected_usage in output
473
474 # non existing bitstream name
475 expected = 'Unable to read file noname'
476 output = u_boot_console.run_command('fpga loadfs %x %x %x %x mmc 0 noname' % (dev, addr, bit_size, block_size))
477 assert expected in output
478 assert expected_usage in output
479
480 # -1 dev number
481 expected = 'fpga_fsload: Invalid device number -1'
482 output = u_boot_console.run_command('fpga loadfs %d %x %x %x mmc 0 noname' % (-1, addr, bit_size, block_size))
483 assert expected in output
484 assert expected_usage in output
485
486
487@pytest.mark.buildconfigspec('cmd_fpga')
488@pytest.mark.buildconfigspec('cmd_echo')
489def test_fpga_loadfs(u_boot_console):
490 dev, f = check_dev(u_boot_console)
491
492 addr = f.get('addr', -1)
493 if addr < 0:
494 pytest.fail('No address specified via env__fpga_under_test')
495
496 bit = f['loadfs']
497 bit_size = f['loadfs_size']
498 block_size = f['loadfs_block_size']
499
500 # This should be done better
501 expected_text = 'FPGA loaded successfully'
502 output = u_boot_console.run_command('fpga loadfs %x %x %x %x %s && echo %s' % (dev, addr, bit_size, block_size, bit, expected_text))
503 assert expected_text in output
504
505@pytest.mark.buildconfigspec('cmd_fpga')
506@pytest.mark.buildconfigspec('cmd_fpga_load_secure')
507@pytest.mark.buildconfigspec('cmd_net')
508@pytest.mark.buildconfigspec('cmd_dhcp')
509@pytest.mark.buildconfigspec('net')
510def test_fpga_secure_bit_auth(u_boot_console):
511
512 test_net.test_net_dhcp(u_boot_console)
513 test_net.test_net_setup_static(u_boot_console)
514
515 f = u_boot_console.config.env.get('env__fpga_secure_readable_file', None)
516 if not f:
517 pytest.skip('No TFTP readable file to read')
518
519 addr = f.get('addr', None)
520 if not addr:
521 addr = u_boot_utils.find_ram_base(u_boot_console)
522
523 expected_tftp = 'Bytes transferred = '
524 fn = f['fn']
525 output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
526 assert expected_tftp in output
527
528 expected_zynqmpsecure = 'Bitstream successfully loaded'
529 output = u_boot_console.run_command('fpga loads 0 %x $filesize 0 2' % (addr))
530 assert expected_zynqmpsecure in output
531
532
533@pytest.mark.buildconfigspec('cmd_fpga')
534@pytest.mark.buildconfigspec('cmd_fpga_load_secure')
535@pytest.mark.buildconfigspec('cmd_net')
536@pytest.mark.buildconfigspec('cmd_dhcp')
537@pytest.mark.buildconfigspec('net')
538def test_fpga_secure_bit_img_auth_kup(u_boot_console):
539
540 test_net.test_net_dhcp(u_boot_console)
541 test_net.test_net_setup_static(u_boot_console)
542
543 f = u_boot_console.config.env.get('env__fpga_secure_readable_file', None)
544 if not f:
545 pytest.skip('No TFTP readable file to read')
546
547 keyaddr = f.get('keyaddr', None)
548 if not keyaddr:
549 addr = u_boot_utils.find_ram_base(u_boot_console)
550 expected_tftp = 'Bytes transferred = '
551 keyfn = f['keyfn']
552 output = u_boot_console.run_command('tftpboot %x %s' % (keyaddr, keyfn))
553 assert expected_tftp in output
554
555 addr = f.get('addr', None)
556 if not addr:
557 addr = u_boot_utils.find_ram_base(u_boot_console)
558 expected_tftp = 'Bytes transferred = '
559 fn = f['enckupfn']
560 output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
561 assert expected_tftp in output
562
563 expected_zynqmpsecure = 'Bitstream successfully loaded'
564 output = u_boot_console.run_command('fpga loads 0 %x $filesize 0 1 %x' % (addr, keyaddr))
565 assert expected_zynqmpsecure in output