1# SPDX-License-Identifier: GPL-2.0+
2# Copyright 2022 Google LLC
3#
4# Test addition of VBE
5
6import os
7
8import pytest
9import utils
10
11@pytest.mark.boardspec('sandbox_vpl')
12@pytest.mark.requiredtool('dtc')
13def test_vbe_vpl(ubman):
14    #cmd = [ubman.config.build_dir + fname, '-v']
15    ram = os.path.join(ubman.config.build_dir, 'ram.bin')
16    fdt = os.path.join(ubman.config.build_dir, 'arch/sandbox/dts/test.dtb')
17    image_fname = os.path.join(ubman.config.build_dir, 'image.bin')
18
19    # Enable firmware1 and the mmc that it uses. These are needed for the full
20    # VBE flow.
21    utils.run_and_log(
22        ubman, f'fdtput -t s {fdt} /bootstd/firmware0 status disabled')
23    utils.run_and_log(
24        ubman, f'fdtput -t s {fdt} /bootstd/firmware1 status okay')
25    utils.run_and_log(
26        ubman, f'fdtput -t s {fdt} /mmc3 status okay')
27    utils.run_and_log(
28        ubman, f'fdtput -t s {fdt} /mmc3 filename {image_fname}')
29
30    # Remove any existing RAM file, so we don't have old data present
31    if os.path.exists(ram):
32        os.remove(ram)
33    flags = ['-p', image_fname, '-w', '-s', 'state.dtb']
34    ubman.restart_uboot_with_flags(flags)
35
36    # Make sure that VBE was used in both VPL (to load SPL) and SPL (to load
37    # U-Boot
38    output = ubman.run_command('vbe state')
39    assert output == 'Phases: VPL SPL'
40