@@ -39,6 +39,7 @@ def qemu_params(
3939 globals = {},
4040 traces = [],
4141 qemu_args = [],
42+ bootstrap = False ,
4243 ** kwargs ):
4344 extra_params = {
4445 "icount" : str (icount ),
@@ -48,6 +49,8 @@ def qemu_params(
4849 "globals" : json .encode (globals ),
4950 # The same goes for this array of strings:
5051 "traces" : json .encode (traces ),
52+ # And these Booleans:
53+ "bootstrap" : json .encode (bootstrap ),
5154 }
5255
5356 return struct (
@@ -394,27 +397,35 @@ def _test_dispatch(ctx, exec_env, firmware):
394397 "otp" : otp_image .short_path ,
395398 }
396399
397- # Generate the flash backend image for QEMU emulation
398- # TODO: when bootstrapping is available, this should always create a blank
399- # flash image and bootstrap the data. Ideally, relevant info pages would
400- # be spliced in at this step, but that is not yet supported by either
401- # flashgen or by Bazel.
402- flash_image = gen_flash (
403- ctx ,
404- flashgen = exec_env .flashgen ,
405- firmware_bin = image ,
406- # TODO: no support for convenience debug symbols from ELFs for now
407- firmware_elf = None ,
408- # Do not sanity check ELFs, because we do not expect the binary to
409- # match the ELF because of the added manifest extensions (e.g. SPX
410- # signatures) present in the signed binary.
411- check_elfs = False ,
412- )
413- data_files += [flash_image ]
414- qemu_args += ["-drive" , "if=mtd,id=eflash,bus=2,file=flash_img.bin,format=raw" ]
415- test_script_fmt |= {
416- "flash" : flash_image .short_path ,
417- }
400+ # If real bootstrapping is requested then prepare the correct command, otherwise we need
401+ # to prepare a QEMU drive containing flash contents.
402+ # Ideally, relevant info pages would be spliced in at this step, but that is
403+ # not yet supported by either flashgen or by Bazel.
404+ if param ["bootstrap" ] and json .decode (param ["bootstrap" ]):
405+ if ctx .attr .test_harness :
406+ fail ("cannot specify both `bootstrap = True` and a test harness (harnesses bootstrap manually)" )
407+ test_script_fmt |= {"flash" : "" }
408+ bootstrap_cmd = "bootstrap --clear-uart=true {firmware}" .format (** param )
409+ param ["bootstrap_cmd" ] = '--exec="{}"' .format (bootstrap_cmd )
410+ else :
411+ # Generate the flash backend image for QEMU emulation
412+ flash_image = gen_flash (
413+ ctx ,
414+ flashgen = exec_env .flashgen ,
415+ firmware_bin = image ,
416+ # TODO: no support for convenience debug symbols from ELFs for now
417+ firmware_elf = None ,
418+ # Do not sanity check ELFs, because we do not expect the binary to
419+ # match the ELF because of the added manifest extensions (e.g. SPX
420+ # signatures) present in the signed binary.
421+ check_elfs = False ,
422+ )
423+ data_files += [flash_image ]
424+ qemu_args += ["-drive" , "if=mtd,id=eflash,bus=2,file=flash_img.bin,format=raw" ]
425+ test_script_fmt |= {
426+ "flash" : flash_image .short_path ,
427+ }
428+ param ["bootstrap_cmd" ] = '--exec="no-op" # SKIPPING BOOTSTRAP'
418429
419430 # Get the pre-test_cmd args.
420431 args = get_fallback (ctx , "attr.args" , exec_env )
0 commit comments