From 2b8922d5c2f31f7a71d84a8aa86946cef00589de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonny=20Sv=C3=A4rd?= Date: Thu, 15 Dec 2022 12:40:00 +0100 Subject: Add custom cross compilation documentation Change-Id: I1ab89146bf897c4c35180ab09f08064511f573f8 --- README.md | 8 ++++++ cmake/toolchain/aarch64-linux-gnu-custom.cmake | 40 ++++++++++++++++++++++++++ cmake/toolchain/aarch64-linux-gnu.cmake | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 cmake/toolchain/aarch64-linux-gnu-custom.cmake diff --git a/README.md b/README.md index e8c095b..aa8cf33 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,14 @@ subsystem, consisting of an Arm Cortex-M of choice and an Arm Ethos-U NPU. The driver stack comes with a CMake based build system. A toolchain file is provided for reference how to cross compile for an Aarch64 based system. +Note that if your host system provides cross compilers and libraries of newer +versions than what is supported on your target system, you might be required to +download an older version of compilers and toolchains for your target system. +While out of scope for this README, an example +[toolchain file](cmake/toolchain/aarch64-linux-gnu-custom.cmake) is provided to +show what it could look like. Another option is to run a Docker image of an +appropriate Linux distribution suited to build for your needs. + Building the kernel modules requires a configured Linux kernel source tree. How to download and configure the Linux kernel goes beyond the scope of this readme. Please refer to the Linux kernel official documentation. diff --git a/cmake/toolchain/aarch64-linux-gnu-custom.cmake b/cmake/toolchain/aarch64-linux-gnu-custom.cmake new file mode 100644 index 0000000..2c02a76 --- /dev/null +++ b/cmake/toolchain/aarch64-linux-gnu-custom.cmake @@ -0,0 +1,40 @@ +# +# SPDX-FileCopyrightText: Copyright 2020-2022 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the License); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an AS IS BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Cross compilation example when using a custom compiler and toolchain files + +set(CMAKE_SYSTEM_NAME Generic) + +set(CMAKE_C_COMPILER /opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER /opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-g++) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_SYSTEM_PROCESSOR "aarch64") + +add_compile_options(-Wall -Wextra) + +set(CMAKE_FIND_ROOT_PATH /opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/aarch64-linux-gnu/) + +set(FIND_LIBRARY_USE_LIB64_PATHS TRUE) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + + diff --git a/cmake/toolchain/aarch64-linux-gnu.cmake b/cmake/toolchain/aarch64-linux-gnu.cmake index 6bbefb9..31fd953 100644 --- a/cmake/toolchain/aarch64-linux-gnu.cmake +++ b/cmake/toolchain/aarch64-linux-gnu.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020-2021 Arm Limited. All rights reserved. +# SPDX-FileCopyrightText: Copyright 2020-2022 Arm Limited and/or its affiliates # # SPDX-License-Identifier: Apache-2.0 # -- cgit v1.2.1