You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by le...@apache.org on 2023/01/16 13:34:15 UTC

[tvm] 01/01: Testing PR13529.

This is an automated email from the ASF dual-hosted git repository.

leandron pushed a commit to branch ci-docker-staging
in repository https://gitbox.apache.org/repos/asf/tvm.git

commit dad13d1c1bc6381c07e2cb0c4d39e92b059e8a5d
Author: Leandro Nunes <le...@arm.com>
AuthorDate: Mon Jan 16 13:32:04 2023 +0000

    Testing PR13529.
---
 apps/microtvm/cmsisnn/Makefile                     | 19 ++++++++-----
 apps/microtvm/cmsisnn/src/demo_bare_metal.c        |  4 +--
 apps/microtvm/ethosu/Makefile                      | 24 ++++++++++-------
 apps/microtvm/ethosu/src/demo_bare_metal.c         |  4 +--
 apps/microtvm/ethosu/src/demo_freertos.c           |  4 +--
 .../install/ubuntu_install_ethosu_driver_stack.sh  | 12 ++++++---
 gallery/how_to/work_with_microtvm/micro_ethosu.py  |  4 +--
 python/tvm/micro/testing/aot_test_utils.py         |  8 +++---
 tests/python/contrib/test_cmsisnn/utils.py         |  4 +--
 tests/python/contrib/test_ethosu/infra.py          |  4 +--
 tests/python/relay/aot/corstone300.mk              | 31 +++++++++++++---------
 11 files changed, 69 insertions(+), 49 deletions(-)

diff --git a/apps/microtvm/cmsisnn/Makefile b/apps/microtvm/cmsisnn/Makefile
index e7d1b7081d..3a14c46779 100644
--- a/apps/microtvm/cmsisnn/Makefile
+++ b/apps/microtvm/cmsisnn/Makefile
@@ -40,15 +40,14 @@ PKG_CFLAGS = ${PKG_COMPILE_OPTS} \
 	-I${STANDALONE_CRT_PATH}/include \
 	-I${STANDALONE_CRT_PATH}/src/runtime/crt/include \
 	-I${PWD}/include \
-	-I${CORSTONE_300_PATH} \
+	-I${ETHOSU_PLATFORM_PATH}/drivers/uart/include \
 	-I${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include/ \
 	-I${CMSIS_PATH}/CMSIS/Core/Include \
 	-I${CMSIS_NN_PATH}/Include \
 	-I${CMSIS_PATH}/CMSIS/DSP/Include \
 	-I$(abspath $(BUILD_DIR))/codegen/host/include
-CMSIS_NN_CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
-	-DTARGET_CPU=cortex-m55 \
-	-DBUILD_CMSIS_NN_FUNCTIONS=YES
+CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
+	-DTARGET_CPU=cortex-m55
 PKG_LDFLAGS = -lm -specs=nosys.specs -static -T corstone300.ld
 
 $(ifeq VERBOSE,1)
@@ -62,7 +61,7 @@ CODEGEN_SRCS = $(wildcard $(abspath $(BUILD_DIR))/codegen/host/src/*.c)
 CODEGEN_OBJS = $(subst .c,.o,$(CODEGEN_SRCS))
 CMSIS_STARTUP_SRCS = $(wildcard ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/*.c)
 CMSIS_NN_SRCS = $(shell find ${CMSIS_NN_PATH}/Source/*/*.c)
-UART_SRCS = $(wildcard ${CORSTONE_300_PATH}/*.c)
+CORSTONE_300_SRCS = $(wildcard ${CORSTONE_300_PATH}/*.c)
 
 demo: $(BUILD_DIR)/demo
 
@@ -94,9 +93,15 @@ ${BUILD_DIR}/libcmsis_nn.a: $(CMSIS_NN_SRCS)
 	$(QUIET)$(AR) -cr $(abspath $(BUILD_DIR)/libcmsis_nn.a) $(abspath $(BUILD_DIR))/libcmsis_nn/*.o
 	$(QUIET)$(RANLIB) $(abspath $(BUILD_DIR)/libcmsis_nn.a)
 
+# Build UART driver
+${BUILD_DIR}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a:
+	$(QUIET)mkdir -p $(@D)
+	$(QUIET)cd ${ETHOSU_PLATFORM_PATH}/drivers/uart && $(CMAKE) -B $(abspath $(BUILD_DIR)/ethosu_core_platform) $(CMAKE_FLAGS)
+	$(QUIET)cd $(abspath $(BUILD_DIR)/ethosu_core_platform) && $(MAKE)
+
 # Build demo application
-$(BUILD_DIR)/demo: $(DEMO_MAIN) $(UART_SRCS) $(BUILD_DIR)/stack_allocator.o $(BUILD_DIR)/crt_backend_api.o \
-	${BUILD_DIR}/libcodegen.a ${BUILD_DIR}/libcmsis_startup.a ${BUILD_DIR}/libcmsis_nn.a
+$(BUILD_DIR)/demo: $(DEMO_MAIN) $(CORSTONE_300_SRCS) $(BUILD_DIR)/stack_allocator.o $(BUILD_DIR)/crt_backend_api.o \
+	${BUILD_DIR}/libcodegen.a ${BUILD_DIR}/libcmsis_startup.a ${BUILD_DIR}/libcmsis_nn.a ${BUILD_DIR}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a
 	$(QUIET)mkdir -p $(@D)
 	$(QUIET)$(CC) $(PKG_CFLAGS) $(FREERTOS_FLAGS) -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive $(PKG_LDFLAGS)
 
diff --git a/apps/microtvm/cmsisnn/src/demo_bare_metal.c b/apps/microtvm/cmsisnn/src/demo_bare_metal.c
index f17fe859f2..80b298d8b2 100644
--- a/apps/microtvm/cmsisnn/src/demo_bare_metal.c
+++ b/apps/microtvm/cmsisnn/src/demo_bare_metal.c
@@ -21,14 +21,14 @@
 #include <tvm_runtime.h>
 #include <tvmgen_detection.h>
 
-#include "uart.h"
+#include "uart_stdout.h"
 
 // Header files generated by convert_image.py
 #include "inputs.h"
 #include "outputs.h"
 
 int main(int argc, char** argv) {
-  uart_init();
+  UartStdOutInit();
   printf("Starting Demo\n");
 
   printf("Running detection inference\n");
diff --git a/apps/microtvm/ethosu/Makefile b/apps/microtvm/ethosu/Makefile
index 63f8adbc27..f28777470e 100644
--- a/apps/microtvm/ethosu/Makefile
+++ b/apps/microtvm/ethosu/Makefile
@@ -41,20 +41,18 @@ PKG_CFLAGS = ${PKG_COMPILE_OPTS} \
 	-I${STANDALONE_CRT_PATH}/include \
 	-I${STANDALONE_CRT_PATH}/src/runtime/crt/include \
 	-I${PWD}/include \
-	-I${CORSTONE_300_PATH} \
-	-I${ETHOSU_PATH}/core_driver/include \
+	-I${ETHOSU_DRIVER_PATH}/include \
+	-I${ETHOSU_PLATFORM_PATH}/drivers/uart/include \
 	-I${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include/ \
 	-I${CMSIS_PATH}/CMSIS/Core/Include \
 	-I${CMSIS_NN_PATH}/Include \
 	-I${CMSIS_PATH}/CMSIS/DSP/Include \
 	-I$(abspath $(BUILD_DIR))/codegen/host/include \
 	-DETHOSU_TEST_RUNNER_TOL=${ETHOSU_TEST_RUNNER_TOL}
-DRIVER_CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
-	-DETHOSU_LOG_SEVERITY=debug \
-	-DCMAKE_SYSTEM_PROCESSOR=cortex-m55
-CMSIS_NN_CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
-	-DTARGET_CPU=cortex-m55 \
-	-DBUILD_CMSIS_NN_FUNCTIONS=YES
+CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR))/../arm-none-eabi-gcc.cmake \
+	-DTARGET_CPU=cortex-m55
+DRIVER_CMAKE_FLAGS = $(CMAKE_FLAGS) \
+	-DETHOSU_LOG_SEVERITY=debug
 PKG_LDFLAGS = -lm -specs=nosys.specs -static -T corstone300.ld
 
 $(ifeq VERBOSE,1)
@@ -84,7 +82,7 @@ CODEGEN_SRCS = $(wildcard $(abspath $(BUILD_DIR))/codegen/host/src/*.c)
 CODEGEN_OBJS = $(subst .c,.o,$(CODEGEN_SRCS))
 CMSIS_STARTUP_SRCS = $(wildcard ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/*.c)
 CMSIS_NN_SOFTMAX_SRCS = $(shell find ${CMSIS_NN_PATH}/Source/SoftmaxFunctions/*.c)
-UART_SRCS = $(wildcard ${CORSTONE_300_PATH}/*.c)
+CORSTONE_300_SRCS = $(wildcard ${CORSTONE_300_PATH}/*.c)
 
 demo: $(BUILD_DIR)/demo
 
@@ -122,7 +120,13 @@ ${BUILD_DIR}/libcmsis_nn_softmax.a: $(CMSIS_NN_SOFTMAX_SRCS)
 	$(QUIET)$(AR) -cr $(abspath $(BUILD_DIR)/libcmsis_nn_softmax.a) $(abspath $(BUILD_DIR))/libcmsis_nn/*.o
 	$(QUIET)$(RANLIB) $(abspath $(BUILD_DIR)/libcmsis_nn_softmax.a)
 
-$(BUILD_DIR)/demo: $(DEMO_MAIN) src/tvm_ethosu_runtime.c $(FREERTOS_SOURCES) $(UART_SRCS) $(BUILD_DIR)/stack_allocator.o $(BUILD_DIR)/crt_backend_api.o ${BUILD_DIR}/libcodegen.a ${BUILD_DIR}/libcmsis_startup.a ${BUILD_DIR}/ethosu_core_driver/libethosu_core_driver.a ${BUILD_DIR}/libcmsis_nn_softmax.a
+# Build UART driver
+${BUILD_DIR}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a:
+	$(QUIET)mkdir -p $(@D)
+	$(QUIET)cd ${ETHOSU_PLATFORM_PATH}/drivers/uart && $(CMAKE) -B $(abspath $(BUILD_DIR)/ethosu_core_platform) $(CMAKE_FLAGS)
+	$(QUIET)cd $(abspath $(BUILD_DIR)/ethosu_core_platform) && $(MAKE)
+
+$(BUILD_DIR)/demo: $(DEMO_MAIN) src/tvm_ethosu_runtime.c $(FREERTOS_SOURCES) $(CORSTONE_300_SRCS) $(BUILD_DIR)/stack_allocator.o $(BUILD_DIR)/crt_backend_api.o ${BUILD_DIR}/libcodegen.a ${BUILD_DIR}/libcmsis_startup.a ${BUILD_DIR}/ethosu_core_driver/libethosu_core_driver.a ${BUILD_DIR}/libcmsis_nn_softmax.a ${BUILD_DIR}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a
 	$(QUIET)mkdir -p $(@D)
 	$(QUIET)$(CC) $(PKG_CFLAGS) $(FREERTOS_FLAGS) -o $@ $^ $(PKG_LDFLAGS)
 
diff --git a/apps/microtvm/ethosu/src/demo_bare_metal.c b/apps/microtvm/ethosu/src/demo_bare_metal.c
index febc212129..1bef90cfb3 100644
--- a/apps/microtvm/ethosu/src/demo_bare_metal.c
+++ b/apps/microtvm/ethosu/src/demo_bare_metal.c
@@ -21,7 +21,7 @@
 #include <tvm_runtime.h>
 
 #include "ethosu_mod.h"
-#include "uart.h"
+#include "uart_stdout.h"
 
 // Header files generated by convert_image.py and convert_labels.py
 #include "inputs.h"
@@ -31,7 +31,7 @@
 int abs(int v) { return v * ((v > 0) - (v < 0)); }
 
 int main(int argc, char** argv) {
-  uart_init();
+  UartStdOutInit();
   printf("Starting Demo\n");
   EthosuInit();
 
diff --git a/apps/microtvm/ethosu/src/demo_freertos.c b/apps/microtvm/ethosu/src/demo_freertos.c
index 4fa363a50e..e59d7aeacc 100644
--- a/apps/microtvm/ethosu/src/demo_freertos.c
+++ b/apps/microtvm/ethosu/src/demo_freertos.c
@@ -24,7 +24,7 @@
 #include <tvm_runtime.h>
 
 #include "ethosu_mod.h"
-#include "uart.h"
+#include "uart_stdout.h"
 
 // Header files generated by convert_image.py and convert_labels.py
 #include "inputs.h"
@@ -46,7 +46,7 @@ static QueueHandle_t xQueue = NULL;
 
 int main(void) {
   // Platform UART
-  uart_init();
+  UartStdOutInit();
   // NPU
   EthosuInit();
 
diff --git a/docker/install/ubuntu_install_ethosu_driver_stack.sh b/docker/install/ubuntu_install_ethosu_driver_stack.sh
index 0fb35b13e7..b86569e3a9 100755
--- a/docker/install/ubuntu_install_ethosu_driver_stack.sh
+++ b/docker/install/ubuntu_install_ethosu_driver_stack.sh
@@ -23,7 +23,7 @@ set -o pipefail
 fvp_dir="/opt/arm/FVP_Corstone_SSE-300"
 cmake_dir="/opt/arm/cmake"
 ethosu_dir="/opt/arm/ethosu"
-ethosu_driver_ver="21.11"
+ethosu_driver_ver="22.08"
 
 mkdir -p /opt/arm
 
@@ -80,9 +80,13 @@ git clone --branch ${ethosu_driver_ver} "https://review.mlplatform.org/ml/ethos-
 git clone --branch ${ethosu_driver_ver} "https://review.mlplatform.org/ml/ethos-u/ethos-u-core-platform" core_platform
 
 # Build Driver
-mkdir ${ethosu_dir}/core_driver/build && cd ${ethosu_dir}/core_driver/build
-cmake -DCMAKE_TOOLCHAIN_FILE=${ethosu_dir}/core_platform/cmake/toolchain/arm-none-eabi-gcc.cmake -DETHOSU_LOG_SEVERITY=debug -DTARGET_CPU=cortex-m55 ..
-make
+NPU_VARIANTS=("u55" "u65")
+for i in ${NPU_VARIANTS[*]}
+do
+    mkdir ${ethosu_dir}/core_driver/build_${i} && cd ${ethosu_dir}/core_driver/build_${i}
+    cmake -DCMAKE_TOOLCHAIN_FILE=${ethosu_dir}/core_platform/cmake/toolchain/arm-none-eabi-gcc.cmake -DETHOSU_LOG_SEVERITY=debug -DTARGET_CPU=cortex-m55 -DETHOSU_TARGET_NPU_CONFIG=ethos-${i}-128 ..
+    make
+done
 
 # Build NN Library
 mkdir ${CMSIS_PATH}/CMSIS-NN/build/ && cd ${CMSIS_PATH}/CMSIS-NN/build/
diff --git a/gallery/how_to/work_with_microtvm/micro_ethosu.py b/gallery/how_to/work_with_microtvm/micro_ethosu.py
index f257507bb5..74a9d59d77 100644
--- a/gallery/how_to/work_with_microtvm/micro_ethosu.py
+++ b/gallery/how_to/work_with_microtvm/micro_ethosu.py
@@ -380,7 +380,7 @@ TVM to offload operators to the Ethos(TM)-U55 where possible.
 #     #include <tvm_runtime.h>
 #
 #     #include "ethosu_mod.h"
-#     #include "uart.h"
+#     #include "uart_stdout.h"
 #
 #     // Header files generated by convert_image.py and convert_labels.py
 #     #include "inputs.h"
@@ -390,7 +390,7 @@ TVM to offload operators to the Ethos(TM)-U55 where possible.
 #     int abs(int v) { return v * ((v > 0) - (v < 0)); }
 #
 #     int main(int argc, char** argv) {
-#       uart_init();
+#       UartStdOutInit();
 #       printf("Starting Demo\n");
 #       EthosuInit();
 #
diff --git a/python/tvm/micro/testing/aot_test_utils.py b/python/tvm/micro/testing/aot_test_utils.py
index 89c08395de..06cd0f1c9e 100644
--- a/python/tvm/micro/testing/aot_test_utils.py
+++ b/python/tvm/micro/testing/aot_test_utils.py
@@ -41,9 +41,9 @@ AOT_DEFAULT_RUNNER = AOTTestRunner()
 AOT_CORSTONE300_RUNNER = AOTTestRunner(
     makefile="corstone300",
     prologue="""
-    uart_init();
+    UartStdOutInit();
     """,
-    includes=["uart.h"],
+    includes=["uart_stdout.h"],
     pass_config={
         "relay.ext.cmsisnn.options": {
             "mcpu": "cortex-m55",
@@ -54,9 +54,9 @@ AOT_CORSTONE300_RUNNER = AOTTestRunner(
 AOT_USMP_CORSTONE300_RUNNER = AOTTestRunner(
     makefile="corstone300",
     prologue="""
-    uart_init();
+    UartStdOutInit();
     """,
-    includes=["uart.h"],
+    includes=["uart_stdout.h"],
     pass_config={
         "relay.ext.cmsisnn.options": {
             "mcpu": "cortex-m55",
diff --git a/tests/python/contrib/test_cmsisnn/utils.py b/tests/python/contrib/test_cmsisnn/utils.py
index 1ec3e609f1..74d9686a78 100644
--- a/tests/python/contrib/test_cmsisnn/utils.py
+++ b/tests/python/contrib/test_cmsisnn/utils.py
@@ -274,9 +274,9 @@ def create_test_runner(compiler_cpu="cortex-m55", cpu_flags=""):
     return AOTTestRunner(
         makefile="corstone300",
         prologue="""
-        uart_init();
+        UartStdOutInit();
         """,
-        includes=["uart.h"],
+        includes=["uart_stdout.h"],
         pass_config={
             "relay.ext.cmsisnn.options": {
                 "mcpu": compiler_cpu + cpu_flags,
diff --git a/tests/python/contrib/test_ethosu/infra.py b/tests/python/contrib/test_ethosu/infra.py
index b2bbcd377b..efab6e6911 100644
--- a/tests/python/contrib/test_ethosu/infra.py
+++ b/tests/python/contrib/test_ethosu/infra.py
@@ -133,7 +133,7 @@ def create_test_runner(
     ethosu_variant = ethosu_variant.upper()
 
     prologue = """
-    uart_init();
+    UartStdOutInit();
     EthosuInit();
 
     struct ethosu_driver* ethos_u = ethosu_reserve_driver();
@@ -158,7 +158,7 @@ def create_test_runner(
         epilogue="""
         ethosu_release_driver(ethos_u);
         """,
-        includes=["uart.h", "ethosu_55.h", "ethosu_mod.h", "hard_fault.h"],
+        includes=["uart_stdout.h", "ethosu_55.h", "ethosu_mod.h", "hard_fault.h"],
         parameters={
             "ETHOSU_TEST_ROOT": test_root,
             "NPU_MACS": ethosu_macs,
diff --git a/tests/python/relay/aot/corstone300.mk b/tests/python/relay/aot/corstone300.mk
index ebda50d9cf..f968a231af 100644
--- a/tests/python/relay/aot/corstone300.mk
+++ b/tests/python/relay/aot/corstone300.mk
@@ -41,7 +41,8 @@ DMLC_CORE=${TVM_ROOT}/3rdparty/dmlc-core
 ETHOSU_PATH=/opt/arm/ethosu
 DRIVER_PATH=${ETHOSU_PATH}/core_driver
 CMSIS_PATH=${ETHOSU_PATH}/cmsis
-PLATFORM_PATH=${ETHOSU_PATH}/core_platform/targets/corstone-300
+ETHOSU_PLATFORM_PATH=/opt/arm/ethosu/core_platform
+CORSTONE_300_PATH = ${ETHOSU_PLATFORM_PATH}/targets/corstone-300
 PKG_COMPILE_OPTS = -g -Wall -O2 -Wno-incompatible-pointer-types -Wno-format -Werror-implicit-function-declaration -mcpu=${MCPU}${MCPU_FLAGS} -mthumb -mfloat-abi=${MFLOAT_ABI} -std=gnu99
 CMAKE = /opt/arm/cmake/bin/cmake
 CC = arm-none-eabi-gcc
@@ -58,15 +59,14 @@ PKG_CFLAGS = ${PKG_COMPILE_OPTS} \
 	-I$(build_dir)/../include \
 	-I${TVM_ROOT}/src/runtime/contrib/ethosu/bare_metal \
 	-I$(CODEGEN_ROOT)/host/include \
-	-I${PLATFORM_PATH} \
+	-I${ETHOSU_PLATFORM_PATH}/drivers/uart/include \
 	-I${DRIVER_PATH}/include \
 	-I${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include/ \
 	-I${CMSIS_PATH}/CMSIS/Core/Include \
 	-I${CMSIS_NN_PATH}/Include \
 	-I${CMSIS_PATH}/CMSIS/DSP/Include \
 	-isystem$(STANDALONE_CRT_DIR)/include
-DRIVER_CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=$(ETHOSU_TEST_ROOT)/arm-none-eabi-gcc.cmake \
-	-DETHOSU_LOG_SEVERITY=debug \
+CMAKE_FLAGS = -DCMAKE_TOOLCHAIN_FILE=${TVM_ROOT}/tests/python/contrib/test_ethosu/reference_system/arm-none-eabi-gcc.cmake \
 	-DCMAKE_SYSTEM_PROCESSOR=cortex-m55
 
 PKG_LDFLAGS = -lm -specs=nosys.specs -static -T ${AOT_TEST_ROOT}/corstone300.ld
@@ -84,10 +84,11 @@ C_CODEGEN_OBJS = $(subst .c,.o,$(C_CODEGEN_SRCS))
 CC_CODEGEN_OBJS = $(subst .cc,.o,$(CC_CODEGEN_SRCS))
 CMSIS_STARTUP_SRCS = $(shell find ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/*.c)
 CMSIS_NN_SRCS = $(shell find ${CMSIS_NN_PATH}/Source/*/*.c)
-UART_SRCS = $(shell find ${PLATFORM_PATH}/*.c)
+CORSTONE_300_SRCS = $(shell find ${CORSTONE_300_PATH}/*.c)
 
 ifdef ETHOSU_TEST_ROOT
-ETHOSU_DRIVER_LIBS = $(wildcard ${DRIVER_PATH}/build/*.a)
+NPU=$(shell echo "${NPU_VARIANT}" | tr '[:upper:]' '[:lower:]')
+ETHOSU_DRIVER_LIBS = ${DRIVER_PATH}/build_${NPU}/*.a
 ETHOSU_RUNTIME=$(build_dir)/tvm_ethosu_runtime.o
 ETHOSU_INCLUDE=-I$(ETHOSU_TEST_ROOT)
 endif
@@ -123,13 +124,19 @@ ${build_dir}/libcmsis_nn.a: $(CMSIS_NN_SRCS)
 	$(QUIET)$(AR) -cr $(abspath $(build_dir)/libcmsis_nn.a) $(abspath $(build_dir))/libcmsis_nn/*.o
 	$(QUIET)$(RANLIB) $(abspath $(build_dir)/libcmsis_nn.a)
 
-${build_dir}/libuart.a: $(UART_SRCS)
-	$(QUIET)mkdir -p $(abspath $(build_dir)/libuart)
-	$(QUIET)cd $(abspath $(build_dir)/libuart) && $(CC) -c $(PKG_CFLAGS) $^
-	$(QUIET)$(AR) -cr $(abspath $(build_dir)/libuart.a) $(abspath $(build_dir))/libuart/*.o
-	$(QUIET)$(RANLIB) $(abspath $(build_dir)/libuart.a)
+${build_dir}/libcorstone.a: $(CORSTONE_300_SRCS)
+	$(QUIET)mkdir -p $(abspath $(build_dir)/libcorstone)
+	$(QUIET)cd $(abspath $(build_dir)/libcorstone) && $(CC) -c $(PKG_CFLAGS) $^
+	$(QUIET)$(AR) -cr $(abspath $(build_dir)/libcorstone.a) $(abspath $(build_dir))/libcorstone/*.o
+	$(QUIET)$(RANLIB) $(abspath $(build_dir)/libcorstone.a)
 
-$(build_dir)/aot_test_runner: $(build_dir)/test.c $(build_dir)/crt_backend_api.o $(build_dir)/stack_allocator.o $(build_dir)/libcodegen.a ${build_dir}/libcmsis_startup.a ${build_dir}/libcmsis_nn.a ${build_dir}/libuart.a $(ETHOSU_DRIVER_LIBS) $(ETHOSU_RUNTIME)
+# Build UART driver
+${build_dir}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a:
+	$(QUIET)mkdir -p $(@D)
+	$(QUIET)cd ${ETHOSU_PLATFORM_PATH}/drivers/uart && $(CMAKE) -B $(abspath $(build_dir)/ethosu_core_platform) $(CMAKE_FLAGS)
+	$(QUIET)cd $(abspath $(build_dir)/ethosu_core_platform) && $(MAKE)
+
+$(build_dir)/aot_test_runner: $(build_dir)/test.c $(build_dir)/crt_backend_api.o $(build_dir)/stack_allocator.o $(build_dir)/libcodegen.a ${build_dir}/libcmsis_startup.a ${build_dir}/libcmsis_nn.a ${build_dir}/libcorstone.a ${build_dir}/ethosu_core_platform/libethosu_uart_cmsdk_apb.a $(ETHOSU_DRIVER_LIBS) $(ETHOSU_RUNTIME)
 	$(QUIET)mkdir -p $(@D)
 	$(QUIET)$(CC) $(PKG_CFLAGS) $(ETHOSU_INCLUDE) -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive $(PKG_LDFLAGS)