Skip to content

Commit

Permalink
Support for Cheshire on Digilent Genesys 2
Browse files Browse the repository at this point in the history
  • Loading branch information
omeh-a committed Nov 25, 2024
1 parent 12f328c commit 3b41d60
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
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
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>

0 comments on commit 3b41d60

Please sign in to comment.