From aa0af1357bfb12881aa97edaf3cee37590fe0856 Mon Sep 17 00:00:00 2001 From: Ivan-Velickovic Date: Mon, 23 Dec 2024 14:50:31 +1300 Subject: [PATCH] Refactor examples for handling many boards The current way examples are done in the repository and shipped in the SDK does not make sense when you have many boards in my opinion so this restructure moves examples that are not specific to any particular platform (e.g hello world) to be generic to every platform supported by Microkit. Signed-off-by: Ivan-Velickovic --- README.md | 2 + build_sdk.py | 74 ++++++------------- dev_build.py | 4 +- docs/manual.md | 2 +- example/{tqma8xqp1gb => }/ethernet/Makefile | 4 + example/ethernet/README.md | 19 +++++ example/{tqma8xqp1gb => }/ethernet/eth.c | 0 .../ethernet/ethernet.system | 0 example/{tqma8xqp1gb => }/ethernet/foo.c | 0 example/{tqma8xqp1gb => }/ethernet/gpt.c | 0 example/{tqma8xqp1gb => }/ethernet/pass.c | 0 .../{qemu_virt_riscv64 => }/hello/Makefile | 19 ++++- example/hello/README.md | 21 ++++++ example/{imx8mp_evk => }/hello/hello.c | 0 example/{imx8mp_evk => }/hello/hello.system | 0 .../hierarchy/Makefile | 19 +++-- example/hierarchy/README.md | 23 ++++++ .../hierarchy/crasher.c | 0 .../imx8mq_evk/hello => hierarchy}/hello.c | 0 .../hierarchy/hierachy.system | 0 .../hierarchy/restarter.c | 0 example/imx8mp_evk/hello/Makefile | 55 -------------- example/imx8mp_evk/imx8mq_evk/hello/Makefile | 55 -------------- .../imx8mp_evk/imx8mq_evk/hello/hello.system | 11 --- example/imx8mq_evk/hello/Makefile | 55 -------------- example/imx8mq_evk/hello/hello.c | 16 ---- example/imx8mq_evk/hello/hello.system | 11 --- example/maaxboard/hello/Makefile | 55 -------------- example/maaxboard/hello/hello.c | 18 ----- example/maaxboard/hello/hello.system | 11 --- example/odroidc2/hello/Makefile | 55 -------------- example/odroidc2/hello/hello.c | 16 ---- example/odroidc2/hello/hello.system | 11 --- .../{imx8mm_evk => }/passive_server/Makefile | 19 +++-- example/passive_server/README.md | 26 +++++++ .../{imx8mm_evk => }/passive_server/client.c | 0 .../passive_server/passive_server.system | 0 .../{imx8mm_evk => }/passive_server/server.c | 0 example/qemu_virt_aarch64/hello/Makefile | 55 -------------- example/qemu_virt_aarch64/hello/hello.c | 16 ---- example/qemu_virt_aarch64/hello/hello.system | 11 --- example/qemu_virt_aarch64/hierarchy/hello.c | 16 ---- example/qemu_virt_riscv64/hello/hello.c | 16 ---- example/qemu_virt_riscv64/hello/hello.system | 11 --- example/rockpro64/hello/Makefile | 55 -------------- example/rockpro64/hello/hello.c | 16 ---- example/rockpro64/hello/hello.system | 11 --- example/star64/hello/Makefile | 50 ------------- example/star64/hello/hello.c | 16 ---- example/star64/hello/hello.system | 11 --- example/{odroidc4 => }/timer/Makefile | 4 + example/timer/README.md | 21 ++++++ example/{odroidc4 => }/timer/timer.c | 0 example/{odroidc4 => }/timer/timer.system | 0 example/zcu102/hello/Makefile | 55 -------------- example/zcu102/hello/hello.c | 18 ----- example/zcu102/hello/hello.system | 11 --- 57 files changed, 189 insertions(+), 805 deletions(-) rename example/{tqma8xqp1gb => }/ethernet/Makefile (93%) create mode 100644 example/ethernet/README.md rename example/{tqma8xqp1gb => }/ethernet/eth.c (100%) rename example/{tqma8xqp1gb => }/ethernet/ethernet.system (100%) rename example/{tqma8xqp1gb => }/ethernet/foo.c (100%) rename example/{tqma8xqp1gb => }/ethernet/gpt.c (100%) rename example/{tqma8xqp1gb => }/ethernet/pass.c (100%) rename example/{qemu_virt_riscv64 => }/hello/Makefile (74%) create mode 100644 example/hello/README.md rename example/{imx8mp_evk => }/hello/hello.c (100%) rename example/{imx8mp_evk => }/hello/hello.system (100%) rename example/{qemu_virt_aarch64 => }/hierarchy/Makefile (76%) create mode 100644 example/hierarchy/README.md rename example/{qemu_virt_aarch64 => }/hierarchy/crasher.c (100%) rename example/{imx8mp_evk/imx8mq_evk/hello => hierarchy}/hello.c (100%) rename example/{qemu_virt_aarch64 => }/hierarchy/hierachy.system (100%) rename example/{qemu_virt_aarch64 => }/hierarchy/restarter.c (100%) delete mode 100644 example/imx8mp_evk/hello/Makefile delete mode 100644 example/imx8mp_evk/imx8mq_evk/hello/Makefile delete mode 100644 example/imx8mp_evk/imx8mq_evk/hello/hello.system delete mode 100644 example/imx8mq_evk/hello/Makefile delete mode 100644 example/imx8mq_evk/hello/hello.c delete mode 100644 example/imx8mq_evk/hello/hello.system delete mode 100644 example/maaxboard/hello/Makefile delete mode 100644 example/maaxboard/hello/hello.c delete mode 100644 example/maaxboard/hello/hello.system delete mode 100644 example/odroidc2/hello/Makefile delete mode 100644 example/odroidc2/hello/hello.c delete mode 100644 example/odroidc2/hello/hello.system rename example/{imx8mm_evk => }/passive_server/Makefile (74%) create mode 100644 example/passive_server/README.md rename example/{imx8mm_evk => }/passive_server/client.c (100%) rename example/{imx8mm_evk => }/passive_server/passive_server.system (100%) rename example/{imx8mm_evk => }/passive_server/server.c (100%) delete mode 100644 example/qemu_virt_aarch64/hello/Makefile delete mode 100644 example/qemu_virt_aarch64/hello/hello.c delete mode 100644 example/qemu_virt_aarch64/hello/hello.system delete mode 100644 example/qemu_virt_aarch64/hierarchy/hello.c delete mode 100644 example/qemu_virt_riscv64/hello/hello.c delete mode 100644 example/qemu_virt_riscv64/hello/hello.system delete mode 100644 example/rockpro64/hello/Makefile delete mode 100644 example/rockpro64/hello/hello.c delete mode 100644 example/rockpro64/hello/hello.system delete mode 100644 example/star64/hello/Makefile delete mode 100644 example/star64/hello/hello.c delete mode 100644 example/star64/hello/hello.system rename example/{odroidc4 => }/timer/Makefile (92%) create mode 100644 example/timer/README.md rename example/{odroidc4 => }/timer/timer.c (100%) rename example/{odroidc4 => }/timer/timer.system (100%) delete mode 100644 example/zcu102/hello/Makefile delete mode 100644 example/zcu102/hello/hello.c delete mode 100644 example/zcu102/hello/hello.system diff --git a/README.md b/README.md index 9141d2a8..92f0f49e 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,8 @@ LICENSE.md LICENSES/$licence.txt doc/ doc/microkit_user_manual.pdf +example/ +example/$example/ bin/ bin/microkit board/ diff --git a/build_sdk.py b/build_sdk.py index 0dfda740..07284309 100644 --- a/build_sdk.py +++ b/build_sdk.py @@ -73,7 +73,6 @@ class BoardInfo: gcc_cpu: Optional[str] loader_link_address: int kernel_options: KERNEL_OPTIONS - examples: Dict[str, Path] @dataclass @@ -96,9 +95,6 @@ class ConfigInfo: "KernelArmHypervisorSupport": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "ethernet": Path("example/tqma8xqp1gb/ethernet") - } ), BoardInfo( name="zcu102", @@ -113,9 +109,6 @@ class ConfigInfo: "KernelArmHypervisorSupport": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "hello": Path("example/zcu102/hello") - } ), BoardInfo( name="maaxboard", @@ -129,9 +122,6 @@ class ConfigInfo: "KernelArmHypervisorSupport": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "hello": Path("example/maaxboard/hello") - } ), BoardInfo( name="imx8mm_evk", @@ -145,9 +135,6 @@ class ConfigInfo: "KernelArmHypervisorSupport": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "passive_server": Path("example/imx8mm_evk/passive_server") - } ), BoardInfo( name="imx8mp_evk", @@ -161,9 +148,6 @@ class ConfigInfo: "KernelArmHypervisorSupport": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "hello": Path("example/imx8mp_evk/hello") - } ), BoardInfo( name="imx8mq_evk", @@ -177,9 +161,6 @@ class ConfigInfo: "KernelArmHypervisorSupport": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "hello": Path("example/imx8mq_evk/hello") - } ), BoardInfo( name="odroidc2", @@ -193,9 +174,6 @@ class ConfigInfo: "KernelArmHypervisorSupport": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "hello": Path("example/odroidc2/hello") - } ), BoardInfo( name="odroidc4", @@ -209,9 +187,6 @@ class ConfigInfo: "KernelArmHypervisorSupport": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "timer": Path("example/odroidc4/timer") - } ), BoardInfo( name="qemu_virt_aarch64", @@ -228,10 +203,6 @@ class ConfigInfo: "KernelArmExportPTMRUser": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "hello": Path("example/qemu_virt_aarch64/hello"), - "hierarchy": Path("example/qemu_virt_aarch64/hierarchy") - } ), BoardInfo( name="qemu_virt_riscv64", @@ -245,9 +216,6 @@ class ConfigInfo: "KernelRiscvExtD": True, "KernelRiscvExtF": True, }, - examples={ - "hello": Path("example/qemu_virt_riscv64/hello"), - } ), BoardInfo( name="rockpro64", @@ -261,9 +229,6 @@ class ConfigInfo: "KernelArmHypervisorSupport": True, "KernelArmVtimerUpdateVOffset": False, }, - examples={ - "hello": Path("example/rockpro64/hello") - } ), BoardInfo( name="star64", @@ -276,9 +241,6 @@ class ConfigInfo: "KernelRiscvExtD": True, "KernelRiscvExtF": True, }, - examples={ - "hello": Path("example/star64/hello") - } ), ) @@ -310,6 +272,15 @@ class ConfigInfo: ) +EXAMPLES={ + "hello": Path("example/hello"), + "ethernet": Path("example/ethernet"), + "passive_server": Path("example/passive_server"), + "hierarchy": Path("example/hierarchy"), + "timer": Path("example/timer"), +} + + def tar_filter(tarinfo: TarInfo) -> TarInfo: """This is used to change the tarinfo when created the .tar.gz archive. @@ -681,19 +652,20 @@ def main() -> None: build_elf_component("loader", root_dir, build_dir, board, config, loader_defines) build_elf_component("monitor", root_dir, build_dir, board, config, []) build_lib_component("libmicrokit", root_dir, build_dir, board, config) - # Setup the examples - for example, example_path in board.examples.items(): - include_dir = root_dir / "board" / board.name / "example" / example - source_dir = example_path - for p in source_dir.rglob("*"): - if not p.is_file(): - continue - rel = p.relative_to(source_dir) - dest = include_dir / rel - dest.parent.mkdir(exist_ok=True, parents=True) - dest.unlink(missing_ok=True) - copy(p, dest) - dest.chmod(0o744) + + # Setup the examples + for example, example_path in EXAMPLES.items(): + include_dir = root_dir / "example" / example + source_dir = example_path + for p in source_dir.rglob("*"): + if not p.is_file(): + continue + rel = p.relative_to(source_dir) + dest = include_dir / rel + dest.parent.mkdir(exist_ok=True, parents=True) + dest.unlink(missing_ok=True) + copy(p, dest) + dest.chmod(0o744) if not args.skip_tar: # At this point we create a tar.gz file diff --git a/dev_build.py b/dev_build.py index 28de9a04..d6c15bf6 100644 --- a/dev_build.py +++ b/dev_build.py @@ -90,9 +90,9 @@ def main(): # Choose the makefile based on the `--example-from-sdk` command line flag makefile_directory = ( - f"{release}/board/{args.board}/example/{args.example}" + f"{release}/example/{args.example}" if args.example_from_sdk - else f"{CWD.absolute()}/example/{args.board}/{args.example}" + else f"{CWD.absolute()}/example/{args.example}" ) cmd = ["make", "-C", makefile_directory] diff --git a/docs/manual.md b/docs/manual.md index 0ec7ede6..2280d4a3 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -331,7 +331,7 @@ Additionally, for each supported board configuration the following are provided: * `kernel.elf` * `monitor.elf` -For some boards there are also examples provided in the `examples` directory. +There are also examples provided in the `example` directory. The Microkit SDK does **not** provide, nor require, any specific build system. The user is free to build their system using whatever build system is deemed most appropriate for their specific use case. diff --git a/example/tqma8xqp1gb/ethernet/Makefile b/example/ethernet/Makefile similarity index 93% rename from example/tqma8xqp1gb/ethernet/Makefile rename to example/ethernet/Makefile index 2e8ebbf5..a1db90ba 100644 --- a/example/tqma8xqp1gb/ethernet/Makefile +++ b/example/ethernet/Makefile @@ -19,6 +19,10 @@ ifeq ($(strip $(MICROKIT_CONFIG)),) $(error MICROKIT_CONFIG must be specified) endif +ifneq ($(MICROKIT_BOARD),tqma8xqp1gb) +$(error Unsupported MICROKIT_BOARD given, only tqma8xqp1gb supported) +endif + TOOLCHAIN := aarch64-none-elf CPU := cortex-a35 diff --git a/example/ethernet/README.md b/example/ethernet/README.md new file mode 100644 index 00000000..cb77b75d --- /dev/null +++ b/example/ethernet/README.md @@ -0,0 +1,19 @@ + +# Example - Ethernet + +This example shows an ethernet system for the TQMa8XQP platform. +It also includes a driver for the general purpose timer on the platform. + +## Building + +```sh +mkdir build +make BUILD_DIR=build MICROKIT_BOARD=tqma8xqp1gb MICROKIT_CONFIG= MICROKIT_SDK=/path/to/sdk +``` + +## Running + +See instructions for your board in the manual. diff --git a/example/tqma8xqp1gb/ethernet/eth.c b/example/ethernet/eth.c similarity index 100% rename from example/tqma8xqp1gb/ethernet/eth.c rename to example/ethernet/eth.c diff --git a/example/tqma8xqp1gb/ethernet/ethernet.system b/example/ethernet/ethernet.system similarity index 100% rename from example/tqma8xqp1gb/ethernet/ethernet.system rename to example/ethernet/ethernet.system diff --git a/example/tqma8xqp1gb/ethernet/foo.c b/example/ethernet/foo.c similarity index 100% rename from example/tqma8xqp1gb/ethernet/foo.c rename to example/ethernet/foo.c diff --git a/example/tqma8xqp1gb/ethernet/gpt.c b/example/ethernet/gpt.c similarity index 100% rename from example/tqma8xqp1gb/ethernet/gpt.c rename to example/ethernet/gpt.c diff --git a/example/tqma8xqp1gb/ethernet/pass.c b/example/ethernet/pass.c similarity index 100% rename from example/tqma8xqp1gb/ethernet/pass.c rename to example/ethernet/pass.c diff --git a/example/qemu_virt_riscv64/hello/Makefile b/example/hello/Makefile similarity index 74% rename from example/qemu_virt_riscv64/hello/Makefile rename to example/hello/Makefile index 6b67fc73..c892a559 100644 --- a/example/qemu_virt_riscv64/hello/Makefile +++ b/example/hello/Makefile @@ -19,7 +19,20 @@ ifeq ($(strip $(MICROKIT_CONFIG)),) $(error MICROKIT_CONFIG must be specified) endif -TOOLCHAIN := riscv64-unknown-elf +BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG) + +ARCH := ${shell grep 'CONFIG_SEL4_ARCH ' $(BOARD_DIR)/include/kernel/gen_config.h | cut -d' ' -f4} + +ifeq ($(ARCH),aarch64) + TOOLCHAIN := aarch64-none-elf + # No specific AArch64 flags + CFLAGS_ARCH := +else ifeq ($(ARCH),riscv64) + TOOLCHAIN := riscv64-unknown-elf + CFLAGS_ARCH := -march=rv64imafdc_zicsr_zifencei -mabi=lp64d +else +$(error Unsupported ARCH) +endif CC := $(TOOLCHAIN)-gcc LD := $(TOOLCHAIN)-ld @@ -28,10 +41,8 @@ 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 +CFLAGS := -mstrict-align -nostdlib -ffreestanding -g -O3 -Wall -Wno-unused-function -Werror -I$(BOARD_DIR)/include $(CFLAGS_ARCH) LDFLAGS := -L$(BOARD_DIR)/lib LIBS := -lmicrokit -Tmicrokit.ld diff --git a/example/hello/README.md b/example/hello/README.md new file mode 100644 index 00000000..271e9180 --- /dev/null +++ b/example/hello/README.md @@ -0,0 +1,21 @@ + +# Example - Hello World + +This is a basic hello world example that has a single protection domain +that simply prints "hello, world!" upon initialisation. + +All supported platforms are supported in this example. + +## Building + +```sh +mkdir build +make BUILD_DIR=build MICROKIT_BOARD= MICROKIT_CONFIG= MICROKIT_SDK=/path/to/sdk +``` + +## Running + +See instructions for your board in the manual. diff --git a/example/imx8mp_evk/hello/hello.c b/example/hello/hello.c similarity index 100% rename from example/imx8mp_evk/hello/hello.c rename to example/hello/hello.c diff --git a/example/imx8mp_evk/hello/hello.system b/example/hello/hello.system similarity index 100% rename from example/imx8mp_evk/hello/hello.system rename to example/hello/hello.system diff --git a/example/qemu_virt_aarch64/hierarchy/Makefile b/example/hierarchy/Makefile similarity index 76% rename from example/qemu_virt_aarch64/hierarchy/Makefile rename to example/hierarchy/Makefile index a4c06cc4..7349bbd3 100644 --- a/example/qemu_virt_aarch64/hierarchy/Makefile +++ b/example/hierarchy/Makefile @@ -19,9 +19,20 @@ ifeq ($(strip $(MICROKIT_CONFIG)),) $(error MICROKIT_CONFIG must be specified) endif -TOOLCHAIN := aarch64-none-elf +BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG) -CPU := cortex-a53 +ARCH := ${shell grep 'CONFIG_SEL4_ARCH ' $(BOARD_DIR)/include/kernel/gen_config.h | cut -d' ' -f4} + +ifeq ($(ARCH),aarch64) + TOOLCHAIN := aarch64-none-elf + # No specific AArch64 flags + CFLAGS_ARCH := +else ifeq ($(ARCH),riscv64) + TOOLCHAIN := riscv64-unknown-elf + CFLAGS_ARCH := -march=rv64imafdc_zicsr_zifencei -mabi=lp64d +else +$(error Unsupported ARCH) +endif CC := $(TOOLCHAIN)-gcc LD := $(TOOLCHAIN)-ld @@ -32,10 +43,8 @@ RESTARTER_OBJS := restarter.o CRASHER_OBJS := crasher.o HELLO_OBJS := hello.o -BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG) - IMAGES := restarter.elf crasher.elf hello.elf -CFLAGS := -mcpu=$(CPU) -mstrict-align -nostdlib -ffreestanding -g -O3 -Wall -Wno-unused-function -Werror -I$(BOARD_DIR)/include +CFLAGS := -mstrict-align -nostdlib -ffreestanding -g -O3 -Wall -Wno-unused-function -Werror -I$(BOARD_DIR)/include $(CFLAGS_ARCH) LDFLAGS := -L$(BOARD_DIR)/lib LIBS := -lmicrokit -Tmicrokit.ld diff --git a/example/hierarchy/README.md b/example/hierarchy/README.md new file mode 100644 index 00000000..332ddc35 --- /dev/null +++ b/example/hierarchy/README.md @@ -0,0 +1,23 @@ + +# Example - Hierarchy + +This example shows off the parent/child PD concept in Microkit as +well as fault handling. The parent 'restarter' PD recieves faults +from the 'crasher' PD that is intentionally crashing and then +resets the crasher's program counter. + +All supported platforms are supported in this example. + +## Building + +```sh +mkdir build +make BUILD_DIR=build MICROKIT_BOARD= MICROKIT_CONFIG= MICROKIT_SDK=/path/to/sdk +``` + +## Running + +See instructions for your board in the manual. diff --git a/example/qemu_virt_aarch64/hierarchy/crasher.c b/example/hierarchy/crasher.c similarity index 100% rename from example/qemu_virt_aarch64/hierarchy/crasher.c rename to example/hierarchy/crasher.c diff --git a/example/imx8mp_evk/imx8mq_evk/hello/hello.c b/example/hierarchy/hello.c similarity index 100% rename from example/imx8mp_evk/imx8mq_evk/hello/hello.c rename to example/hierarchy/hello.c diff --git a/example/qemu_virt_aarch64/hierarchy/hierachy.system b/example/hierarchy/hierachy.system similarity index 100% rename from example/qemu_virt_aarch64/hierarchy/hierachy.system rename to example/hierarchy/hierachy.system diff --git a/example/qemu_virt_aarch64/hierarchy/restarter.c b/example/hierarchy/restarter.c similarity index 100% rename from example/qemu_virt_aarch64/hierarchy/restarter.c rename to example/hierarchy/restarter.c diff --git a/example/imx8mp_evk/hello/Makefile b/example/imx8mp_evk/hello/Makefile deleted file mode 100644 index b78ab030..00000000 --- a/example/imx8mp_evk/hello/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# 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/imx8mp_evk/imx8mq_evk/hello/Makefile b/example/imx8mp_evk/imx8mq_evk/hello/Makefile deleted file mode 100644 index b78ab030..00000000 --- a/example/imx8mp_evk/imx8mq_evk/hello/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# 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/imx8mp_evk/imx8mq_evk/hello/hello.system b/example/imx8mp_evk/imx8mq_evk/hello/hello.system deleted file mode 100644 index 146da4ba..00000000 --- a/example/imx8mp_evk/imx8mq_evk/hello/hello.system +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/example/imx8mq_evk/hello/Makefile b/example/imx8mq_evk/hello/Makefile deleted file mode 100644 index b78ab030..00000000 --- a/example/imx8mq_evk/hello/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# 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/imx8mq_evk/hello/hello.c b/example/imx8mq_evk/hello/hello.c deleted file mode 100644 index 493c9574..00000000 --- a/example/imx8mq_evk/hello/hello.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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) -{ -} diff --git a/example/imx8mq_evk/hello/hello.system b/example/imx8mq_evk/hello/hello.system deleted file mode 100644 index 146da4ba..00000000 --- a/example/imx8mq_evk/hello/hello.system +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/example/maaxboard/hello/Makefile b/example/maaxboard/hello/Makefile deleted file mode 100644 index e7bdffb0..00000000 --- a/example/maaxboard/hello/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# 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 -g -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) -g -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/maaxboard/hello/hello.c b/example/maaxboard/hello/hello.c deleted file mode 100644 index 9519a6cb..00000000 --- a/example/maaxboard/hello/hello.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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/maaxboard/hello/hello.system b/example/maaxboard/hello/hello.system deleted file mode 100644 index 146da4ba..00000000 --- a/example/maaxboard/hello/hello.system +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/example/odroidc2/hello/Makefile b/example/odroidc2/hello/Makefile deleted file mode 100644 index b71bb74e..00000000 --- a/example/odroidc2/hello/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# 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-a55 - -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 -g -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) -g -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/odroidc2/hello/hello.c b/example/odroidc2/hello/hello.c deleted file mode 100644 index 493c9574..00000000 --- a/example/odroidc2/hello/hello.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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) -{ -} diff --git a/example/odroidc2/hello/hello.system b/example/odroidc2/hello/hello.system deleted file mode 100644 index 146da4ba..00000000 --- a/example/odroidc2/hello/hello.system +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/example/imx8mm_evk/passive_server/Makefile b/example/passive_server/Makefile similarity index 74% rename from example/imx8mm_evk/passive_server/Makefile rename to example/passive_server/Makefile index d1a0a486..c144a0e8 100644 --- a/example/imx8mm_evk/passive_server/Makefile +++ b/example/passive_server/Makefile @@ -19,9 +19,20 @@ ifeq ($(strip $(MICROKIT_CONFIG)),) $(error MICROKIT_CONFIG must be specified) endif -TOOLCHAIN := aarch64-none-elf +BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG) -CPU := cortex-a53 +ARCH := ${shell grep 'CONFIG_SEL4_ARCH ' $(BOARD_DIR)/include/kernel/gen_config.h | cut -d' ' -f4} + +ifeq ($(ARCH),aarch64) + TOOLCHAIN := aarch64-none-elf + # No specific AArch64 flags + CFLAGS_ARCH := +else ifeq ($(ARCH),riscv64) + TOOLCHAIN := riscv64-unknown-elf + CFLAGS_ARCH := -march=rv64imafdc_zicsr_zifencei -mabi=lp64d +else +$(error Unsupported ARCH) +endif CC := $(TOOLCHAIN)-gcc LD := $(TOOLCHAIN)-ld @@ -31,10 +42,8 @@ MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit SERVER_OBJS := server.o CLIENT_OBJS := client.o -BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG) - IMAGES := server.elf client.elf -CFLAGS := -mcpu=$(CPU) -mstrict-align -nostdlib -ffreestanding -g -O3 -Wall -Wno-unused-function -Werror -I$(BOARD_DIR)/include +CFLAGS := -mstrict-align -nostdlib -ffreestanding -g -O3 -Wall -Wno-unused-function -Werror -I$(BOARD_DIR)/include $(CFLAGS_ARCH) LDFLAGS := -L$(BOARD_DIR)/lib LIBS := -lmicrokit -Tmicrokit.ld diff --git a/example/passive_server/README.md b/example/passive_server/README.md new file mode 100644 index 00000000..c4c94d86 --- /dev/null +++ b/example/passive_server/README.md @@ -0,0 +1,26 @@ + +# Example - Passive Server + +This example shows a client and server PD communicating with each +other where the server does not have an active scheduling context +and is therefore a 'passive' server. + +When the client PPCs into the server, the server is executing on +the client's budget. See the manual for more details on passive +PDs. + +All supported platforms are supported in this example. + +## Building + +```sh +mkdir build +make BUILD_DIR=build MICROKIT_BOARD= MICROKIT_CONFIG= MICROKIT_SDK=/path/to/sdk +``` + +## Running + +See instructions for your board in the manual. diff --git a/example/imx8mm_evk/passive_server/client.c b/example/passive_server/client.c similarity index 100% rename from example/imx8mm_evk/passive_server/client.c rename to example/passive_server/client.c diff --git a/example/imx8mm_evk/passive_server/passive_server.system b/example/passive_server/passive_server.system similarity index 100% rename from example/imx8mm_evk/passive_server/passive_server.system rename to example/passive_server/passive_server.system diff --git a/example/imx8mm_evk/passive_server/server.c b/example/passive_server/server.c similarity index 100% rename from example/imx8mm_evk/passive_server/server.c rename to example/passive_server/server.c diff --git a/example/qemu_virt_aarch64/hello/Makefile b/example/qemu_virt_aarch64/hello/Makefile deleted file mode 100644 index e7bdffb0..00000000 --- a/example/qemu_virt_aarch64/hello/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# 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 -g -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) -g -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/qemu_virt_aarch64/hello/hello.c b/example/qemu_virt_aarch64/hello/hello.c deleted file mode 100644 index 493c9574..00000000 --- a/example/qemu_virt_aarch64/hello/hello.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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) -{ -} diff --git a/example/qemu_virt_aarch64/hello/hello.system b/example/qemu_virt_aarch64/hello/hello.system deleted file mode 100644 index 146da4ba..00000000 --- a/example/qemu_virt_aarch64/hello/hello.system +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/example/qemu_virt_aarch64/hierarchy/hello.c b/example/qemu_virt_aarch64/hierarchy/hello.c deleted file mode 100644 index 493c9574..00000000 --- a/example/qemu_virt_aarch64/hierarchy/hello.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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) -{ -} diff --git a/example/qemu_virt_riscv64/hello/hello.c b/example/qemu_virt_riscv64/hello/hello.c deleted file mode 100644 index 493c9574..00000000 --- a/example/qemu_virt_riscv64/hello/hello.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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) -{ -} diff --git a/example/qemu_virt_riscv64/hello/hello.system b/example/qemu_virt_riscv64/hello/hello.system deleted file mode 100644 index 146da4ba..00000000 --- a/example/qemu_virt_riscv64/hello/hello.system +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/example/rockpro64/hello/Makefile b/example/rockpro64/hello/Makefile deleted file mode 100644 index e7bdffb0..00000000 --- a/example/rockpro64/hello/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# 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 -g -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) -g -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 deleted file mode 100644 index 493c9574..00000000 --- a/example/rockpro64/hello/hello.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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) -{ -} diff --git a/example/rockpro64/hello/hello.system b/example/rockpro64/hello/hello.system deleted file mode 100644 index 146da4ba..00000000 --- a/example/rockpro64/hello/hello.system +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/example/star64/hello/Makefile b/example/star64/hello/Makefile deleted file mode 100644 index 6b67fc73..00000000 --- a/example/star64/hello/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# -# 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 := 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/star64/hello/hello.c b/example/star64/hello/hello.c deleted file mode 100644 index 493c9574..00000000 --- a/example/star64/hello/hello.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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) -{ -} diff --git a/example/star64/hello/hello.system b/example/star64/hello/hello.system deleted file mode 100644 index 146da4ba..00000000 --- a/example/star64/hello/hello.system +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/example/odroidc4/timer/Makefile b/example/timer/Makefile similarity index 92% rename from example/odroidc4/timer/Makefile rename to example/timer/Makefile index 1880f8da..0a1bdbde 100644 --- a/example/odroidc4/timer/Makefile +++ b/example/timer/Makefile @@ -19,6 +19,10 @@ ifeq ($(strip $(MICROKIT_CONFIG)),) $(error MICROKIT_CONFIG must be specified) endif +ifneq ($(MICROKIT_BOARD),odroidc4) +$(error Unsupported MICROKIT_BOARD given, only odroidc4 supported) +endif + TOOLCHAIN := aarch64-none-elf CPU := cortex-a55 diff --git a/example/timer/README.md b/example/timer/README.md new file mode 100644 index 00000000..dc0b12b8 --- /dev/null +++ b/example/timer/README.md @@ -0,0 +1,21 @@ + +# Example - Timer + +This example shows a basic timer driver for the Odroid-C4 +platform. The timer driver initialises the device and then +sets a regular 1 second timeout and prints the current time +whenever the timeout expires. + +## Building + +```sh +mkdir build +make BUILD_DIR=build MICROKIT_BOARD=odroidc4 MICROKIT_CONFIG= MICROKIT_SDK=/path/to/sdk +``` + +## Running + +See instructions for your board in the manual. diff --git a/example/odroidc4/timer/timer.c b/example/timer/timer.c similarity index 100% rename from example/odroidc4/timer/timer.c rename to example/timer/timer.c diff --git a/example/odroidc4/timer/timer.system b/example/timer/timer.system similarity index 100% rename from example/odroidc4/timer/timer.system rename to example/timer/timer.system diff --git a/example/zcu102/hello/Makefile b/example/zcu102/hello/Makefile deleted file mode 100644 index e7bdffb0..00000000 --- a/example/zcu102/hello/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# 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 -g -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) -g -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/zcu102/hello/hello.c b/example/zcu102/hello/hello.c deleted file mode 100644 index 9519a6cb..00000000 --- a/example/zcu102/hello/hello.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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/zcu102/hello/hello.system b/example/zcu102/hello/hello.system deleted file mode 100644 index 146da4ba..00000000 --- a/example/zcu102/hello/hello.system +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file