From 382adf45b567f7316264ae2f15a4d49f1260627c Mon Sep 17 00:00:00 2001 From: Krishnan Winter Date: Tue, 24 Sep 2024 16:14:47 +1000 Subject: [PATCH] echo_server: add example for star64. Signed-off-by: Krishnan Winter --- benchmark/benchmark.c | 11 +- examples/echo_server/Makefile | 25 +- .../board/star64/echo_server.system | 295 ++++++++++++++++++ examples/echo_server/echo.mk | 43 +-- .../include/ethernet_config/ethernet_config.h | 3 + shell.nix | 2 +- 6 files changed, 352 insertions(+), 27 deletions(-) create mode 100644 examples/echo_server/board/star64/echo_server.system diff --git a/benchmark/benchmark.c b/benchmark/benchmark.c index 1eae9056c..e7d6fef9e 100644 --- a/benchmark/benchmark.c +++ b/benchmark/benchmark.c @@ -16,6 +16,7 @@ #include #include +#ifdef CONFIG_ARCH_ARM #define LOG_BUFFER_CAP 7 /* Notification channels and TCB CAP offsets - ensure these align with .system file! */ @@ -353,4 +354,12 @@ seL4_Bool fault(microkit_child id, microkit_msginfo msginfo, microkit_msginfo *r } return seL4_False; -} \ No newline at end of file +} +#endif + +#ifdef CONFIG_ARCH_RISCV + +void init(void) {} +void notified(microkit_channel ch) {} + +#endif diff --git a/examples/echo_server/Makefile b/examples/echo_server/Makefile index e7376ac71..0ccadea97 100644 --- a/examples/echo_server/Makefile +++ b/examples/echo_server/Makefile @@ -12,33 +12,44 @@ $(error MICROKIT_SDK must be specified) endif export override MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) - -ifeq ($(strip $(TOOLCHAIN)),) - TOOLCHAIN := aarch64-none-elf - export TOOLCHAIN := aarch64-none-elf - export LIBC := $(dir $(realpath $(shell aarch64-none-elf-gcc --print-file-name libc.a))) -endif - ifeq ($(strip $(MICROKIT_BOARD)), odroidc4) export DRIV_DIR := meson export UART_DRIV_DIR := meson export TIMER_DRV_DIR := meson export CPU := cortex-a55 + export ARCH := aarch64 else ifneq ($(filter $(strip $(MICROKIT_BOARD)),imx8mm_evk imx8mp_evk maaxboard),) export DRIV_DIR := imx export UART_DRIV_DIR := imx export TIMER_DRV_DIR := imx export CPU := cortex-a53 + export ARCH := aarch64 else ifeq ($(strip $(MICROKIT_BOARD)), qemu_virt_aarch64) export DRIV_DIR := virtio export UART_DRIV_DIR := arm export TIMER_DRV_DIR := arm export CPU := cortex-a53 QEMU := qemu-system-aarch64 + export ARCH := aarch64 +else ifeq ($(strip $(MICROKIT_BOARD)), star64) + export DRIV_DIR := dwmac-5.10a + export UART_DRIV_DIR := snps + export TIMER_DRV_DIR := jh7110 + export ARCH := riscv64 else $(error Unsupported MICROKIT_BOARD given) endif +ifeq ($(ARCH),aarch64) + TOOLCHAIN := aarch64-none-elf + export TOOLCHAIN := aarch64-none-elf + export LIBC := $(dir $(realpath $(shell aarch64-none-elf-gcc --print-file-name libc.a))) +else ifeq ($(ARCH),riscv64) + TOOLCHAIN := riscv64-none-elf + export TOOLCHAIN := $(TOOLCHAIN) + export LIBC := $(dir $(realpath $(shell riscv64-none-elf-gcc --print-file-name libc.a))) +endif + export BUILD_DIR:=$(abspath ${BUILD_DIR}) export MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) diff --git a/examples/echo_server/board/star64/echo_server.system b/examples/echo_server/board/star64/echo_server.system new file mode 100644 index 000000000..e015266de --- /dev/null +++ b/examples/echo_server/board/star64/echo_server.system @@ -0,0 +1,295 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ethernet interrupt --> + ethernet interrupt --> + ethernet interrupt --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/echo_server/echo.mk b/examples/echo_server/echo.mk index bf5e3a67c..e070b7a4a 100644 --- a/examples/echo_server/echo.mk +++ b/examples/echo_server/echo.mk @@ -29,24 +29,31 @@ vpath %.c ${SDDF} ${ECHO_SERVER} IMAGES := eth_driver.elf lwip.elf benchmark.elf idle.elf network_virt_rx.elf\ network_virt_tx.elf copy.elf timer_driver.elf uart_driver.elf serial_virt_tx.elf -CFLAGS := -mcpu=$(CPU) \ - -mstrict-align \ - -ffreestanding \ - -g3 -O3 -Wall \ - -Wno-unused-function \ - -DMICROKIT_CONFIG_$(MICROKIT_CONFIG) \ - -I$(BOARD_DIR)/include \ - -I$(SDDF)/include \ - -I${ECHO_INCLUDE}/lwip \ - -I${ETHERNET_CONFIG_INCLUDE} \ - -I$(SERIAL_CONFIG_INCLUDE) \ - -I${SDDF}/$(LWIPDIR)/include \ - -I${SDDF}/$(LWIPDIR)/include/ipv4 \ - -MD \ - -MP - -LDFLAGS := -L$(BOARD_DIR)/lib -L${LIBC} -LIBS := --start-group -lmicrokit -Tmicrokit.ld -lc libsddf_util_debug.a --end-group +CFLAGS := -mstrict-align \ + -ffreestanding \ + -g3 -O3 -Wall \ + -Wno-unused-function \ + -DMICROKIT_CONFIG_$(MICROKIT_CONFIG) \ + -I$(BOARD_DIR)/include \ + -I$(SDDF)/include \ + -I${ECHO_INCLUDE}/lwip \ + -I${ETHERNET_CONFIG_INCLUDE} \ + -I$(SERIAL_CONFIG_INCLUDE) \ + -I${SDDF}/$(LWIPDIR)/include \ + -I${SDDF}/$(LWIPDIR)/include/ipv4 \ + -MD \ + -MP + +LDFLAGS := -L$(BOARD_DIR)/lib -L${LIBC} -L. +LIBS := --start-group -lmicrokit -Tmicrokit.ld -lc -lsddf_util_debug --end-group + +ifeq ($(ARCH),aarch64) + CFLAGS += -mcpu=$(CPU) + LIBS += -lc +else ifeq ($(ARCH),riscv64) + CFLAGS += -mabi=lp64d -march=rv64imafdc + LIBS += -lc +endif CHECK_FLAGS_BOARD_MD5:=.board_cflags-$(shell echo -- ${CFLAGS} ${BOARD} ${MICROKIT_CONFIG} | shasum | sed 's/ *-//') diff --git a/examples/echo_server/include/ethernet_config/ethernet_config.h b/examples/echo_server/include/ethernet_config/ethernet_config.h index e9ce98bb4..057661821 100644 --- a/examples/echo_server/include/ethernet_config/ethernet_config.h +++ b/examples/echo_server/include/ethernet_config/ethernet_config.h @@ -39,6 +39,9 @@ #elif defined(CONFIG_PLAT_IMX8MP_EVK) #define MAC_ADDR_CLI0 0x525401000009 #define MAC_ADDR_CLI1 0x52540100000A +#elif defined (CONFIG_PLAT_STAR64) +#define MAC_ADDR_CLI0 0x52540100000B +#define MAC_ADDR_CLI1 0x52540100000C #else #error "Must define MAC addresses for clients in ethernet config" #endif diff --git a/shell.nix b/shell.nix index 3c6f366e3..a51bacc18 100644 --- a/shell.nix +++ b/shell.nix @@ -12,7 +12,7 @@ in llvm.lld llvm.libllvm dosfstools - + pkgsCross.riscv64-embedded.buildPackages.gcc # for git-clang-format. nix is weird. llvm.libclang.python ];