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

Support for Cheshire on Digilent Genesys 2 #252

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions build_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,21 @@ class ConfigInfo:
"hello": Path("example/star64/hello")
}
),
BoardInfo(
name="cheshire",
arch=KernelArch.RISCV64,
gcc_cpu=None,
loader_link_address=0x90000000,
kernel_options={
"KernelIsMCS": True,
"KernelPlatform": "cheshire",
"KernelRiscvExtD": True,
"KernelRiscvExtF": True,
},
examples={
"hello": Path("example/cheshire/hello")
}
),
)

SUPPORTED_CONFIGS = (
Expand Down
55 changes: 55 additions & 0 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,61 @@ You can see that when using the `go` command, U-Boot is
To avoid this behaviour, the call to `armv8_switch_to_el1` should be replaced with
`armv8_switch_to_el2` in this `do_go_exec` function.

## Cheshire

Support is available for [Cheshire](https://github.com/pulp-platform/cheshire). It is an SoC design based on the CVA6 core, implementing a 64-bit RISC-V CPU. The design supports the hypervisor extension but currently is not supported in seL4.

Microkit outputs a raw binary for this device. Several steps are required in order to boot.

A custom version of OpenSBI is required. It can be found [here](https://github.com/pulp-platform/opensbi/tree/cheshire). Build the firmware payload using platform `fpga/cheshire`.

### Using U-Boot

With a system pre-configured with the Cheshire ZSBL, OpenSBI and U-boot:

=> go 0x90000000

### Raw systerm with no bootloader

Without any firmware present on the SD card, it is still possible to boot Cheshire with a Microkit system.

Using a GDB prompt via openOCD:

1. Reset board
> monitor reset halt

2. Load a device tree blob (DTS available in Cheshire repo or seL4) to memory and set the a0 and a1 registers to point at it:

> restore /path/to/cheshire.dtb binary 0xa0000000

(tell openSBI where DTB is)

> set $a0=0xa0000000

(tell openSBI that the default hart is #0)

> set $a1=0

3. Load openSBI

> load /path/to/opensbi/fw_payload.elf

4. Allow openSBI to boot, and interrupt it once the line `Test payload running` is emitted on serial.

> continue

(wait for output)

> (Ctrl+C)

5. Load Microkit image and execute

> restore /path/to/loader.img binary 0x90000000

(execute)

> continue

## Adding Platform Support

The following section is a guide for adding support for a new platform to Microkit.
Expand Down
50 changes: 50 additions & 0 deletions example/cheshire/hello/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Copyright 2024, UNSW
#
# SPDX-License-Identifier: BSD-2-Clause
#
ifeq ($(strip $(BUILD_DIR)),)
$(error BUILD_DIR must be specified)
endif

ifeq ($(strip $(MICROKIT_SDK)),)
$(error MICROKIT_SDK must be specified)
endif

ifeq ($(strip $(MICROKIT_BOARD)),)
$(error MICROKIT_BOARD must be specified)
endif

ifeq ($(strip $(MICROKIT_CONFIG)),)
$(error MICROKIT_CONFIG must be specified)
endif

TOOLCHAIN := riscv64-unknown-elf

CC := $(TOOLCHAIN)-gcc
LD := $(TOOLCHAIN)-ld
AS := $(TOOLCHAIN)-as
MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit

HELLO_OBJS := hello.o

BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG)

IMAGES := hello.elf
CFLAGS := -mstrict-align -nostdlib -ffreestanding -g -O3 -Wall -Wno-unused-function -Werror -I$(BOARD_DIR)/include -march=rv64imafdc_zicsr_zifencei -mabi=lp64d
LDFLAGS := -L$(BOARD_DIR)/lib
LIBS := -lmicrokit -Tmicrokit.ld

IMAGE_FILE = $(BUILD_DIR)/loader.img
REPORT_FILE = $(BUILD_DIR)/report.txt

all: $(IMAGE_FILE)

$(BUILD_DIR)/%.o: %.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/hello.elf: $(addprefix $(BUILD_DIR)/, $(HELLO_OBJS))
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@

$(IMAGE_FILE) $(REPORT_FILE): $(addprefix $(BUILD_DIR)/, $(IMAGES)) hello.system
$(MICROKIT_TOOL) hello.system --search-path $(BUILD_DIR) --board $(MICROKIT_BOARD) --config $(MICROKIT_CONFIG) -o $(IMAGE_FILE) -r $(REPORT_FILE)
16 changes: 16 additions & 0 deletions example/cheshire/hello/hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright 2024, UNSW
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <stdint.h>
#include <microkit.h>

void init(void)
{
microkit_dbg_puts("hello, world\n");
}

void notified(microkit_channel ch)
{
}
11 changes: 11 additions & 0 deletions example/cheshire/hello/hello.system
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2024, UNSW

SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<protection_domain name="hello" priority="254">
<program_image path="hello.elf" />
</protection_domain>
</system>