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