Skip to content

Commit

Permalink
Reorganize repls into hpc & sysctrl trees and add Robot based CI test…
Browse files Browse the repository at this point in the history
…ing (#6)

* Reorganize repls into hpc & sysctrl trees
* Add Renode Robot testcase for DLA
* Run Robot in CI
* Upload snapshots of failing tests
* renode.sh: fix script path
  • Loading branch information
hegza authored Mar 18, 2024
1 parent a5d4db2 commit fe2f86a
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 66 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ env:
CI: 1
CARGO_TERM_COLOR: always
RENODE_PATH: /opt/renode/
# Used by renode-test to generate snapshots of failed tests
RENODE_CI_MODE: YES

jobs:
build-dla-example:
Expand Down Expand Up @@ -43,12 +45,17 @@ jobs:
BIN: dla

steps:
- uses: actions/checkout@v3.0.2
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: dla-debug
- name: Create Renode peripheral symlinks
run: ln -s $(readlink -f "./vp/devel/python_peripherals/DLA.py") "$RENODE_PATH/scripts/pydev/DLA.py"
- name: Run example
run: renode --console -e "set bin @$BIN; include @$BASEDIR/scripts/start_hpc.resc"
run: renode-test scripts/robot/hello_dla.robot --variable BIN:"$(readlink -f $BIN)"
- name: Upload snapshots
if: failure()
uses: actions/upload-artifact@v4
with:
path: snapshots/
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Generated by Robot Test Framework
log.html
report.html
logs/
*.xml
snapshots/
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ Set renode installation path to RENODE_PATH variable in renode.sh
```sh
cargo run --example dla
```

### Run Robot Tests

```sh
renode-test scripts/robot/hello_dla.robot
```
4 changes: 2 additions & 2 deletions examples/hello-dla/examples/dla.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#![no_std]
#![no_main]

use hello_hpc::{uart_write, dla_write, dla_read};
use hello_hpc::{dla_read, dla_write, uart_write};
use panic_halt as _;
use riscv_rt::entry;

#[entry]
fn main() -> ! {
uart_write("Hello world!");
uart_write("Hello world!\r\n");
dla_write("Hello DLA");
let mut buf: [u8; 9] = [0; 9];
dla_read(&mut buf, 9, 0);
Expand Down
7 changes: 2 additions & 5 deletions examples/hello-dla/renode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ VP_PYTHON_PERIPHERALS="$BASEDIR/../../vp/devel/python_peripherals"
if [ ! -h "$RENODE_PYTHON_PERIPHERALS/DLA.py" ]; then
echo "Symlinks not found"
read -p "Create symlinks and continue? (y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
# Symlink the updated Python peripheral to Renode search directory
ln -s $(readlink -f "$VP_PYTHON_PERIPHERALS/DLA.py") "$RENODE_PYTHON_PERIPHERALS/DLA.py"
fi

# Update python peripheral to renode directory



renode --console -e "set bin @$BIN; include @$BASEDIR/../../scripts/start_hpc.resc"
renode --console -e "set bin @$BIN; include @$BASEDIR/../../scripts/2_run_hpc.resc"
2 changes: 1 addition & 1 deletion examples/hello-hpc/renode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -x # echo on
BASEDIR=$(dirname "$0")
BIN=${BIN=$1}

renode --console -e "set bin @$BIN; include @$BASEDIR/../../scripts/start_hpc.resc"
renode --console -e "set bin @$BIN; include @$BASEDIR/../../scripts/2_run_hpc.resc"
13 changes: 13 additions & 0 deletions scripts/0_mach_create.resc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using sysbus

mach create "headsail"

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

emulation CreateUartPtyTerminal "term0" "/tmp/uart0" True
emulation CreateUartPtyTerminal "term1" "/tmp/uart1" True
connector Connect sysbus.apb_uart_0 term0
connector Connect sysbus.apb_uart_1 term1

:showAnalyzer sysbus.apb_uart_0
:showAnalyzer sysbus.apb_uart_1
5 changes: 5 additions & 0 deletions scripts/1_hpc.resc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include $ORIGIN/0_mach_create.resc

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

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

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

machine StartGdbServer 3333 true sysbus.cpu_sysctrl
9 changes: 9 additions & 0 deletions scripts/2_run_hpc.resc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include $ORIGIN/1_hpc.resc

macro reset
"""
sysbus LoadELF $bin false true sysbus.cpu_hpc
"""

runMacro $reset;
start;
9 changes: 9 additions & 0 deletions scripts/2_run_sysctrl.resc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include $ORIGIN/1_sysctrl.resc

macro reset
"""
sysbus LoadELF $bin false true sysbus.cpu_sysctrl
"""

runMacro $reset;
start;
26 changes: 26 additions & 0 deletions scripts/robot/hello_dla.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
*** Variables ***
${SCRIPT} ${CURDIR}/../1_hpc.resc
${CPU} sysbus.cpu_hpc
${UART} sysbus.apb_uart_0
${BIN} ${CURDIR}/../../examples/hello-dla/target/riscv64imac-unknown-none-elf/debug/examples/dla

*** Settings ***
Suite Setup Setup
Suite Teardown Teardown
Test Teardown Test Teardown
Resource ${RENODEKEYWORDS}

*** Keywords ***
Create Machine
Execute Script ${SCRIPT}

*** Test Cases ***
Hello DLA works
Create Machine
Create Terminal Tester ${UART}

Execute Command set bin @${BIN}
Execute Command sysbus LoadELF $bin false true ${CPU}
Start Emulation

Wait For Line On Uart Hello world!
10 changes: 10 additions & 0 deletions scripts/robot/help.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*** Settings ***
Suite Setup Setup
Suite Teardown Teardown
Test Teardown Test Teardown
Resource ${RENODEKEYWORDS}

*** Test Cases ***
Should Print Help
${x}= Execute Command help
Should Contain ${x} Available commands:
24 changes: 0 additions & 24 deletions scripts/start_hpc.resc

This file was deleted.

21 changes: 21 additions & 0 deletions vp/devel/peripherals.repl → vp/devel/common.repl
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
mem_dsp_0: Memory.MappedMemory @ sysbus 0xFF810000
size: 0x10000

mem_dsp_1: Memory.MappedMemory @ sysbus 0xFF830000
size: 0x10000

hpc_bootram: Memory.MappedMemory @ sysbus 0x10000
size: 0x8000

ram_0: Memory.MappedMemory @ sysbus 0x90080000
size: 0x8000

ram_1: Memory.MappedMemory @ sysbus 0x90280000
size: 0x8000

ram_2: Memory.MappedMemory @ sysbus 0x90480000
size: 0x8000

ram_3: Memory.MappedMemory @ sysbus 0x90680000
size: 0x8000

apb_uart_0: UART.NS16550 @ sysbus 0xFFF00000
wideRegisters: true

Expand Down
9 changes: 0 additions & 9 deletions vp/devel/cpus.repl

This file was deleted.

7 changes: 7 additions & 0 deletions vp/devel/hpc.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cpu_hpc: CPU.RiscV64 @ sysbus
cpuType: "rv64imac"
hartId: 0
timeProvider: empty

sdram: Memory.MappedMemory @ sysbus 0x10000000
size: 0x70000000
23 changes: 0 additions & 23 deletions vp/devel/memory.repl

This file was deleted.

11 changes: 11 additions & 0 deletions vp/devel/sysctrl.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cpu_sysctrl: CPU.IbexRiscV32 @ sysbus
// CPU ISA is actually rv32em but SW & VP support for that is sketchy
cpuType: "rv32imc"
timeProvider: empty
allowUnalignedAccesses: false

sysctrl_bank_0: Memory.MappedMemory @ sysbus 0x1c000000
size: 0x8000

sysctrl_bank_1: Memory.MappedMemory @ sysbus 0x1c008000
size: 0x8000

0 comments on commit fe2f86a

Please sign in to comment.