@@ -70,6 +70,7 @@ def qemu_params(
70
70
globals = {},
71
71
traces = [],
72
72
qemu_args = [],
73
+ bootstrap = False ,
73
74
** kwargs ):
74
75
extra_params = {
75
76
"icount" : str (icount ),
@@ -79,6 +80,7 @@ def qemu_params(
79
80
"globals" : json .encode (globals ),
80
81
# The same goes for this array of strings:
81
82
"traces" : json .encode (traces ),
83
+ "bootstrap" : json .encode (bootstrap ),
82
84
}
83
85
84
86
return struct (
@@ -417,28 +419,35 @@ def _test_dispatch(ctx, exec_env, firmware):
417
419
"otp" : otp_image .short_path ,
418
420
}
419
421
420
- # Generate the flash backend image for QEMU emulation
421
- # TODO: when bootstrapping is available, this should always create a blank
422
- # flash image and bootstrap the data. Ideally, relevant info pages would
423
- # be spliced in at this step, but that is not yet supported by either
424
- # flashgen or by Bazel.
425
- flash_image = gen_flash (
426
- ctx ,
427
- flashgen = exec_env .flashgen ,
428
- firmware_bin = image ,
429
- # TODO: no support for convenience debug symbols from ELFs for now
430
- firmware_elf = None ,
431
- # Do not sanity check ELFs, because we do not expect the binary to
432
- # match the ELF because of the added manifest extensions (e.g. SPX
433
- # signatures) present in the signed binary.
434
- check_elfs = False ,
435
- )
436
- data_files += [flash_image ]
437
- qemu_args += ["-drive" , "if=mtd,id=eflash,bus=2,file=flash_img.bin,format=raw" ]
438
- test_script_fmt |= {
439
- "flash" : flash_image .short_path ,
440
- "mutable_flash" : "flash_img.bin" ,
441
- }
422
+ # If real bootstrapping is requested then prepare the correct command, otherwise we need
423
+ # to prepare a QEMU drive containing flash contents.
424
+ if param ["bootstrap" ] and json .decode (param ["bootstrap" ]):
425
+ test_script_fmt |= {"flash" : "" }
426
+ bootstrap_cmd = "bootstrap --clear-uart=true --reset-delay 1000ms {firmware}" .format (** param )
427
+ param ["bootstrap_cmd" ] = '--exec="{}"' .format (bootstrap_cmd )
428
+ else :
429
+ # Generate the flash backend image for QEMU emulation
430
+ # TODO: when bootstrapping is available, this should always create a blank
431
+ # flash image and bootstrap the data. Ideally, relevant info pages would
432
+ # be spliced in at this step, but that is not yet supported by either
433
+ # flashgen or by Bazel.
434
+ flash_image = gen_flash (
435
+ ctx ,
436
+ flashgen = exec_env .flashgen ,
437
+ firmware_bin = image ,
438
+ # TODO: no support for convenience debug symbols from ELFs for now
439
+ firmware_elf = None ,
440
+ # Do not sanity check ELFs, because we do not expect the binary to
441
+ # match the ELF because of the added manifest extensions (e.g. SPX
442
+ # signatures) present in the signed binary.
443
+ check_elfs = False ,
444
+ )
445
+ data_files += [flash_image ]
446
+ qemu_args += ["-drive" , "if=mtd,id=eflash,bus=2,file=flash_img.bin,format=raw" ]
447
+ test_script_fmt |= {
448
+ "flash" : flash_image .short_path ,
449
+ }
450
+ param ["bootstrap_cmd" ] = '--exec="no-op" # SKIPPING BOOTSTRAP'
442
451
443
452
# Get the pre-test_cmd args.
444
453
args = get_fallback (ctx , "attr.args" , exec_env )
0 commit comments