Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize scripts #4

Merged
merged 7 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ on:
env:
CI: 1
CARGO_TERM_COLOR: always
RENODE_PATH: /opt/renode/
RENODE_DIR: /opt/renode/
# Used by renode-test to generate snapshots of failed tests
RENODE_CI_MODE: YES
DLA_BIN: dla

jobs:
build-dla-example:
Expand All @@ -28,7 +29,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dla-debug
name: $DLA_BIN
path: ./examples/hpc/hello-dla/target/riscv64imac-unknown-none-elf/debug/examples/dla
if-no-files-found: error
retention-days: 14
Expand All @@ -41,19 +42,16 @@ jobs:
image: antmicro/renode:1.14.0
options: --user root

env:
BIN: dla

steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: dla-debug
name: $DLA_BIN
- name: Create Renode peripheral symlinks
run: ln -s $(readlink -f "./vp/devel/python_peripherals/DLA.py") "$RENODE_PATH/scripts/pydev/DLA.py"
run: ln -s $(readlink -f "./vp/devel/python_peripherals/DLA.py") "$RENODE_DIR/scripts/pydev/DLA.py"
- name: Run example
run: renode-test scripts/robot/hello_dla.robot --variable BIN:"$(readlink -f $BIN)"
run: renode-test scripts/robot/hello_dla.robot --variable BIN:"$(readlink -f $DLA_BIN)"
- name: Upload snapshots
if: failure()
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion examples/hpc/hello-dla/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[target.riscv64imac-unknown-none-elf]
runner = "./renode.sh"
runner = "../../../scripts/run_on_hpc.sh"
rustflags = ["-C", "link-arg=-Tmem_hpc.x", "-C", "link-arg=-Tlink.x"]

[build]
Expand Down
18 changes: 0 additions & 18 deletions examples/hpc/hello-dla/renode.sh

This file was deleted.

2 changes: 1 addition & 1 deletion examples/hpc/hello-hpc/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[target.riscv64imac-unknown-none-elf]
runner = "./renode.sh"
runner = "../../../scripts/run_on_hpc.sh"
rustflags = ["-C", "link-arg=-Tmem_hpc.x", "-C", "link-arg=-Tlink.x"]

[build]
Expand Down
7 changes: 0 additions & 7 deletions examples/hpc/hello-hpc/renode.sh

This file was deleted.

2 changes: 1 addition & 1 deletion examples/sysctrl/hello-sysctrl/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
target = "riscv32imc-unknown-none-elf"

[target.riscv32imc-unknown-none-elf]
runner = "./renode.sh"
runner = "../../../scripts/run_on_sysctrl.sh"
rustflags = ["-C", "link-arg=-Tmem_sysctrl.x", "-C", "link-arg=-Tlink.x"]
7 changes: 0 additions & 7 deletions examples/sysctrl/hello-sysctrl/renode.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using sysbus

mach create "headsail"

machine LoadPlatformDescription $ORIGIN/../vp/devel/common.repl
machine LoadPlatformDescription $ORIGIN/../../vp/devel/common.repl

emulation CreateUartPtyTerminal "term0" "/tmp/uart0" True
emulation CreateUartPtyTerminal "term1" "/tmp/uart1" True
Expand Down
2 changes: 1 addition & 1 deletion scripts/1_hpc.resc → scripts/resc/1_hpc.resc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include $ORIGIN/0_mach_create.resc

machine LoadPlatformDescription $ORIGIN/../vp/devel/hpc.repl
machine LoadPlatformDescription $ORIGIN/../../vp/devel/hpc.repl

machine StartGdbServer 3335 true sysbus.cpu_hpc
2 changes: 1 addition & 1 deletion scripts/1_sysctrl.resc → scripts/resc/1_sysctrl.resc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include $ORIGIN/0_mach_create.resc

machine LoadPlatformDescription $ORIGIN/../vp/devel/sysctrl.repl
machine LoadPlatformDescription $ORIGIN/../../vp/devel/sysctrl.repl

machine StartGdbServer 3333 true sysbus.cpu_sysctrl
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/robot/hello_dla.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*** Variables ***
${SCRIPT} ${CURDIR}/../1_hpc.resc
${SCRIPT} ${CURDIR}/../resc/1_hpc.resc
${CPU} sysbus.cpu_hpc
${UART} sysbus.apb_uart_0
${BIN} ${CURDIR}/../../examples/hpc/hello-dla/target/riscv64imac-unknown-none-elf/debug/examples/dla
Expand Down
14 changes: 14 additions & 0 deletions scripts/run_on_hpc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# Runs compiled ELF from $BIN or param $1 on HPC

BASEDIR=$(dirname "$0")
$BASEDIR/setup_renode.sh

BIN=${BIN=$1}
if [ -z "$BIN" ]; then
echo "!! Pass in an ELF using \$BIN or \$1"
exit 1
fi

renode --console -e "set bin @$BIN; include @$BASEDIR/resc/2_run_hpc.resc"
14 changes: 14 additions & 0 deletions scripts/run_on_sysctrl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# Runs compiled ELF from $BIN or param $1 on SysCtrl

BASEDIR=$(dirname "$0")
$BASEDIR/setup_renode.sh

BIN=${BIN=$1}
if [ -z "$BIN" ]; then
echo "!! Pass in an ELF using \$BIN or \$1"
exit 1
fi

renode --console -e "set bin @$BIN; include @$BASEDIR/resc/2_run_sysctrl.resc"
28 changes: 28 additions & 0 deletions scripts/setup_renode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# # Parameters
#
# * `-y` - skip confirmation prompt (e.g., for CI)

# Detect renode location
RENODE="${RENODE:-$(which renode)}"
RENODE_DIR="$(dirname $(which renode))"

RENODE_PYTHON_PERIPHERALS="$RENODE_DIR/scripts/pydev"
REQUIRED_SYMLINK="$RENODE_PYTHON_PERIPHERALS/DLA.py"

BASEDIR=$(dirname "$0")
VP_PYTHON_PERIPHERALS="$BASEDIR/../vp/devel/python_peripherals"

# Check if symlink exists
if [ ! -h "$REQUIRED_SYMLINK" ]; then
echo "Symlink not found"
if [[ ! $* == *-y* ]]; then
read -p "Create symlinks and continue? (y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
fi
# Symlink the updated Python peripheral to Renode search directory
ln -s $(readlink -f "$VP_PYTHON_PERIPHERALS/DLA.py") "$REQUIRED_SYMLINK"
echo "Created Symlink at \"$REQUIRED_SYMLINK\""
else
echo "Symlink at \"$REQUIRED_SYMLINK\" detected. Nothing to be done."
fi
16 changes: 16 additions & 0 deletions scripts/tear_renode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Detect renode location
RENODE="${RENODE:-$(which renode)}"
RENODE_DIR="$(dirname $(which renode))"

RENODE_PYTHON_PERIPHERALS="$RENODE_DIR/scripts/pydev"
REQUIRED_SYMLINK="$RENODE_PYTHON_PERIPHERALS/DLA.py"

# Check if symlink exists
if [ -h "$REQUIRED_SYMLINK" ]; then
unlink $REQUIRED_SYMLINK
echo "Unlinked symlink at \"$REQUIRED_SYMLINK\""
else
echo "No symlink \"$REQUIRED_SYMLINK\" at Nothing to be done."
fi