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