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/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.cmake b/tutorial/ewarm/ewarm.cmake similarity index 68% rename from tutorial/ewarm.cmake rename to tutorial/ewarm/ewarm.cmake index 2da3ef4..b1d35bc 100644 --- a/tutorial/ewarm.cmake +++ b/tutorial/ewarm/ewarm.cmake @@ -2,12 +2,13 @@ # 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 "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") +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) @@ -21,6 +22,6 @@ 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" + "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!"); +}