diff --git a/build_sdk.py b/build_sdk.py index 2a92cef6..b7b771a6 100644 --- a/build_sdk.py +++ b/build_sdk.py @@ -55,30 +55,29 @@ class ConfigInfo: SUPPORTED_BOARDS = ( BoardInfo( - name="tqma8xqp1gb", - gcc_cpu="cortex-a35", - loader_link_address=0x80280000, + name="zcu102", + gcc_cpu="cortex-a53", + loader_link_address=0x40000000, kernel_options={ - "KernelPlatform": "tqma8xqp1gb", + "KernelPlatform": "zynqmp", + "KernelARMPlatform": "zcu102", "KernelIsMCS": True, "KernelArmExportPCNTUser": True, }, examples={ - "ethernet": Path("example/tqma8xqp1gb/ethernet") } ), BoardInfo( - name="zcu102", + name="rockpro64", gcc_cpu="cortex-a53", - loader_link_address=0x40000000, + loader_link_address=0x20000000, kernel_options={ - "KernelPlatform": "zynqmp", - "KernelARMPlatform": "zcu102", + "KernelPlatform": "rockpro64", + "KernelARMPlatform": "rockpro64", "KernelIsMCS": True, "KernelArmExportPCNTUser": True, }, examples={ - "hello": Path("example/zcu102/hello") } ), # BoardInfo( diff --git a/example/rockpro64/hello/Makefile b/example/rockpro64/hello/Makefile new file mode 100644 index 00000000..b78ab030 --- /dev/null +++ b/example/rockpro64/hello/Makefile @@ -0,0 +1,55 @@ +# +# Copyright 2021, Breakaway Consulting Pty. Ltd. +# +# 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 := aarch64-none-elf + +CPU := cortex-a53 + +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 := -mcpu=$(CPU) -mstrict-align -nostdlib -ffreestanding -g3 -O3 -Wall -Wno-unused-function -Werror -I$(BOARD_DIR)/include +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)/%.o: %.s Makefile + $(AS) -g3 -mcpu=$(CPU) $< -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/rockpro64/hello/hello.c b/example/rockpro64/hello/hello.c new file mode 100644 index 00000000..9519a6cb --- /dev/null +++ b/example/rockpro64/hello/hello.c @@ -0,0 +1,18 @@ +/* + * Copyright 2021, Breakaway Consulting Pty. Ltd. + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include +#include + +void +init(void) +{ + microkit_dbg_puts("hello, world\n"); +} + +void +notified(microkit_channel ch) +{ +} \ No newline at end of file diff --git a/example/rockpro64/hello/hello.system b/example/rockpro64/hello/hello.system new file mode 100644 index 00000000..9625ad66 --- /dev/null +++ b/example/rockpro64/hello/hello.system @@ -0,0 +1,11 @@ + + + + + + + diff --git a/loader/src/loader.c b/loader/src/loader.c index 09840993..6d4262d5 100644 --- a/loader/src/loader.c +++ b/loader/src/loader.c @@ -31,6 +31,21 @@ _Static_assert(sizeof(uintptr_t) == 8 || sizeof(uintptr_t) == 4, "Expect uintptr #if defined(BOARD_zcu102) #define GICD_BASE 0x00F9010000UL #define GICC_BASE 0x00F9020000UL +#elif defined(BOARD_rockpro64) /*see line 513 of rockpro64.dts*/ +#define GICD_BASE 0xfee00000UL +#define GICC_BASE 0xfee10000UL +#endif + +/* + * seL4 expects platforms with a GICv2 to be configured. This configuration is + * usually done by U-Boot and so the loader does not have to do anything. + * However, in the case of using something like QEMU, where the system is run + * without U-Boot, we have to do this configuration in the loader. Otherwise + * interrupts will not work. + */ +#if defined(BOARD_zcu102) || \ + defined(BOARD_rockpro64) + #define GIC_V2 #endif #define REGION_TYPE_DATA 1 @@ -143,6 +158,19 @@ putc(uint8_t ch) { *((volatile uint32_t *)(0x00FF000030)) = ch; } + +#elif defined(BOARD_rockpro64) +#define UART_BASE 0x9000000 +#define UARTDR 0x000 +#define UARTFR 0x018 +#define PL011_UARTFR_TXFF (1 << 5) + +static void +putc(uint8_t ch) +{ + while ((*UART_REG(UARTFR) & PL011_UARTFR_TXFF) != 0); + *UART_REG(UARTDR) = ch; +} #else #error Board not defined #endif @@ -417,7 +445,7 @@ start_kernel(void) ); } -#if defined(BOARD_zcu102) +#if defined(GIC_V2) static void configure_gicv2(void) { @@ -483,7 +511,7 @@ main(void) */ copy_data(); -#if defined(BOARD_zcu102) +#if defined(GIC_V2) configure_gicv2(); #endif