Skip to content

Commit

Permalink
Merge remote-tracking branch 'rvtest/master' into noop
Browse files Browse the repository at this point in the history
  • Loading branch information
Squareless-XD committed Oct 30, 2024
2 parents e6399f8 + 51de008 commit 147c369
Show file tree
Hide file tree
Showing 121 changed files with 5,772 additions and 244 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
on: pull_request
on:
pull_request:
paths:
- 'debug/**'

name: Check Code Style (checkpatch)
name: Check Debug Code Style (pylint)

jobs:
check:
Expand Down
172 changes: 172 additions & 0 deletions .github/workflows/spike-openocd-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Build Spike and run a couple of debug tests.

name: Test OpenOCD against 2 spike configurations

env:
SPIKE_REPO: https://github.com/riscv-software-src/riscv-isa-sim.git
SPIKE_REV: master
RISCV_TESTS_REPO: https://github.com/riscv-software-src/riscv-tests.git
RISCV_TESTS_REV: master
OPENOCD_REPO: https://github.com/riscv/riscv-openocd.git
OPENOCD_REV: riscv
TOOLCHAIN_URL: https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v12.2.0-1/xpack-riscv-none-elf-gcc-12.2.0-1-linux-x64.tar.gz

on:
# Run on merges to master to populate the cache with entities that are
# accessible by every pull request.
push:
branches:
- riscv
paths:
- 'debug/**'
- '.github/workflows/spike-openocd-tests.yml'
pull_request:
types: [synchronize, opened, reopened]
paths:
- 'debug/**'
- '.github/workflows/spike-openocd-tests.yml'

# There is some commented out code below that would be useful in adding this
# workflow to other repos. Ideally we can come up with something that would
# leave this file almost identical between repos, so they can all easily run
# this test suite.

jobs:
test:
name: Test debug (Ubuntu)
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y device-tree-compiler build-essential
- name: Get revisions of dependencies
run: |
SPIKE_COMMIT=$( git ls-remote "$SPIKE_REPO" $SPIKE_REV | awk '{ print $1; }' )
OPENOCD_COMMIT=$( git ls-remote "$OPENOCD_REPO" $OPENOCD_REV | awk '{ print $1; }' )
echo "Revison of Spike: $SPIKE_COMMIT"
echo "Revision of OpenOCD: $OPENOCD_COMMIT"
# Save for later use
echo "SPIKE_COMMIT=$SPIKE_COMMIT" >> $GITHUB_ENV
echo "OPENOCD_COMMIT=$OPENOCD_COMMIT" >> $GITHUB_ENV
- name: Get the toolchain from cache (if available)
id: cache-restore-toolchain
uses: actions/cache/restore@v3
with:
path: /opt/riscv/toolchain
key: "toolchain-${{env.TOOLCHAIN_URL}}"

- if: ${{ steps.cache-restore-toolchain.outputs.cache-hit != 'true' }}
name: Download Toolchain (if not cached)
run: |
mkdir -p /opt/riscv/toolchain
wget --progress=dot:giga $TOOLCHAIN_URL -O /tmp/toolchain.tar.gz
- if: ${{ steps.cache-restore-toolchain.outputs.cache-hit != 'true' }}
name: Install Toolchain (if not cached)
run: tar zxf /tmp/toolchain.tar.gz --strip-components=1 -C /opt/riscv/toolchain

- name: Save the toolchain to the cache (if necessary)
id: cache-save-toolchain
uses: actions/cache/save@v3
with:
path: /opt/riscv/toolchain
key: "toolchain-${{env.TOOLCHAIN_URL}}"

- name: Get OpenOCD from cache (if available)
id: cache-restore-openocd
uses: actions/cache/restore@v3
with:
path: /opt/riscv/openocd
key: "openocd-${{env.OPENOCD_COMMIT}}"

- if: ${{ steps.cache-restore-openocd.outputs.cache-hit != 'true' }}
name: Download OpenOCD source (if not cached)
run: |
git clone "$OPENOCD_REPO"
cd riscv-openocd
git checkout "$OPENOCD_COMMIT"
git submodule update --init --recursive
- if: ${{ steps.cache-restore-openocd.outputs.cache-hit != 'true' }}
name: Build OpenOCD (if not cached)
run: |
cd riscv-openocd
./bootstrap
./configure --prefix=/opt/riscv/openocd
make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
make install
- if: ${{ steps.cache-restore-openocd.outputs.cache-hit != 'true' }}
name: Save OpenOCD to cache (if built)
id: cache-save-openocd
uses: actions/cache/save@v3
with:
path: /opt/riscv/openocd
key: "openocd-${{env.OPENOCD_COMMIT}}"

- name: Get spike from cache (if available)
id: cache-restore-spike
uses: actions/cache/restore@v3
with:
path: /opt/riscv/spike
key: "spike-${{env.SPIKE_COMMIT}}"

- if: ${{ steps.cache-restore-spike.outputs.cache-hit != 'true' }}
name: Download Spike source (if not cached)
run: |
git clone "$SPIKE_REPO"
cd riscv-isa-sim
git checkout "$SPIKE_COMMIT"
git submodule update --init --recursive
- if: ${{ steps.cache-restore-spike.outputs.cache-hit != 'true' }}
name: Build Spike (if not cached)
run: |
cd riscv-isa-sim
mkdir build && cd build
../configure --prefix=/opt/riscv/spike
make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
make install
- if: ${{ steps.cache-restore-spike.outputs.cache-hit != 'true' }}
name: Save spike to cache (if built)
id: cache-save-spike
uses: actions/cache/save@v3
with:
path: /opt/riscv/spike
key: "spike-${{env.SPIKE_COMMIT}}"

- name: Run Spike32 Tests
id: spike32-tests
run: |
cd debug
./gdbserver.py targets/RISC-V/spike32.py --print-failures \
--gcc /opt/riscv/toolchain/bin/riscv-none-elf-gcc \
--gdb /opt/riscv/toolchain/bin/riscv-none-elf-gdb \
--sim_cmd /opt/riscv/spike/bin/spike \
--server_cmd /opt/riscv/openocd/bin/openocd
- name: Run Spike64-2 Tests
if: success() || steps.spike32-tests.conclusion == 'failure'
run: |
cd debug
./gdbserver.py targets/RISC-V/spike64-2.py --print-failures \
--gcc /opt/riscv/toolchain/bin/riscv-none-elf-gcc \
--gdb /opt/riscv/toolchain/bin/riscv-none-elf-gdb \
--sim_cmd /opt/riscv/spike/bin/spike \
--server_cmd /opt/riscv/openocd/bin/openocd
- name: Archive test logs
# Proceed even if there was a failed test
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
with:
name: test-logs
path: riscv-tests/debug/logs
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Building from repository
-----------------------------

We assume that the RISCV environment variable is set to the RISC-V tools
install path, and that the riscv-gnu-toolchain package is installed.
install path, and that the [riscv-gnu-toolchain](
https://github.com/riscv-collab/riscv-gnu-toolchain) package is installed.

$ git clone https://github.com/riscv/riscv-tests
$ cd riscv-tests
Expand Down
9 changes: 8 additions & 1 deletion benchmarks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

XLEN ?= 64

ifeq ($(XLEN),32)
ABI ?= ilp32d
endif
ifeq ($(XLEN),64)
ABI ?= lp64d
endif

default: all

src_dir = .
Expand Down Expand Up @@ -45,7 +52,7 @@ bmarks = \

RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf -fno-tree-loop-distribute-patterns -march=rv$(XLEN)gcv -mabi=lp64d
RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf -fno-tree-loop-distribute-patterns -march=rv$(XLEN)gcv -mabi=$(ABI)
RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs)
RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lm -lgcc -T $(src_dir)/common/test.ld
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/rsort/rsort.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// See LICENSE for license details.

//**************************************************************************
// Quicksort benchmark
// Radix Sort benchmark
//--------------------------------------------------------------------------
//
// This benchmark uses quicksort to sort an array of integers. The
// This benchmark uses radix sort to sort an array of integers. The
// implementation is largely adapted from Numerical Recipes for C. The
// input data (and reference data) should be generated using the
// qsort_gendata.pl perl script and dumped to a file named
Expand Down
1 change: 1 addition & 0 deletions debug/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The following should be in the user's path:
* openocd (can be overridden with `--server_cmd` when running gdbserver.py
manually), which should be the latest from
https://github.com/riscv/riscv-openocd.git.
* Python packages that might not be installed: pexpect

Usage
=====
Expand Down
Loading

0 comments on commit 147c369

Please sign in to comment.