From 3b41d6019e1e8504a688ad29d52acb418f09bfc8 Mon Sep 17 00:00:00 2001 From: Matt Rossouw Date: Mon, 25 Nov 2024 18:47:44 +1100 Subject: [PATCH] Support for Cheshire on Digilent Genesys 2 --- build_sdk.py | 15 +++++++++ example/cheshire/hello/Makefile | 50 +++++++++++++++++++++++++++++ example/cheshire/hello/hello.c | 16 +++++++++ example/cheshire/hello/hello.system | 11 +++++++ 4 files changed, 92 insertions(+) create mode 100644 example/cheshire/hello/Makefile create mode 100644 example/cheshire/hello/hello.c create mode 100644 example/cheshire/hello/hello.system diff --git a/build_sdk.py b/build_sdk.py index 0dfda740..25ad98b6 100644 --- a/build_sdk.py +++ b/build_sdk.py @@ -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 = ( diff --git a/example/cheshire/hello/Makefile b/example/cheshire/hello/Makefile new file mode 100644 index 00000000..81928b34 --- /dev/null +++ b/example/cheshire/hello/Makefile @@ -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) diff --git a/example/cheshire/hello/hello.c b/example/cheshire/hello/hello.c new file mode 100644 index 00000000..c69bdaf9 --- /dev/null +++ b/example/cheshire/hello/hello.c @@ -0,0 +1,16 @@ +/* + * Copyright 2024, UNSW + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include +#include + +void init(void) +{ + microkit_dbg_puts("hello, world\n"); +} + +void notified(microkit_channel ch) +{ +} diff --git a/example/cheshire/hello/hello.system b/example/cheshire/hello/hello.system new file mode 100644 index 00000000..5436463c --- /dev/null +++ b/example/cheshire/hello/hello.system @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file