Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 2 | # Copyright (c) 2015 Stephen Warren |
| 3 | # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 4 | |
| 5 | import pytest |
Simon Glass | fb91637 | 2025-02-09 09:07:15 -0700 | [diff] [blame] | 6 | import utils |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 7 | |
| 8 | @pytest.mark.buildconfigspec('cmd_memory') |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 9 | def test_md(ubman): |
Stephen Warren | 75e731e | 2016-01-26 13:41:30 -0700 | [diff] [blame] | 10 | """Test that md reads memory as expected, and that memory can be modified |
| 11 | using the mw command.""" |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 12 | |
Simon Glass | fb91637 | 2025-02-09 09:07:15 -0700 | [diff] [blame] | 13 | ram_base = utils.find_ram_base(ubman) |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 14 | addr = '%08x' % ram_base |
| 15 | val = 'a5f09876' |
| 16 | expected_response = addr + ': ' + val |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 17 | ubman.run_command('mw ' + addr + ' 0 10') |
| 18 | response = ubman.run_command('md ' + addr + ' 10') |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 19 | assert(not (expected_response in response)) |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 20 | ubman.run_command('mw ' + addr + ' ' + val) |
| 21 | response = ubman.run_command('md ' + addr + ' 10') |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 22 | assert(expected_response in response) |
| 23 | |
| 24 | @pytest.mark.buildconfigspec('cmd_memory') |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 25 | def test_md_repeat(ubman): |
Stephen Warren | 75e731e | 2016-01-26 13:41:30 -0700 | [diff] [blame] | 26 | """Test command repeat (via executing an empty command) operates correctly |
| 27 | for "md"; the command must repeat and dump an incrementing address.""" |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 28 | |
Simon Glass | fb91637 | 2025-02-09 09:07:15 -0700 | [diff] [blame] | 29 | ram_base = utils.find_ram_base(ubman) |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 30 | addr_base = '%08x' % ram_base |
| 31 | words = 0x10 |
| 32 | addr_repeat = '%08x' % (ram_base + (words * 4)) |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 33 | ubman.run_command('md %s %x' % (addr_base, words)) |
| 34 | response = ubman.run_command('') |
Stephen Warren | 819f23b | 2016-01-15 11:15:27 -0700 | [diff] [blame] | 35 | expected_response = addr_repeat + ': ' |
| 36 | assert(expected_response in response) |