blob: 612234960542e335871a2a93edc0e6a8545d8bc8 [file] [log] [blame]
Kory Maincent965a34f2021-05-04 19:31:23 +02001# SPDX-License-Identifier: GPL-2.0+
2# Copyright (c) 2020
3# Author: Kory Maincent <kory.maincent@bootlin.com>
4
5# Test U-Boot's "extension" commands.
6
7import os
8import pytest
Simon Glassfb916372025-02-09 09:07:15 -07009import utils
Kory Maincent965a34f2021-05-04 19:31:23 +020010
11overlay_addr = 0x1000
12
13SANDBOX_DTB='arch/sandbox/dts/sandbox.dtb'
14OVERLAY_DIR='arch/sandbox/dts/'
15
Simon Glassddba5202025-02-09 09:07:14 -070016def load_dtb(ubman):
17 ubman.log.action('Loading devicetree to RAM...')
18 ubman.run_command('host load hostfs - $fdt_addr_r %s' % (os.path.join(ubman.config.build_dir, SANDBOX_DTB)))
19 ubman.run_command('fdt addr $fdt_addr_r')
Kory Maincent965a34f2021-05-04 19:31:23 +020020
21@pytest.mark.buildconfigspec('cmd_fdt')
22@pytest.mark.boardspec('sandbox')
Simon Glassddba5202025-02-09 09:07:14 -070023def test_extension(ubman):
Kory Maincent965a34f2021-05-04 19:31:23 +020024 """Test the 'extension' command."""
25
Simon Glassddba5202025-02-09 09:07:14 -070026 load_dtb(ubman)
Kory Maincent965a34f2021-05-04 19:31:23 +020027
Simon Glassddba5202025-02-09 09:07:14 -070028 output = ubman.run_command('extension list')
Heinrich Schuchardt8ee1fa22024-11-27 08:06:26 +010029 # extension_bootdev_hunt may have already run.
30 # Without reboot we cannot make any assumption here.
31 # assert('No extension' in output)
Kory Maincent965a34f2021-05-04 19:31:23 +020032
Simon Glassddba5202025-02-09 09:07:14 -070033 output = ubman.run_command('extension scan')
Kory Maincent965a34f2021-05-04 19:31:23 +020034 assert output == 'Found 2 extension board(s).'
35
Simon Glassddba5202025-02-09 09:07:14 -070036 output = ubman.run_command('extension list')
Kory Maincent965a34f2021-05-04 19:31:23 +020037 assert('overlay0.dtbo' in output)
38 assert('overlay1.dtbo' in output)
39
Simon Glassddba5202025-02-09 09:07:14 -070040 ubman.run_command_list([
Kory Maincent965a34f2021-05-04 19:31:23 +020041 'setenv extension_overlay_addr %s' % (overlay_addr),
Simon Glassddba5202025-02-09 09:07:14 -070042 'setenv extension_overlay_cmd \'host load hostfs - ${extension_overlay_addr} %s${extension_overlay_name}\'' % (os.path.join(ubman.config.build_dir, OVERLAY_DIR))])
Kory Maincent965a34f2021-05-04 19:31:23 +020043
Simon Glassddba5202025-02-09 09:07:14 -070044 output = ubman.run_command('extension apply 0')
Kory Maincent965a34f2021-05-04 19:31:23 +020045 assert('bytes read' in output)
46
Simon Glassddba5202025-02-09 09:07:14 -070047 output = ubman.run_command('fdt print')
Kory Maincent965a34f2021-05-04 19:31:23 +020048 assert('button3' in output)
49
Simon Glassddba5202025-02-09 09:07:14 -070050 output = ubman.run_command('extension apply all')
Kory Maincent965a34f2021-05-04 19:31:23 +020051 assert('bytes read' in output)
52
Simon Glassddba5202025-02-09 09:07:14 -070053 output = ubman.run_command('fdt print')
Kory Maincent965a34f2021-05-04 19:31:23 +020054 assert('button4' in output)
55