diff --git a/.github/scripts/breakpoint.gdb b/.github/scripts/breakpoint.gdb deleted file mode 100644 index 0da002f6ed0..00000000000 --- a/.github/scripts/breakpoint.gdb +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -echo Connecting to OpenOCD...\n -set architecture riscv:rv32 -set remotetimeout 30 -target extended-remote :3333 - -echo Connected, waiting...\n -shell sleep 5s - -echo Setting Breakpoint 1...\n -hbreak *0x1c - -echo Continuing...\n -continue - -delete diff --git a/.github/scripts/breakpoint_golden.txt b/.github/scripts/breakpoint_golden.txt deleted file mode 100644 index eeb5ad39723..00000000000 --- a/.github/scripts/breakpoint_golden.txt +++ /dev/null @@ -1 +0,0 @@ -Breakpoint 1, 0x0000001c in ?? () diff --git a/.github/scripts/dump_and_compare.sh b/.github/scripts/dump_and_compare.sh index 354dedd67dd..378a298879c 100755 --- a/.github/scripts/dump_and_compare.sh +++ b/.github/scripts/dump_and_compare.sh @@ -16,13 +16,13 @@ set -ex # Invoke GDB and dump core registers -${GCC_PREFIX}-gdb -n --batch -x dump_registers.gdb >gdb.log +${GCC_PREFIX}-gdb -n --batch -x test.gdb >gdb.log # Parse the log, extract register values. Skip those which change as the # program executes since we don't know at which point we tap in. -cat gdb.log | grep -E '^ra |^sp |^gp |^tp |^t[01256] |^s[0-9]+ |^a[0-9]+ |^\$[0-9]+' >regdump.txt +cat gdb.log | grep -E '^ra |^sp |^gp |^tp |^t[01256] |^s[0-9]+ |^a[0-9]+ |^\$[0-9]+' >gdb_test_dump.txt # Compare the dumps # TODO this temporarily exits with success just to allow collecting coverage data # without considering the truthness of register values. -diff -E -y regdump_golden.txt regdump.txt || true +diff -E -y gdb_test_golden.txt gdb_test_dump.txt || true diff --git a/.github/scripts/dump_registers.gdb b/.github/scripts/dump_registers.gdb deleted file mode 100644 index 6e491afd504..00000000000 --- a/.github/scripts/dump_registers.gdb +++ /dev/null @@ -1,24 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -echo Connecting to OpenOCD...\n -set architecture riscv:rv32 -set remotetimeout 30 -target extended-remote :3333 - -echo Connected, waiting...\n -shell sleep 30s - -echo Dumping registers...\n -info registers diff --git a/.github/scripts/regdump_golden.txt b/.github/scripts/gdb_test_golden.txt similarity index 74% rename from .github/scripts/regdump_golden.txt rename to .github/scripts/gdb_test_golden.txt index b1913bb9d73..22a59a4a501 100644 --- a/.github/scripts/regdump_golden.txt +++ b/.github/scripts/gdb_test_golden.txt @@ -26,3 +26,7 @@ s10 0x0 0 s11 0x0 0 t5 0x0 0 t6 0x0 0 +$1 = {0xcafebaba, 0xdeadbeef, 0xfeedbaca, 0xa5a5a5a5} +$2 = {0x1234567, 0x89abcdef, 0x55555555, 0xaaaaaaaa} +$3 = {0xaaaab0b7, 0xaaa08093, 0x7c009073, 0x90734191, 0x50b77f91, 0x80931234, 0xf1376780, 0x7111abcd} +Breakpoint 1, 0x0000001c in ?? () diff --git a/.github/scripts/mem_access.sh b/.github/scripts/mem_access.sh deleted file mode 100755 index bc4cabdc193..00000000000 --- a/.github/scripts/mem_access.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -set -ex - -# Invoke GDB -${GCC_PREFIX}-gdb -n --batch -x mem_access.gdb >gdb.log -# Parse the log -cat gdb.log | grep -E '^\$[0-9]+' >out.txt - -# Compare the dumps -# TODO this temporarily exits with success just to allow collecting coverage data -# without considering the truthness of reported values. -diff -E -y mem_access_golden.txt out.txt || true - diff --git a/.github/scripts/mem_access_golden.txt b/.github/scripts/mem_access_golden.txt deleted file mode 100644 index 1f6b009253f..00000000000 --- a/.github/scripts/mem_access_golden.txt +++ /dev/null @@ -1,3 +0,0 @@ -$1 = {0xcafebaba, 0xdeadbeef, 0xfeedbaca, 0xa5a5a5a5} -$2 = {0x1234567, 0x89abcdef, 0x55555555, 0xaaaaaaaa} -$3 = {0xaaaab0b7, 0xaaa08093, 0x7c009073, 0x90734191, 0x50b77f91, 0x80931234, 0xf1376780, 0x7111abcd} diff --git a/.github/scripts/peripheral_access.gdb b/.github/scripts/peripheral_access.gdb deleted file mode 100644 index 473466eebd7..00000000000 --- a/.github/scripts/peripheral_access.gdb +++ /dev/null @@ -1,44 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -echo Connecting to OpenOCD...\n -set architecture riscv:rv32 -set remotetimeout 30 -target extended-remote :3333 - -echo Connected, waiting...\n -shell sleep 5s - -echo Accessing ECC...\n -print/x *0x10008000@2 -print/x *0x10008008@2 - -echo Accessing HMAC...\n -print/x *0x10010000@2 -print/x *0x10010008@2 - -echo Accessing SHA512...\n -print/x *0x10020000@2 -print/x *0x10020008@2 - -echo Accessing SHA256...\n -print/x *0x10028000@2 -print/x *0x10028008@2 - -echo Writing and reading DOE IV...\n -set *(0x10000000) = 0xCAFEBABA -set *(0x10000004) = 0xDEADBEEF -set *(0x10000008) = 0xD0ED0E00 -print/x *0x10000000@3 - diff --git a/.github/scripts/peripheral_access.sh b/.github/scripts/peripheral_access.sh deleted file mode 100755 index 2db9a2f2bb8..00000000000 --- a/.github/scripts/peripheral_access.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -set -ex - -# Invoke GDB -${GCC_PREFIX}-gdb -n --batch -x peripheral_access.gdb >gdb.log -# Parse the log -cat gdb.log | grep -E '^\$[0-9]+' >peripheral_access.txt - -# Compare the dumps -diff -E -y peripheral_access_golden.txt peripheral_access.txt || true - diff --git a/.github/scripts/peripheral_access_golden.txt b/.github/scripts/peripheral_access_golden.txt deleted file mode 100644 index 292097533fc..00000000000 --- a/.github/scripts/peripheral_access_golden.txt +++ /dev/null @@ -1,9 +0,0 @@ -$1 = {0x63707365, 0x38342d33} -$2 = {0x3030312e, 0x0} -$3 = {0x6163686d, 0x61327368} -$4 = {0x3030322e, 0x0} -$5 = {0x61327368, 0x31322d35} -$6 = {0x3830302e, 0x0} -$7 = {0x61327368, 0x35362d32} -$8 = {0x3830312e, 0x0} -$9 = {0xcafebaba, 0xdeadbeef, 0xd0ed0e00} diff --git a/.github/scripts/mem_access.gdb b/.github/scripts/test.gdb similarity index 93% rename from .github/scripts/mem_access.gdb rename to .github/scripts/test.gdb index ad57ad63271..005e98b5457 100644 --- a/.github/scripts/mem_access.gdb +++ b/.github/scripts/test.gdb @@ -18,8 +18,10 @@ set remotetimeout 30 target extended-remote :3333 echo Connected, waiting...\n -shell sleep 5s +shell sleep 30s +echo Dumping registers...\n +info registers echo Accessing DCCM...\n set *(0x00080000) = 0x01234567 set *(0x00080004) = 0x89ABCDEF @@ -119,13 +121,21 @@ set *(0xd0000008) = 0x55555555 set *(0xd000000C) = 0xAAAAAAAA print/x *0xd0000000@4 +echo Setting Breakpoint 1...\n +hbreak *0x1c + +echo Continuing...\n +continue + +delete + +# This causes an error. Let's execute it anyway for coverage. echo Accessing region at 0xe0000000...\n set *(0xe0000000) = 0x01234567 set *(0xe0000004) = 0x89ABCDEF set *(0xe0000008) = 0x55555555 set *(0xe000000C) = 0xAAAAAAAA print/x *0xe0000000@4 - echo Accessing region at 0xf0000000...\n set *(0xf0000000) = 0x01234567 set *(0xf0000004) = 0x89ABCDEF @@ -133,3 +143,5 @@ set *(0xf0000008) = 0x55555555 set *(0xf000000C) = 0xAAAAAAAA print/x *0xf0000000@4 +# end the simulation gracefully +set *(volatile unsigned char*)0xd0580000 = 0xff diff --git a/.github/workflows/test-openocd.yml b/.github/workflows/test-openocd.yml index c18cd5e98b2..a5b3bf95572 100644 --- a/.github/workflows/test-openocd.yml +++ b/.github/workflows/test-openocd.yml @@ -69,82 +69,31 @@ jobs: -f ${RV_ROOT}/testbench/openocd_scripts/jtag_cg.tcl pkill openocd || true - - name: Test with GDB-test (register access) + - name: Test with GDB-test (register access, memory access, breakpoints) run: | # TODO GDB is in /opt/riscv and a separate toolchain is installed with apt. Make this better. export PATH=/opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin:$PATH export RV_ROOT=$(pwd) - mkdir reg_test - make -C reg_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \ + mkdir gdb_test + make -C gdb_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \ CONF_PARAMS="-set build_${{ matrix.bus }} -set openocd_test" COVERAGE=${{ matrix.coverage }} - cd reg_test + cd gdb_test ${RV_ROOT}/.github/scripts/gdb_test.sh \ /bin/bash -c 'cd ${RV_ROOT}/.github/scripts && ./dump_and_compare.sh' || true pkill openocd || true - - name: Test with GDB-test (memory access) - run: | - # TODO GDB is in /opt/riscv and a separate toolchain is installed with apt. Make this better. - export PATH=/opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin:$PATH - export RV_ROOT=$(pwd) - mkdir mem_test - make -C mem_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \ - CONF_PARAMS="-set build_${{ matrix.bus }} -set openocd_test" COVERAGE=${{ matrix.coverage }} - cd mem_test - ${RV_ROOT}/.github/scripts/gdb_test.sh \ - /bin/bash -c 'cd ${RV_ROOT}/.github/scripts && ./mem_access.sh' || true - pkill openocd || true - - - name: Test with GDB-test (peripheral access) - run: | - # TODO REMOVE THIS TEST, as we aim to target all possible memory regions in the test above this, - # and there are no actual peripherals in the tesbench. - - # TODO GDB is in /opt/riscv and a separate toolchain is installed with apt. Make this better. - export PATH=/opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin:$PATH - export RV_ROOT=$(pwd) - mkdir periph_test - make -C periph_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \ - CONF_PARAMS="-set build_${{ matrix.bus }} -set openocd_test" COVERAGE=${{ matrix.coverage }} - cd periph_test - ${RV_ROOT}/.github/scripts/gdb_test.sh \ - /bin/bash -c 'cd ${RV_ROOT}/.github/scripts && ./peripheral_access.sh' || true - pkill openocd || true - - - name: Test with GDB-test (breakpoints) - run: | - # TODO GDB is in /opt/riscv and a separate toolchain is installed with apt. Make this better. - export PATH=/opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin:$PATH - export RV_ROOT=$(pwd) - mkdir breakpoint_test - make -C breakpoint_test -f ${RV_ROOT}/tools/Makefile verilator-build program.hex TEST=infinite_loop \ - CONF_PARAMS="-set build_${{ matrix.bus }} -set openocd_test" COVERAGE=${{ matrix.coverage }} - cd breakpoint_test - ${RV_ROOT}/.github/scripts/gdb_test.sh \ - /bin/bash -c 'cd ${RV_ROOT}/.github/scripts && ./breakpoint.sh' || true - pkill openocd || true - - name: Prepare coverage data shell: bash run: | export PATH=/opt/verilator/bin:$PATH export RV_ROOT=$(pwd) sis -d convert --dat-dir ${RV_ROOT}/run - sis -d convert --dat-dir ${RV_ROOT}/reg_test - sis -d convert --dat-dir ${RV_ROOT}/mem_test - sis -d convert --dat-dir ${RV_ROOT}/periph_test - sis -d convert --dat-dir ${RV_ROOT}/breakpoint_test + sis -d convert --dat-dir ${RV_ROOT}/gdb_test mkdir -p results mv ${RV_ROOT}/run/coverage.info \ results/coverage_openocd_${{ matrix.bus }}_${{ matrix.coverage }}.info - mv ${RV_ROOT}/reg_test/coverage.info \ - results/coverage_openocd_reg_test_${{ matrix.bus }}_${{ matrix.coverage }}.info - mv ${RV_ROOT}/mem_test/coverage.info \ - results/coverage_openocd__mem_test_${{ matrix.bus }}_${{ matrix.coverage }}.info - mv ${RV_ROOT}/periph_test/coverage.info \ - results/coverage_openocd_periph_test_${{ matrix.bus }}_${{ matrix.coverage }}.info - mv ${RV_ROOT}/breakpoint_test/coverage.info \ - results/coverage_openocd_breakpoint_test_${{ matrix.bus }}_${{ matrix.coverage }}.info + mv ${RV_ROOT}/gdb_test/coverage.info \ + results/coverage_openocd_gdb_test_${{ matrix.bus }}_${{ matrix.coverage }}.info - name: Pack artifacts if: always()