Skip to content

Commit

Permalink
Implement CI for hifive unmatched
Browse files Browse the repository at this point in the history
  • Loading branch information
grg-haas committed Jul 16, 2024
1 parent 029a3d1 commit 1e3b13f
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 27 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test-system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [generic, mpfs, cva6]
platform: [generic, mpfs, cva6, hifive_unmatched]
bits: [32, 64]
exclude:
# mpfs is not 32 bit
- platform: mpfs
bits: 32
# unmatched is not 32 bit
- platform: hifive_unmatched
bits: 32
# ignore 32-bit cva6 for now
- platform: cva6
bits: 32
Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,14 @@ linux-configure: $(BUILDROOT_BUILDDIR)/.config
## Run targets ##
#################

CALL_LOGFILE ?= $(shell mktemp)
call:
$(call log,info,Calling command)
ssh -i $(BUILDROOT_BUILDDIR)/target/root/.ssh/id-rsa \
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-o ConnectTimeout=5 \
-p $(QEMU_PORT) root@localhost $(KEYSTONE_COMMAND) 2>&1 | \
grep -v "Warning: Permanently added" | tee -a $(CALL_LOGFILE)

-include mkutils/plat/$(KEYSTONE_PLATFORM)/run.mk

8 changes: 0 additions & 8 deletions mkutils/plat/cva6/run.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ flash: $(SD_DEVICE)
dd if=$(PAYLOAD) of=$(SDDEVICE_PART1) status=progress oflag=sync bs=1M
dd if=$(KERNEL) of=$(SDDEVICE_PART2) status=progress oflag=sync bs=1M

CALL_LOGFILE ?= $(shell mktemp)
call:
$(call log,info,Calling command on the CVA6 board)
ssh -i $(BUILDROOT_BUILDDIR)/target/root/.ssh/id-rsa \
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
root@$(KEYSTONE_IP) $(KEYSTONE_COMMAND) 2>&1 | \
grep -v "Warning: Permanently added" | tee -a $(CALL_LOGFILE)

debug-connect:
$(call log,info,Connecting to OpenOCD)
$(BUILDROOT_BUILDDIR)/host/bin/riscv64-buildroot-linux-gnu-gdb \
Expand Down
9 changes: 0 additions & 9 deletions mkutils/plat/generic/run.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ run:
$(call log,info,Starting QEMU)
$(BUILDROOT_BUILDDIR)/host/bin/qemu-system-riscv$(KEYSTONE_BITS) $(QEMU_FLAGS)

CALL_LOGFILE ?= $(shell mktemp)
call:
$(call log,info,Calling command in QEMU)
ssh -i $(BUILDROOT_BUILDDIR)/target/root/.ssh/id-rsa \
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-o ConnectTimeout=5 \
-p $(QEMU_PORT) root@localhost $(KEYSTONE_COMMAND) 2>&1 | \
grep -v "Warning: Permanently added" | tee -a $(CALL_LOGFILE)

debug-connect:
$(call log,info,Connecting to QEMU)
$(BUILDROOT_BUILDDIR)/host/bin/riscv$(KEYSTONE_BITS)-buildroot-linux-gnu-gdb \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ ifeq ($(EXTEND),1)
endif

endif

8 changes: 0 additions & 8 deletions mkutils/plat/mpfs/run.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ run:
$(call log,info,Starting OpenOCD)
$(SC_INSTALL_DIR)/openocd/bin/openocd $(OPENOCD_FLAGS)

CALL_LOGFILE ?= $(shell mktemp)
call:
$(call log,info,Calling command on the MPFS board)
ssh -i $(BUILDROOT_BUILDDIR)/target/root/.ssh/id-rsa \
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
root@$(KEYSTONE_IP) $(KEYSTONE_COMMAND) 2>&1 | \
grep -v "Warning: Permanently added" | tee -a $(CALL_LOGFILE)

debug-connect:
$(call log,info,Connecting to OpenOCD)
PYTHONPATH=$(BUILDROOT_BUILDDIR)/build/host-gcc-final-11.4.0/libstdc++-v3/python \
Expand Down
3 changes: 3 additions & 0 deletions scripts/ci/configs/global.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ export TTY_IDPRODUCT_mpfs="ea71"
export TTY_IDVENDOR_cva6="0403"
export TTY_IDPRODUCT_cva6="6001"

# hifive_unmatched
export TTY_IDVENDOR_hifive_unmatched="0403"
export TTY_IDPRODUCT_hifive_unmatched="6010"
6 changes: 6 additions & 0 deletions scripts/ci/configs/track.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export RELAY_SERIAL="AH02O23H"
export RELAY_ID_global=1
export RELAY_ID_mpfs=8
export RELAY_ID_cva6=4
export RELAY_ID_hifive_unmatched=5

# MPFS configuration

Expand All @@ -20,3 +21,8 @@ export TFTP_DIR="/srv/tftp"

export HOST_IP_cva6="10.42.1.1"
export BOARD_IP_cva6="10.42.1.171"

# Unmatched configuration

export HOST_IP_hifive_unmatched="10.42.1.1"
export BOARD_IP_hifive_unmatched="10.42.1.27"
17 changes: 17 additions & 0 deletions scripts/ci/plat/hifive_unmatched/expected.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Verifying archive integrity... MD5 checksums are OK. All good.
Uncompressing Keystone Enclave Package
testing test-stack
testing test-loop
testing test-malloc
testing test-long-nop
testing test-fibonacci
testing test-fib-bench
testing test-attestation
Attestation report SIGNATURE is valid
testing test-untrusted
Enclave said: hello world!
Enclave said: 2nd hello world!
Enclave said value: 13
Enclave said value: 20
testing test-data-sealing
Enclave said: Sealing key derivation successful!
38 changes: 38 additions & 0 deletions scripts/ci/plat/hifive_unmatched/flash-os.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -e

# Source global test configuration file
. scripts/ci/test-setup.sh

OS_FILENAME="build-hifive_unmatched64/buildroot.build/images/sdcard.img"
get_platform_var HOST_IP
get_platform_var BOARD_IP

###########
## Flash ##
###########
set -x

TTYDEV=$(find_tty 1)
touch "$LOGFILE"
start_record_tty "$TTYDEV" 115200 "$LOGFILE" hfu-tty

power_on_btn
wait_for "Hit any key to stop autboot"
echo 'a' > "$TTYDEV"

rm -rf "$TFTP_DIR/sdcard.img"
cp "$OS_FILENAME" "$TFTP_DIR/sdcard.img"

# Configure TFTP
echo "setenv serverip $HOST_IP" > "$TTYDEV" ; sleep 1
echo "setenv ipaddr $BOARD_IP" > "$TTYDEV" ; sleep 1

echo "tftp sdcard.img" > "$TTYDEV"
wait_for "=>"
echo "mmc write 80210000 0 100000"
wait_for "=>"

stop_record_tty hfu-tty
power_off_btn
exit 0
43 changes: 43 additions & 0 deletions scripts/ci/plat/hifive_unmatched/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -e

# Source global test configuration file
. scripts/ci/test-setup.sh

if [[ -z "$CMD_LOGFILE" ]]; then
echo "CMD_LOGFILE undefined"
exit 1
fi

get_platform_var BOARD_IP

###############
## Run tests ##
###############
set -x

# Fix permissions on the key
chmod 600 "build-hifive_unmatched64/buildroot.build/target/root/.ssh/id-rsa"

# Start the board
export KEYSTONE_PLATFORM="hifive_unmatched"
export KEYSTONE_IP="$BOARD_IP"

TTYDEV=$(find_tty 1)
start_record_tty "$TTYDEV" 115200 "$LOGFILE" hfu-tty
power_on_btn

# TODO: check for connectivity instead of sleeping
sleep 60

export CALL_LOGFILE="$CMD_LOGFILE"
touch "$CALL_LOGFILE"

KEYSTONE_COMMAND="modprobe keystone-driver" make call
KEYSTONE_COMMAND="/usr/share/keystone/examples/tests.ke" make call
# TODO: attestation does not yet work in unmatched
#KEYSTONE_COMMAND="/usr/share/keystone/examples/attestor.ke" make call

power_off_btn
stop_record_tty hfu-tty
exit 0
10 changes: 10 additions & 0 deletions scripts/ci/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ function power_off {
./scripts/ci/utils/relay_power.py "$RELAY_SERIAL" "$RELAY_ID" off
}

function power_on_btn {
# Very temporarily close the power on circuit
power_on ; power_off
}

function power_off_btn {
# Simulate holding the power button to force off
power_on ; sleep 3 ; power_off
}

# Serial functions

get_platform_var TTY_IDVENDOR
Expand Down

0 comments on commit 1e3b13f

Please sign in to comment.