Skip to content

Commit

Permalink
Implement CI for CVA6
Browse files Browse the repository at this point in the history
  • Loading branch information
grg-haas committed Jun 18, 2024
1 parent e310f6a commit 842b92e
Show file tree
Hide file tree
Showing 24 changed files with 657 additions and 183 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ jobs:
# Combine cache directories to save space
combine-caches:
runs-on: ubuntu-latest
if: ${{ always() }}
if: success() || failure()
needs: build
steps:
- name: Install dependencies
Expand Down Expand Up @@ -378,6 +378,6 @@ jobs:
uses: ./.github/workflows/build-runtime.yml

# System tests, which are run for simulatable and self-hostable platforms
test-system:
test-system-functionality:
needs: build
uses: ./.github/workflows/test-system.yml
203 changes: 43 additions & 160 deletions .github/workflows/test-system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@ on:
workflow_call:

jobs:
test-generic:
runs-on: ubuntu-latest
test-system:
runs-on: ${{ matrix.platform == 'generic' && 'ubuntu-latest' || matrix.platform }}
environment: ${{ matrix.platform != 'generic' && 'track' || null }}
strategy:
matrix:
platform: [generic]
platform: [generic, mpfs] #cva6]
bits: [32, 64]
exclude:
# mpfs is not 32 bit
- platform: mpfs
bits: 32

steps:
# We don't need submodules here since Keystone is a monorepo!
- name: Checkout Keystone
uses: actions/checkout@v4
with:
submodules: 'false'
submodules: 'true'
sparse-checkout: |
.
scripts/
mkutils/
- name: Restore build directory
uses: actions/download-artifact@v4
Expand All @@ -26,188 +34,63 @@ jobs:
- name: Decompress build directory
run: cat build.tar.xz | xz -d -T0 | tar -xf -

- name: Test Keystone system
run: |
# Fix permissions on the key
chmod 600 build-${{ matrix.platform }}${{ matrix.bits }}/buildroot.build/target/root/.ssh/id-rsa
# Launch QEMU
export KEYSTONE_PLATFORM=${{ matrix.platform }}
export KEYSTONE_BITS=${{ matrix.bits }}
export QEMU_PORT=$(( RANDOM + 1024 ))
export LD_LIBRARY_PATH=build-${{ matrix.platform }}${{ matrix.bits }}/buildroot.build/host/lib
screen -L -dmS qemu bash -c "make run 2>&1 | tee run.log"
# TODO: check for connectivity instead of sleeping
sleep 60
export CALL_LOGFILE=cmd.log
echo "" > $CALL_LOGFILE
KEYSTONE_COMMAND="modprobe keystone-driver" make call
KEYSTONE_COMMAND="/usr/share/keystone/examples/tests.ke" make call
KEYSTONE_COMMAND="/usr/share/keystone/examples/attestor.ke" make call
KEYSTONE_COMMAND="poweroff" make call
- name: Check expected
run: |
[[ -z $(diff cmd.log scripts/ci/expected.log) ]]
- name: Upload run log
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-keystone-${{ matrix.platform }}${{ matrix.bits }}-run.log
path: run.log

- name: Upload cmd log
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-keystone-${{ matrix.platform }}${{ matrix.bits }}-cmd.log
path: cmd.log

test-mpfs:
runs-on: [self-hosted, mpfs]
environment: track
steps:
# We don't need submodules here since Keystone is a monorepo!
- name: Checkout Keystone
uses: actions/checkout@v4
with:
submodules: 'false'

- name: Restore build directory
uses: actions/download-artifact@v4
with:
name: keystone-mpfs64-builddir
path: .

- name: Decompress build directory
run: cat build.tar.xz | xz -d -T0 | tar -xf -

# Test the firmware, first by flashing it
- name: Flash HSS
- name: Flash and check firmware
env:
POWER_ON_CMD: ${{ vars.POWER_ON_CMD_MPFS }}
POWER_OFF_CMD: ${{ vars.POWER_OFF_CMD_MPFS }}
SC_INSTALL_DIR: ${{ vars.SC_INSTALL_DIR }}
KEYSTONE_PLATFORM: ${{ matrix.platform }}
KEYSTONE_BITS: ${{ matrix.bits }}
LOGFILE: fw-program.log
run: |
$POWER_ON_CMD
export FPGENPROG=$(which fpgenprog)
make -C build-mpfs64/buildroot.build/build/hss-v2023.06 program 2>/dev/null >program.log
$POWER_OFF_CMD
# Check if we succeeded
[[ ! -z $(cat program.log | grep "mpfsBootmodeProgrammer completed successfully") ]]
if [[ -f scripts/ci/plat/${{ matrix.platform }}/flash-firmware.sh ]]; then
scripts/ci/plat/${{ matrix.platform }}/flash-firmware.sh
fi
- name: Upload HSS program log
if: failure()
- name: Upload firmware programming log
if: ${{ matrix.platform != 'generic' && failure() }}
uses: actions/upload-artifact@v4
with:
name: test-keystone-mpfs64-prog-hss.log
path: program.log
name: test-keystone-${{ matrix.platform }}${{ matrix.bits }}-fw-program.log
path: fw-program.log

# And then verifying that we can actually get to the command line
- name: Check HSS ok
- name: Flash and check OS
env:
POWER_ON_CMD: ${{ vars.POWER_ON_CMD_MPFS }}
POWER_OFF_CMD: ${{ vars.POWER_OFF_CMD_MPFS }}
FIND_TTY_CMD: ${{ vars.FIND_TTY_CMD }}
KEYSTONE_PLATFORM: ${{ matrix.platform }}
KEYSTONE_BITS: ${{ matrix.bits }}
LOGFILE: os-program.log
run: |
# Collect serial output
TTYDEV=$($FIND_TTY_CMD 0)
screen -L -dmS mpfs-tty bash -c "stty raw -echo 115200 < $TTYDEV ; cat $TTYDEV > run-hss.log"
$POWER_ON_CMD ; sleep 30 ; $POWER_OFF_CMD
screen -XS mpfs-tty quit
# At least the first hart should have started
[[ ! -z $(cat run-hss.log | sed -e 's/\x1b\[[0-9;]*m//g' | grep "u54 State Change: \[Running\]") ]]
if [[ -f scripts/ci/plat/${{ matrix.platform }}/flash-os.sh ]]; then
scripts/ci/plat/${{ matrix.platform }}/flash-os.sh
fi
- name: Upload HSS run log
if: failure()
- name: Upload OS programming log
if: ${{ matrix.platform != 'generic' && failure() }}
uses: actions/upload-artifact@v4
with:
name: test-keystone-mpfs64-run-hss.log
path: run-hss.log

# Now we also need to flash the disk. First, get into usbdmsc
- name: Flash OS
env:
POWER_ON_CMD: ${{ vars.POWER_ON_CMD_MPFS }}
POWER_OFF_CMD: ${{ vars.POWER_OFF_CMD_MPFS }}
FIND_TTY_CMD: ${{ vars.FIND_TTY_CMD }}
run: |
# Wait for the board to come up a bit. We'll hammer it with serial
# input to ensure that we halt the boot at HSS
TTYDEV=$($FIND_TTY_CMD 0)
$POWER_ON_CMD
NOW=$(date +%s)
stty raw -echo 115200 < "$TTYDEV"
while [[ $(( $(date +%s) - $NOW )) -lt 10 ]]; do echo 'a' > "$TTYDEV" ; done
echo "" > "$TTYDEV"
echo "usbdmsc" > "$TTYDEV"
# Wait a bit for the USB to connect then flash
sleep 10
FOUND_DEVICE=""
for d in /dev/sd? ; do
if [[ ! -z $(udevadm info --query=all -n "$d" | grep -i polarfire) ]]; then
FOUND_DEVICE="yes"
dd if=build-mpfs64/buildroot.build/images/sdcard.img of="$d" bs=4M oflag=direct
break
fi
done
$POWER_OFF_CMD
[[ ! -z "$FOUND_DEVICE" ]]
name: test-keystone-${{ matrix.platform }}${{ matrix.bits }}-os-program.log
path: os-program.log

- name: Test Keystone system
env:
POWER_ON_CMD: ${{ vars.POWER_ON_CMD_MPFS }}
POWER_OFF_CMD: ${{ vars.POWER_OFF_CMD_MPFS }}
FIND_TTY_CMD: ${{ vars.FIND_TTY_CMD }}
KEYSTONE_IP: ${{ vars.BOARD_IP_MPFS }}
KEYSTONE_PLATFORM: ${{ matrix.platform }}
KEYSTONE_BITS: ${{ matrix.bits }}
LOGFILE: run.log
CMD_LOGFILE: cmd.log
run: |
# Fix permissions on the key
chmod 600 build-mpfs64/buildroot.build/target/root/.ssh/id-rsa
# Start the board
TTYDEV=$($FIND_TTY_CMD 1)
export KEYSTONE_PLATFORM=mpfs
export KEYSTONE_BITS=64
screen -L -dmS mpfs-tty bash -c "stty raw -echo 115200 < $TTYDEV ; cat $TTYDEV > run.log"
$POWER_ON_CMD
# TODO: check for connectivity instead of sleeping
sleep 60
export CALL_LOGFILE=cmd.log
echo "" > $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 mpfs
#KEYSTONE_COMMAND="/usr/share/keystone/examples/attestor.ke" make call
$POWER_OFF_CMD
screen -XS mpfs-tty quit
scripts/ci/plat/${{ matrix.platform }}/test.sh
- name: Check expected
run: |
[[ -z $(diff cmd.log scripts/ci/expected-mpfs.log) ]]
[[ -z $(diff cmd.log scripts/ci/plat/${{ matrix.platform }}/expected.log) ]]
- name: Upload run log
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-keystone-mpfs64-run.log
name: test-keystone-${{ matrix.platform }}${{ matrix.bits }}-run.log
path: run.log

- name: Upload cmd log
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-keystone-mpfs64-cmd.log
name: test-keystone-${{ matrix.platform }}${{ matrix.bits }}-cmd.log
path: cmd.log
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "overlays/microchip"]
path = overlays/microchip
url = https://github.com/linux4microchip/buildroot-external-microchip
[submodule "scripts/ci/utils/relay_ft245r"]
path = scripts/ci/utils/relay_ft245r
url = https://github.com/vpatron/relay_ft245r
14 changes: 11 additions & 3 deletions mkutils/plat/cva6/run.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@


PAYLOAD = $(BUILDROOT_BUILDDIR)/images/fw_payload.bin
SDDEVICE_PART1 = $(SD_DEVICE)1
SDDEVICE_PART2 = $(SD_DEVICE)2
KERNEL = $(BUILDROOT_BUILDDIR)/images/uImage
SDDEVICE_PART1 = $(shell lsblk $(SD_DEVICE) -no PATH | head -2 | tail -1)
SDDEVICE_PART2 = $(shell lsblk $(SD_DEVICE) -no PATH | head -3 | tail -1)



Expand All @@ -16,5 +17,12 @@ flash: $(SD_DEVICE)
$(info $(SD_DEVICE))
$(info $(SDDEVICE_PART1))
$(info $(SDDEVICE_PART2))
sgdisk --clear -g --new=1:2048:40M --new=2:512M:0 --typecode=1:3000 --typecode=2:8300 $(SD_DEVICE)
sgdisk --clear -g --new=1:2048:4M --new=2:512M:0 --typecode=1:3000 --typecode=2:8300 $(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

debug-connect:
$(call log,info,Connecting to OpenOCD)
$(BUILDROOT_BUILDDIR)/host/bin/riscv64-buildroot-linux-gnu-gdb \
-iex "set KEYSTONE=$(KEYSTONE)" \
-x $(KEYSTONE)/scripts/gdb/cva6.cfg
25 changes: 9 additions & 16 deletions overlays/keystone/board/cva6/configs/linux64-cva6-defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ CONFIG_DEFAULT_HOSTNAME="ariane-fpga"
# CONFIG_CROSS_MEMORY_ATTACH is not set
CONFIG_NAMESPACES=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="${BUILD_ROOT}/buildroot.build/images/rootfs.cpio"
CONFIG_INITRAMFS_SOURCE="${BR_BINARIES_DIR}/rootfs.cpio"
CONFIG_EMBEDDED=y
CONFIG_SMP=y
CONFIG_HZ_100=y
CONFIG_CMDLINE="earlyprintk initcall_debug"
# CONFIG_GCC_PLUGINS is not set
CONFIG_MODULES=y
# CONFIG_BLK_DEV_BSG is not set
CONFIG_PARTITION_ADVANCED=y
# CONFIG_COMPACTION is not set
CONFIG_CMA=y
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
Expand All @@ -26,16 +27,13 @@ CONFIG_NETDEVICES=y
CONFIG_VXLAN=y
CONFIG_LOWRISC_DIGILENT_100MHZ=y
CONFIG_XILINX_EMACLITE=y
CONFIG_MDIO_BCM_UNIMAC=y
CONFIG_REALTEK_PHY=y
CONFIG_MDIO_BITBANG=y
CONFIG_MDIO_BCM_UNIMAC=y
CONFIG_MDIO_GPIO=y
CONFIG_MDIO_BUS_MUX_GPIO=y
CONFIG_MDIO_BUS_MUX_MMIOREG=y
CONFIG_MDIO_BUS_MUX_MULTIPLEXER=y
CONFIG_MDIO_GPIO=y
CONFIG_REALTEK_PHY=y
CONFIG_DEBUG=y
CONFIG_DEBUG_INFO=y
CONFIG_GDB_SCRIPTS=y
CONFIG_MDIO_BUS_MUX_MMIOREG=y
# CONFIG_WLAN is not set
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
Expand All @@ -44,15 +42,13 @@ CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
CONFIG_SERIAL_OF_PLATFORM=y
CONFIG_SERIAL_UARTLITE=y
CONFIG_HVC_RISCV_SBI=y
CONFIG_VIRTIO_CONSOLE=y
# CONFIG_HW_RANDOM is not set
CONFIG_I2C=y
CONFIG_I2C_OCORES=y
CONFIG_SPI=y
CONFIG_SPI_SPIDEV=y
CONFIG_SPI_MASTER=y
CONFIG_SPI_XILINX=y
CONFIG_SPI_SPIDEV=y
CONFIG_GPIOLIB=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_XILINX=y
Expand All @@ -61,9 +57,6 @@ CONFIG_POWER_RESET_GPIO_RESTART=y
CONFIG_USB=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_SUPPORT=y
CONFIG_USB_COMMON=y
CONFIG_USB_CONFIGFS=m
CONFIG_MMC=y
CONFIG_MMC_SPI=y
CONFIG_NEW_LEDS=y
Expand All @@ -87,7 +80,7 @@ CONFIG_NFS_V4_1=y
CONFIG_NFS_V4_2=y
CONFIG_CRYPTO_ECHAINIV=y
# CONFIG_CRYPTO_HW is not set
CONFIG_DMA_CMA=y
CONFIG_PRINTK_TIME=y
CONFIG_STRIP_ASM_SYMS=y
CONFIG_DEBUG_SECTION_MISMATCH=y
CONFIG_STACKTRACE=y
2 changes: 2 additions & 0 deletions overlays/keystone/board/cva6/configs/uboot-cva6.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_MMC_WRITE=y
CONFIG_BOOTCOMMAND="mmc info; mmc read 90000000 100000 10000; setenv fdt_high 0xffffffffffffffff; bootm 90000000 - $(fdtcontroladdr)"
Loading

0 comments on commit 842b92e

Please sign in to comment.