From 6ca2f6203fffef28e8828b2ad4e20c6003f442b4 Mon Sep 17 00:00:00 2001 From: Ankit Khandeparkar Date: Fri, 18 Oct 2024 13:47:27 +0200 Subject: [PATCH 1/2] working bxarm tutorial --- tutorial/CMakeLists.txt | 24 ----------------- tutorial/bxarm/CMakeLists.txt | 45 ++++++++++++++++++++++++++++++++ tutorial/{ => bxarm}/bxarm.cmake | 7 ++--- tutorial/{ => bxarm}/tutorial.c | 0 tutorial/ewarm.cmake | 26 ------------------ 5 files changed, 49 insertions(+), 53 deletions(-) delete mode 100644 tutorial/CMakeLists.txt create mode 100644 tutorial/bxarm/CMakeLists.txt rename tutorial/{ => bxarm}/bxarm.cmake (80%) rename tutorial/{ => bxarm}/tutorial.c (100%) delete mode 100644 tutorial/ewarm.cmake diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt deleted file mode 100644 index 631dac3..0000000 --- a/tutorial/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# set the minimum required version of CMake to be 3.20 -cmake_minimum_required(VERSION 3.20) - -# set the project name -project(Tutorial) - -# add the executable target -add_executable(tutorial) - -# target sources -target_sources(tutorial PRIVATE tutorial.c) - -# compiler options -target_compile_options(tutorial PRIVATE --cpu=cortex-m4) - -# linker options -target_link_options(tutorial PRIVATE --semihosting) - -# TODO 1: Enable testing in CMake - -# TODO 2: Add a test named `tutorialTest` for `tutorial` (hint: use CSpyBat) - -# TODO 3: Set the `tutorialTest` test passing condition - diff --git a/tutorial/bxarm/CMakeLists.txt b/tutorial/bxarm/CMakeLists.txt new file mode 100644 index 0000000..80c3639 --- /dev/null +++ b/tutorial/bxarm/CMakeLists.txt @@ -0,0 +1,45 @@ +# set the minimum required version of CMake to be 3.20 +cmake_minimum_required(VERSION 3.20) + +# set the project name +project(Tutorial) + +# add the executable target +add_executable(tutorial) + +# target sources +target_sources(tutorial PRIVATE tutorial.c) + +# compiler options +target_compile_options(tutorial PRIVATE --debug --endian=little --cpu=Cortex-M4 -e --fpu=VFPv4_sp -Ol) + +# linker options +target_link_options(tutorial PRIVATE --config ${TOOLKIT_DIR}/arm/config/linker/ST/stm32f429xI.icf --semihosting --entry __iar_program_start --vfe --text_out locale --cpu=Cortex-M4 --fpu=VFPv4_sp) + +# enable testing +enable_testing() + +# add a test named `tutorialTest` for `tutorial` +add_test(NAME tutorialTest + COMMAND ${TOOLKIT_DIR}/common/bin/CSpyBat + # C-SPY drivers for the Arm simulator via command line interface + ${TOOLKIT_DIR}/arm/bin/libarmPROC.so + ${TOOLKIT_DIR}/arm/bin/libarmSIM2.so + --plugin=${TOOLKIT_DIR}/arm/bin/libarmLibsupportUniversal.so + --device_macro=${TOOLKIT_DIR}/arm/config/debugger/ST/STM32F4xx.dmac + # The target executable (built with debug information) + --debug_file=$ + # C-SPY driver options + --backend + --endian=little + --cpu=Cortex-M4 + --fpu=VFPv4_SP + -p + ${TOOLKIT_DIR}/arm/config/debugger/ST/STM32F429II.ddf + --semihosting + --device=STM32F429II + --multicore_nr_of_cores=1) + +# set the `tutorialTest` test passing condition +set_tests_properties(tutorialTest PROPERTIES PASS_REGULAR_EXPRESSION "Hello world!") + diff --git a/tutorial/bxarm.cmake b/tutorial/bxarm/bxarm.cmake similarity index 80% rename from tutorial/bxarm.cmake rename to tutorial/bxarm/bxarm.cmake index dc8d1ad..4af5556 100644 --- a/tutorial/bxarm.cmake +++ b/tutorial/bxarm/bxarm.cmake @@ -2,12 +2,13 @@ # Set CMake for cross-compiling set(CMAKE_SYSTEM_NAME Generic) +set(TOOLKIT_DIR /opt/iarsystems/bxarm) # Set CMake to use the IAR C/C++ Compiler from the IAR Build Tools for Arm # Update if using a different supported target or operating system -set(CMAKE_ASM_COMPILER /opt/iarsystems/bxarm/arm/bin/iasmarm) -set(CMAKE_C_COMPILER /opt/iarsystems/bxarm/arm/bin/iccarm) -set(CMAKE_CXX_COMPILER /opt/iarsystems/bxarm/arm/bin/iccarm) +set(CMAKE_ASM_COMPILER ${TOOLKIT_DIR}/arm/bin/iasmarm) +set(CMAKE_C_COMPILER ${TOOLKIT_DIR}/arm/bin/iccarm) +set(CMAKE_CXX_COMPILER ${TOOLKIT_DIR}/arm/bin/iccarm) # Avoids running the linker during try_compile() set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) diff --git a/tutorial/tutorial.c b/tutorial/bxarm/tutorial.c similarity index 100% rename from tutorial/tutorial.c rename to tutorial/bxarm/tutorial.c diff --git a/tutorial/ewarm.cmake b/tutorial/ewarm.cmake deleted file mode 100644 index 2da3ef4..0000000 --- a/tutorial/ewarm.cmake +++ /dev/null @@ -1,26 +0,0 @@ -# Toolchain File for the IAR C/C++ Compiler - -# Set CMake for cross-compiling -set(CMAKE_SYSTEM_NAME Generic) - -# Set CMake to use the IAR C/C++ Compiler from the IAR Embedded Workbench for Arm -# Update if using a different supported target or operating system -set(CMAKE_ASM_COMPILER "C:/Program Files/IAR Systems/Embedded Workbench 9.3/arm/bin/iasmarm.exe") -set(CMAKE_C_COMPILER "C:/Program Files/IAR Systems/Embedded Workbench 9.3/arm/bin/iccarm.exe") -set(CMAKE_CXX_COMPILER "C:/Program Files/IAR Systems/Embedded Workbench 9.3/arm/bin/iccarm.exe") - -# Avoids running the linker during try_compile() -set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) - -# Set the default build tool for Ninja gnerators -# Reasonably recent IAR products ships with ninja (https://ninja-build.org) -# The CMake code block below tries to find it. If not found, -# manually install the desired build system in your operating system -# Alternatively: set(CMAKE_MAKE_PROGRAM "C:/path/to/ninja.exe") -if(CMAKE_GENERATOR MATCHES "^Ninja.*$") - find_program(CMAKE_MAKE_PROGRAM - NAMES ninja.exe - PATHS $ENV{PATH} - "C:/Program Files/IAR Systems/Embedded Workbench 9.3/common/bin" - REQUIRED) -endif() From a6d73466bcac87f61298c18cb6b1aa097b19dbc4 Mon Sep 17 00:00:00 2001 From: Ankit Khandeparkar Date: Fri, 18 Oct 2024 13:59:18 +0200 Subject: [PATCH 2/2] working ewarm tutorial --- tutorial/ewarm/CMakeLists.txt | 45 +++++++++++++++++++++++++++++++++++ tutorial/ewarm/ewarm.cmake | 27 +++++++++++++++++++++ tutorial/ewarm/tutorial.c | 5 ++++ 3 files changed, 77 insertions(+) create mode 100644 tutorial/ewarm/CMakeLists.txt create mode 100644 tutorial/ewarm/ewarm.cmake create mode 100644 tutorial/ewarm/tutorial.c diff --git a/tutorial/ewarm/CMakeLists.txt b/tutorial/ewarm/CMakeLists.txt new file mode 100644 index 0000000..1ec566e --- /dev/null +++ b/tutorial/ewarm/CMakeLists.txt @@ -0,0 +1,45 @@ +# set the minimum required version of CMake to be 3.20 +cmake_minimum_required(VERSION 3.20) + +# set the project name +project(Tutorial) + +# add the executable target +add_executable(tutorial) + +# target sources +target_sources(tutorial PRIVATE tutorial.c) + +# compiler options +target_compile_options(tutorial PRIVATE --debug --endian=little --cpu=Cortex-M4 -e --fpu=VFPv4_sp -Ol) + +# linker options +target_link_options(tutorial PRIVATE --config ${TOOLKIT_DIR}/arm/config/linker/ST/stm32f429xI.icf --semihosting --entry __iar_program_start --vfe --text_out locale --cpu=Cortex-M4 --fpu=VFPv4_sp) + +# enable testing +enable_testing() + +# add a test named `tutorialTest` for `tutorial` +add_test(NAME tutorialTest + COMMAND ${TOOLKIT_DIR}/common/bin/CSpyBat.exe + # C-SPY drivers for the Arm simulator via command line interface + ${TOOLKIT_DIR}/arm/bin/armPROC.dll + ${TOOLKIT_DIR}/arm/bin/armSIM2.dll + --plugin=${TOOLKIT_DIR}/arm/bin/armLibsupportUniversal.dll + --device_macro=${TOOLKIT_DIR}/arm/config/debugger/ST/STM32F4xx.dmac + # The target executable (built with debug information) + --debug_file=$ + # C-SPY driver options + --backend + --endian=little + --cpu=Cortex-M4 + --fpu=VFPv4_SP + -p + ${TOOLKIT_DIR}/arm/config/debugger/ST/STM32F429II.ddf + --semihosting + --device=STM32F429II + --multicore_nr_of_cores=1) + +# set the `tutorialTest` test passing condition +set_tests_properties(tutorialTest PROPERTIES PASS_REGULAR_EXPRESSION "Hello world!") + diff --git a/tutorial/ewarm/ewarm.cmake b/tutorial/ewarm/ewarm.cmake new file mode 100644 index 0000000..b1d35bc --- /dev/null +++ b/tutorial/ewarm/ewarm.cmake @@ -0,0 +1,27 @@ +# Toolchain File for the IAR C/C++ Compiler + +# Set CMake for cross-compiling +set(CMAKE_SYSTEM_NAME Generic) +set(TOOLKIT_DIR C:/iar/ewarm-9.60.2) + +# Set CMake to use the IAR C/C++ Compiler from the IAR Embedded Workbench for Arm +# Update if using a different supported target or operating system +set(CMAKE_ASM_COMPILER ${TOOLKIT_DIR}/arm/bin/iasmarm.exe) +set(CMAKE_C_COMPILER ${TOOLKIT_DIR}/arm/bin/iccarm.exe) +set(CMAKE_CXX_COMPILER ${TOOLKIT_DIR}/arm/bin/iccarm.exe) + +# Avoids running the linker during try_compile() +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +# Set the default build tool for Ninja gnerators +# Reasonably recent IAR products ships with ninja (https://ninja-build.org) +# The CMake code block below tries to find it. If not found, +# manually install the desired build system in your operating system +# Alternatively: set(CMAKE_MAKE_PROGRAM "C:/path/to/ninja.exe") +if(CMAKE_GENERATOR MATCHES "^Ninja.*$") + find_program(CMAKE_MAKE_PROGRAM + NAMES ninja.exe + PATHS $ENV{PATH} + "C:/iar/ewarm-9.60.2/common/bin" + REQUIRED) +endif() diff --git a/tutorial/ewarm/tutorial.c b/tutorial/ewarm/tutorial.c new file mode 100644 index 0000000..13ef719 --- /dev/null +++ b/tutorial/ewarm/tutorial.c @@ -0,0 +1,5 @@ +#include + +void main() { + printf("Hello world!"); +}