From c503b0023cc2e75a026cbe73908c66866acabea9 Mon Sep 17 00:00:00 2001 From: svad05 Date: Fri, 8 Jul 2022 16:39:20 +0300 Subject: [PATCH] =?UTF-8?q?dev(none):=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B2=D0=BD=D0=B5=D1=88=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../p-net/cmake/tools/AddGoogleTest.cmake | 86 ++++++++++++++ .../p-net/cmake/tools/AddOsal.cmake | 63 ++++++++++ .../p-net/cmake/tools/FindSphinx.cmake | 16 +++ .../p-net/cmake/tools/GetGitRevision.cmake | 25 ++++ profinet_stack/p-net/cmake/tools/LICENSE | 29 +++++ .../cmake/tools/Platform/STM32Cube.cmake | 80 +++++++++++++ .../cmake/tools/Platform/rt-kernel.cmake | 111 ++++++++++++++++++ profinet_stack/p-net/cmake/tools/README.md | 5 + .../cmake/tools/toolchain/arm7tdmi.cmake | 17 +++ .../cmake/tools/toolchain/arm926ej-s.cmake | 16 +++ .../tools/toolchain/cortex-a8-neon.cmake | 17 +++ .../cmake/tools/toolchain/cortex-a8.cmake | 16 +++ .../cmake/tools/toolchain/cortex-a9-vfp.cmake | 17 +++ .../cmake/tools/toolchain/cortex-a9.cmake | 16 +++ .../cmake/tools/toolchain/cortex-m3.cmake | 17 +++ .../cmake/tools/toolchain/cortex-m4.cmake | 17 +++ .../cmake/tools/toolchain/cortex-m4f.cmake | 18 +++ .../cmake/tools/toolchain/cortex-m7f.cmake | 18 +++ .../cmake/tools/toolchain/cortex-m7fd.cmake | 18 +++ .../cmake/tools/toolchain/cortex-r5-vfp.cmake | 18 +++ .../p-net/cmake/tools/toolchain/e200.cmake | 18 +++ .../p-net/cmake/tools/toolchain/ppc604.cmake | 19 +++ .../cmake/tools/toolchain/rt-kernel.cmake | 92 +++++++++++++++ .../cmake/tools/toolchain/stm32cube.cmake | 54 +++++++++ 24 files changed, 803 insertions(+) create mode 100644 profinet_stack/p-net/cmake/tools/AddGoogleTest.cmake create mode 100644 profinet_stack/p-net/cmake/tools/AddOsal.cmake create mode 100644 profinet_stack/p-net/cmake/tools/FindSphinx.cmake create mode 100644 profinet_stack/p-net/cmake/tools/GetGitRevision.cmake create mode 100644 profinet_stack/p-net/cmake/tools/LICENSE create mode 100644 profinet_stack/p-net/cmake/tools/Platform/STM32Cube.cmake create mode 100644 profinet_stack/p-net/cmake/tools/Platform/rt-kernel.cmake create mode 100644 profinet_stack/p-net/cmake/tools/README.md create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/arm7tdmi.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/arm926ej-s.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-a8-neon.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-a8.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-a9-vfp.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-a9.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-m3.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-m4.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-m4f.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-m7f.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-m7fd.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/cortex-r5-vfp.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/e200.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/ppc604.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/rt-kernel.cmake create mode 100644 profinet_stack/p-net/cmake/tools/toolchain/stm32cube.cmake diff --git a/profinet_stack/p-net/cmake/tools/AddGoogleTest.cmake b/profinet_stack/p-net/cmake/tools/AddGoogleTest.cmake new file mode 100644 index 0000000..7cb17a2 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/AddGoogleTest.cmake @@ -0,0 +1,86 @@ + +cmake_minimum_required(VERSION 3.14) + +if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + # gtest doesn't build on older GCC + message(FATAL_ERROR + "GTest needs at least GCC version 5. Set BUILD_TESTING=OFF to disable tests.") +endif() + +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +if (CMAKE_SYSTEM_NAME STREQUAL rt-kernel) + set(gtest_disable_pthreads ON CACHE BOOL "" FORCE) + list(APPEND GTEST_COMPILE_OPTIONS + -D_POSIX_C_SOURCE=200809L + -Wno-psabi + ) +endif() +if (CMAKE_SYSTEM_NAME STREQUAL STM32Cube) + set(gtest_disable_pthreads ON CACHE BOOL "" FORCE) + list(APPEND GTEST_COMPILE_OPTIONS + -D_POSIX_C_SOURCE=200809L + -Wno-psabi + -D_POSIX_PATH_MAX=80 + ) +endif() + +include(FetchContent) +FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/rtlabs-com/googletest.git + GIT_TAG 25808659d317cb03409e7949914b274e10e6824f + ) +FetchContent_GetProperties(googletest) +if(NOT googletest_POPULATED) + FetchContent_Populate(googletest) + set(INSTALL_GTEST OFF CACHE BOOL "") + add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL) + target_compile_options(gtest PRIVATE ${GTEST_COMPILE_OPTIONS}) +endif() + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} + --force-new-ctest-process + --output-on-failure + --build-config "$") +set_target_properties(check PROPERTIES FOLDER "Scripts") + +if(GOOGLE_TEST_INDIVIDUAL) + include(GoogleTest) +endif() + +macro(add_gtest TESTNAME) + target_link_libraries(${TESTNAME} PUBLIC gtest) + + if (BUILD_GMOCK) + target_link_libraries(${TESTNAME} PUBLIC gmock) + endif() + + if(GOOGLE_TEST_INDIVIDUAL) + gtest_discover_tests(${TESTNAME} + TEST_PREFIX "${TESTNAME}." + PROPERTIES FOLDER "Tests") + else() + add_test(${TESTNAME} ${TESTNAME}) + set_target_properties(${TESTNAME} PROPERTIES FOLDER "Tests") + endif() + +endmacro() + +mark_as_advanced( + gmock_build_tests + gtest_build_samples + gtest_build_tests + gtest_disable_pthreads + gtest_force_shared_crt + gtest_hide_internal_symbols + BUILD_GMOCK + BUILD_GTEST + ) + +set_target_properties(gtest gtest_main + PROPERTIES FOLDER "Extern") + +if(BUILD_GMOCK) + set_target_properties(gmock gmock_main + PROPERTIES FOLDER "Extern") +endif() diff --git a/profinet_stack/p-net/cmake/tools/AddOsal.cmake b/profinet_stack/p-net/cmake/tools/AddOsal.cmake new file mode 100644 index 0000000..eb18584 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/AddOsal.cmake @@ -0,0 +1,63 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# www.rt-labs.com +# Copyright 2020 rt-labs AB, Sweden. +# +# This software is licensed under the terms of the BSD 3-clause +# license. See the file LICENSE distributed with this software for +# full license information. +#*******************************************************************/ + +# Find OSAL library. This module supports three use-cases: +# +# 1) OSAL sibling project +# +# If a target named OSAL exists then this module does nothing. This +# would be the case if OSAL is managed by a superproject. +# +# 2) External OSAL +# +# Search for and use an external OSAL. CMake will find the external +# OSAL library if it is installed in a default location such as +# /usr/include or /usr/local/include. You can also give a search hint +# by setting the Osal_DIR variable. This could be the case for a +# native build or a cross-compiled Linux system with a staging folder. +# +# 3) Automatic download and build of OSAL +# +# Finally, if OSAL is not found in the system it will be downloaded +# and built automatically. + +cmake_minimum_required(VERSION 3.14) + +if (NOT TARGET osal) + # Attempt to find externally built OSAL + find_package(Osal QUIET) + + if (NOT Osal_FOUND) + # Download and build OSAL locally as a static library + include(FetchContent) + FetchContent_Declare( + osal + GIT_REPOSITORY https://github.com/rtlabs-com/osal.git + GIT_TAG e960068 + ) + FetchContent_GetProperties(osal) + if(NOT osal_POPULATED) + FetchContent_Populate(osal) + set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) + set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE) + add_subdirectory(${osal_SOURCE_DIR} ${osal_BINARY_DIR} EXCLUDE_FROM_ALL) + set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE BOOL "" FORCE) + endif() + + # Hide Osal_DIR to avoid confusion, as it is not used in this + # configuration + mark_as_advanced(Osal_DIR) + endif() +endif() diff --git a/profinet_stack/p-net/cmake/tools/FindSphinx.cmake b/profinet_stack/p-net/cmake/tools/FindSphinx.cmake new file mode 100644 index 0000000..e2f884a --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/FindSphinx.cmake @@ -0,0 +1,16 @@ + +# Look for an executable called sphinx-build +find_program( + SPHINX_EXECUTABLE + NAMES sphinx-build + DOC "Path to sphinx-build executable" + ) + +include(FindPackageHandleStandardArgs) + +# Handle standard arguments to find_package like REQUIRED and QUIET +find_package_handle_standard_args( + Sphinx + "Failed to find sphinx-build executable" + SPHINX_EXECUTABLE + ) diff --git a/profinet_stack/p-net/cmake/tools/GetGitRevision.cmake b/profinet_stack/p-net/cmake/tools/GetGitRevision.cmake new file mode 100644 index 0000000..d008332 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/GetGitRevision.cmake @@ -0,0 +1,25 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# www.rt-labs.com +# Copyright 2020 rt-labs AB, Sweden. +# +# This software is licensed under the terms of the BSD 3-clause +# license. See the file LICENSE distributed with this software for +# full license information. +#*******************************************************************/ + +# Get git revision if available, as projectname_GIT_REVISION + +find_package(Git QUIET) +execute_process(COMMAND + "${GIT_EXECUTABLE}" describe --tags --always --dirty + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + OUTPUT_VARIABLE "${CMAKE_PROJECT_NAME}_GIT_REVISION" + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) diff --git a/profinet_stack/p-net/cmake/tools/LICENSE b/profinet_stack/p-net/cmake/tools/LICENSE new file mode 100644 index 0000000..428ce36 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2020, rt-labs AB +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/profinet_stack/p-net/cmake/tools/Platform/STM32Cube.cmake b/profinet_stack/p-net/cmake/tools/Platform/STM32Cube.cmake new file mode 100644 index 0000000..b0630e3 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/Platform/STM32Cube.cmake @@ -0,0 +1,80 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# www.rt-labs.com +# Copyright 2021 rt-labs AB, Sweden. +# +# This software is licensed under the terms of the BSD 3-clause +# license. See the file LICENSE distributed with this software for +# full license information. +#*******************************************************************/ + +include_guard() +cmake_minimum_required (VERSION 3.1.2) +enable_language(ASM) + +# Avoid warning when re-running cmake +set(DUMMY ${CMAKE_TOOLCHAIN_FILE}) + +# No support for shared libs +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) + +set(UNIX 1) +set(CMAKE_STATIC_LIBRARY_PREFIX "lib") +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") +set(CMAKE_EXECUTABLE_SUFFIX ".elf") + +# Do not build executables during configuration stage. Required +# libraries may not be built yet. +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +# Prefer standard extensions +set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1) +set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1) +set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1) + +# Add machine-specific flags +add_definitions(${MACHINE}) +add_link_options(${MACHINE}) + +# Common flags +add_definitions( + -fdata-sections + -ffunction-sections + ) + +# Common includes +list (APPEND INCLUDES + # nothing yet + ) + +set(CMAKE_ASM_STANDARD_INCLUDE_DIRECTORIES ${INCLUDES}) +set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${INCLUDES}) +set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${INCLUDES}) + +# Linker flags +add_link_options( + -Wl,--gc-sections + ) + +# Libraries +list (APPEND LIBS + -lc + -lm + -lnosys + ) +list(JOIN LIBS " " LIBS) # Convert list to space separated string +set(CMAKE_C_STANDARD_LIBRARIES ${LIBS}) +set(CMAKE_CXX_STANDARD_LIBRARIES "${LIBS} -lstdc++") + +# Macro to add .bin output +macro(generate_bin TARGET) + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND ${OBJCOPY} + ARGS -O binary ${TARGET}.elf ${TARGET}.bin + ) +endmacro() diff --git a/profinet_stack/p-net/cmake/tools/Platform/rt-kernel.cmake b/profinet_stack/p-net/cmake/tools/Platform/rt-kernel.cmake new file mode 100644 index 0000000..39393a4 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/Platform/rt-kernel.cmake @@ -0,0 +1,111 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# www.rt-labs.com +# Copyright 2017 rt-labs AB, Sweden. +# +# This software is licensed under the terms of the BSD 3-clause +# license. See the file LICENSE distributed with this software for +# full license information. +#*******************************************************************/ + +include_guard() +cmake_minimum_required (VERSION 3.1.2) + +# Avoid warning when re-running cmake +set(DUMMY ${CMAKE_TOOLCHAIN_FILE}) + +# No support for shared libs +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) + +set(UNIX 1) +set(CMAKE_STATIC_LIBRARY_PREFIX "lib") +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") +set(CMAKE_EXECUTABLE_SUFFIX ".elf") + +# Do not build executables during configuration stage. Required +# libraries may not be built yet. +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +# Prefer standard extensions +set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1) +set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1) +set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1) + +# Add machine-specific flags +add_definitions(${MACHINE}) +add_link_options(${MACHINE}) + +if (NOT ${VARIANT} STREQUAL "") + add_definitions(-D${VARIANT}) +endif() + +# Common flags +add_definitions( + -ffunction-sections + -fomit-frame-pointer + -fno-strict-aliasing + -fshort-wchar + ) + +# Common includes +list (APPEND INCLUDES + ${RTK}/bsp/${BSP}/include + ${RTK}/include + ${RTK}/include/arch/${ARCH} + ${RTK}/lwip/src/include + ) +set(CMAKE_ASM_STANDARD_INCLUDE_DIRECTORIES ${INCLUDES}) +set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${INCLUDES}) +set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${INCLUDES}) + +# Linker flags +add_link_options( + -nostartfiles + -L${RTK}/lib/${ARCH}/${VARIANT}/${CPU} + -T${RTK}/bsp/${BSP}/${BSP}.ld + -Wl,--gc-sections + ) + +# Libraries +list (APPEND LIBS + -l${BSP} + -l${ARCH} + -lkern + -ldev + -lsio + -lblock + -lfs + -lusb + -llwip + -lptpd + -leth + -li2c + -lrtc + -lcan + -lnand + -lspi + -lnor + -lpwm + -ladc + -ldac + -ltrace + -lcounter + -lshell + -llua + -lc + -lm + ) +list(JOIN LIBS " " LIBS) # Convert list to space separated string +set(CMAKE_C_STANDARD_LIBRARIES ${LIBS}) +set(CMAKE_CXX_STANDARD_LIBRARIES "${LIBS} -lstdc++") + +# Group libraries when linking + +set(CMAKE_C_LINK_EXECUTABLE " -o -Wl,--start-group -Wl,--end-group") + +set(CMAKE_CXX_LINK_EXECUTABLE " -o -Wl,--start-group -Wl,--end-group") diff --git a/profinet_stack/p-net/cmake/tools/README.md b/profinet_stack/p-net/cmake/tools/README.md new file mode 100644 index 0000000..1f44004 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/README.md @@ -0,0 +1,5 @@ +CMake tools and utilities +========================= + +This repository contains common cmake functionality for rt-labs +open-source projects. diff --git a/profinet_stack/p-net/cmake/tools/toolchain/arm7tdmi.cmake b/profinet_stack/p-net/cmake/tools/toolchain/arm7tdmi.cmake new file mode 100644 index 0000000..47e416e --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/arm7tdmi.cmake @@ -0,0 +1,17 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2014 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mthumb-interwork + -mlittle-endian + -mthumb + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/arm926ej-s.cmake b/profinet_stack/p-net/cmake/tools/toolchain/arm926ej-s.cmake new file mode 100644 index 0000000..6f1bb77 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/arm926ej-s.cmake @@ -0,0 +1,16 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2010 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mlittle-endian + -mcpu=arm926ej-s + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-a8-neon.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-a8-neon.cmake new file mode 100644 index 0000000..45e9a47 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-a8-neon.cmake @@ -0,0 +1,17 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2017 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mcpu=cortex-a8 + -mfpu=neon + -mfloat-abi=hard + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-a8.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-a8.cmake new file mode 100644 index 0000000..305b553 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-a8.cmake @@ -0,0 +1,16 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2011 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mfpu=neon + -mcpu=cortex-a8 + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-a9-vfp.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-a9-vfp.cmake new file mode 100644 index 0000000..6ea3576 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-a9-vfp.cmake @@ -0,0 +1,17 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2014 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mcpu=cortex-a9 + -mfpu=vfpv3-d16 + -mfloat-abi=hard + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-a9.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-a9.cmake new file mode 100644 index 0000000..a64adfc --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-a9.cmake @@ -0,0 +1,16 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2014 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mfpu=neon + -mcpu=cortex-a9 + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-m3.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m3.cmake new file mode 100644 index 0000000..37c72b7 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m3.cmake @@ -0,0 +1,17 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2011 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mfpu=vfp + -mcpu=cortex-m3 + -mthumb + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-m4.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m4.cmake new file mode 100644 index 0000000..8bbcbd9 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m4.cmake @@ -0,0 +1,17 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2011 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mfpu=vfp + -mcpu=cortex-m4 + -mthumb + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-m4f.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m4f.cmake new file mode 100644 index 0000000..ac4078e --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m4f.cmake @@ -0,0 +1,18 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2011 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mcpu=cortex-m4 + -mthumb + -mfloat-abi=hard + -mfpu=fpv4-sp-d16 + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-m7f.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m7f.cmake new file mode 100644 index 0000000..fc909d1 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m7f.cmake @@ -0,0 +1,18 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2011 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mcpu=cortex-m7 + -mthumb + -mfloat-abi=hard + -mfpu=fpv4-sp-d16 + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-m7fd.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m7fd.cmake new file mode 100644 index 0000000..7d1cce0 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-m7fd.cmake @@ -0,0 +1,18 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2011 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mcpu=cortex-m7 + -mthumb + -mfloat-abi=hard + -mfpu=fpv5-d16 + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/cortex-r5-vfp.cmake b/profinet_stack/p-net/cmake/tools/toolchain/cortex-r5-vfp.cmake new file mode 100644 index 0000000..3729fdc --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/cortex-r5-vfp.cmake @@ -0,0 +1,18 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2018 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mcpu=cortex-r5 + -mthumb + -mfloat-abi=hard + -mfpu=vfpv3-d16 + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/e200.cmake b/profinet_stack/p-net/cmake/tools/toolchain/e200.cmake new file mode 100644 index 0000000..46374c4 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/e200.cmake @@ -0,0 +1,18 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2011 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mcpu=8540 + -mregnames + -mmultiple + -mabi=spe + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/ppc604.cmake b/profinet_stack/p-net/cmake/tools/toolchain/ppc604.cmake new file mode 100644 index 0000000..e38a7ec --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/ppc604.cmake @@ -0,0 +1,19 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# http://www.rt-labs.com +# Copyright 2011 rt-labs AB, Sweden. +# See LICENSE file in the project root for full license information. +#*******************************************************************/ + +list(APPEND MACHINE + -mbig + -mregnames + -mcpu=powerpc + -mcall-sysv + -meabi + ) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/rt-kernel.cmake b/profinet_stack/p-net/cmake/tools/toolchain/rt-kernel.cmake new file mode 100644 index 0000000..92d8f9b --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/rt-kernel.cmake @@ -0,0 +1,92 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# www.rt-labs.com +# Copyright 2017 rt-labs AB, Sweden. +# +# This software is licensed under the terms of the BSD 3-clause +# license. See the file LICENSE distributed with this software for +# full license information. +#*******************************************************************/ + +#[=======================================================================[.rst: +rt-kernel toolchain +------------------- + +The following environment variables must be set when cmake +configuration is invoked:: + + RTK - Location of rt-kernel tree + BSP - Name of Board Support Package + +The following environment variables are optional:: + + COMPILERS - Compiler search path, defaults to /opt/rt-tools/compilers + +Your CMAKE_MODULE_PATH must also be configured so that +Platform/rt-kernel.cmake can be found. + +Example to build for the xmc48relax board:: + + RTK=/path/to/rt-kernel BSP=xmc48relax cmake \ + -B build.xmc48relax \ + -DCMAKE_TOOLCHAIN_FILE=/path/to/rt-kernel.cmake +#]=======================================================================] + +include_guard() + +# The name of the target operating system +set(CMAKE_SYSTEM_NAME rt-kernel) + +# Default toolchain search path +if (NOT DEFINED ENV{COMPILERS}) + set(ENV{COMPILERS} "/opt/rt-tools/compilers") +endif() + +# Get environment variables +set(RTK $ENV{RTK} CACHE STRING + "Location of rt-kernel tree") +set(COMPILERS $ENV{COMPILERS} CACHE STRING + "Location of compiler toolchain") +set(BSP $ENV{BSP} CACHE STRING + "The name of the BSP to build for") + +# Check that bsp.mk exists +set(BSP_MK_FILE ${RTK}/bsp/${BSP}/${BSP}.mk) +if (NOT EXISTS ${BSP_MK_FILE}) + message(FATAL_ERROR "Failed to open ${BSP_MK_FILE}") +endif() + +# Slurp bsp.mk contents +file(READ ${BSP_MK_FILE} BSP_MK) + +# Get CPU +string(REGEX MATCH "CPU=([A-Za-z0-9_\-]*)" _ ${BSP_MK}) +set(CPU ${CMAKE_MATCH_1} CACHE STRING "") + +# Get ARCH +string(REGEX MATCH "ARCH=([A-Za-z0-9_\-]*)" _ ${BSP_MK}) +set(ARCH ${CMAKE_MATCH_1} CACHE STRING "") + +# Get VARIANT +string(REGEX MATCH "VARIANT=([A-Za-z0-9_\-]*)" _ ${BSP_MK}) +set(VARIANT ${CMAKE_MATCH_1} CACHE STRING "") + +# Get CROSS_GCC +string(REGEX MATCH "CROSS_GCC=([A-Za-z0-9_\-]*)" _ ${BSP_MK}) +set(CROSS_GCC ${CMAKE_MATCH_1} CACHE STRING "") + +# Set cross-compiler toolchain +set(CMAKE_C_COMPILER ${COMPILERS}/${CROSS_GCC}/bin/${CROSS_GCC}-gcc) +set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER}) +if(CMAKE_HOST_WIN32) + set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER}.exe) + set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER}.exe) +endif(CMAKE_HOST_WIN32) + +# Set cross-compiler machine-specific flags +include(toolchain/${CPU}) diff --git a/profinet_stack/p-net/cmake/tools/toolchain/stm32cube.cmake b/profinet_stack/p-net/cmake/tools/toolchain/stm32cube.cmake new file mode 100644 index 0000000..96468d7 --- /dev/null +++ b/profinet_stack/p-net/cmake/tools/toolchain/stm32cube.cmake @@ -0,0 +1,54 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# www.rt-labs.com +# Copyright 2021 rt-labs AB, Sweden. +# +# This software is licensed under the terms of the BSD 3-clause +# license. See the file LICENSE distributed with this software for +# full license information. +#*******************************************************************/ + +#[=======================================================================[.rst: +STM32Cube toolchain +------------------- + +The following environment variables must be set when cmake +configuration is invoked:: + + CPU - Name of CPU + BOARD - Name of board + CUBE_DIR - Path to STM32Cube firmware + +Machine-specific flags will be loaded from toolchain/${CPU}.cmake. See +the toolchain folder for known values. + +Your CMAKE_MODULE_PATH must also be configured so that +Platform/STM32Cube.cmake can be found. +#]=======================================================================] + +include_guard() + +# The name of the target operating system +set(CMAKE_SYSTEM_NAME STM32Cube) + +set(CPU $ENV{CPU} CACHE STRING "") +set(BOARD $ENV{BOARD} CACHE STRING "") +set(CUBE_DIR $ENV{CUBE_DIR} CACHE STRING "") + +# Set cross-compiler toolchain +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER}) +set(OBJCOPY arm-none-eabi-objcopy) +if(CMAKE_HOST_WIN32) + set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER}.exe) + set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER}.exe) + set(OBJCOPY ${OBJCOPY}.exe) +endif(CMAKE_HOST_WIN32) + +# Set cross-compiler machine-specific flags +include(toolchain/${CPU})