From 83555933aaf4b48c97b91e04e406b9268dc60e2d Mon Sep 17 00:00:00 2001 From: Alexey Shvetsov Date: Tue, 7 Nov 2017 08:03:59 +0300 Subject: [PATCH] Add platformio support for stm32 (#8246) [2.0] Add platformio support for stm32 --- Marlin/src/HAL/HAL.h | 2 +- Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.h | 14 +++++ .../HAL/HAL_STM32F1/stm32f1_flag_script.py | 55 +++++++++++++++++++ platformio.ini | 9 +++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 Marlin/src/HAL/HAL_STM32F1/stm32f1_flag_script.py diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index bc7d285e81..1e0de556f0 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -45,7 +45,7 @@ #define CPU_32_BIT #include "math_32bit.h" #include "HAL_LPC1768/HAL.h" -#elif defined(__STM32F1__) +#elif defined(__STM32F1__) || defined(TARGET_STM32F1) #define CPU_32_BIT #include "math_32bit.h" #include "HAL_STM32F1/HAL_Stm32f1.h" diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.h b/Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.h index 24b8801da3..3d61842271 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.h +++ b/Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.h @@ -42,11 +42,25 @@ #include "Arduino.h" +// -------------------------------------------------------------------------- +// Undefine DEBUG_ settings +// -------------------------------------------------------------------------- + + +#undef DEBUG_NONE +#undef DEBUG_FAULT +#undef DEBUG_ALL + +// -------------------------------------------------------------------------- +// Includes +// -------------------------------------------------------------------------- + #include "fastio_Stm32f1.h" #include "watchdog_Stm32f1.h" #include "HAL_timers_Stm32f1.h" + // -------------------------------------------------------------------------- // Defines // -------------------------------------------------------------------------- diff --git a/Marlin/src/HAL/HAL_STM32F1/stm32f1_flag_script.py b/Marlin/src/HAL/HAL_STM32F1/stm32f1_flag_script.py new file mode 100644 index 0000000000..0610ce132a --- /dev/null +++ b/Marlin/src/HAL/HAL_STM32F1/stm32f1_flag_script.py @@ -0,0 +1,55 @@ +from __future__ import print_function +import sys + +#dynamic build flags for generic compile options +if __name__ == "__main__": + args = " ".join([ "-std=gnu11", + "-std=gnu++11", + "-Os", + "-mcpu=cortex-m3", + "-mthumb", + + "-ffreestanding", + "-fsigned-char", + "-fno-move-loop-invariants", + "-fno-strict-aliasing", + + "--specs=nano.specs", + "--specs=nosys.specs", + + "-IMarlin/src/HAL", + + "-MMD", + "-MP", + "-DTARGET_STM32F1" + ]) + + for i in range(1, len(sys.argv)): + args += " " + sys.argv[i] + + print(args) + +# extra script for linker options +else: + from SCons.Script import DefaultEnvironment + env = DefaultEnvironment() + env.Append( + ARFLAGS=["rcs"], + + ASFLAGS=["-x", "assembler-with-cpp"], + + CXXFLAGS=[ + "-fabi-version=0", + "-fno-use-cxa-atexit", + "-fno-threadsafe-statics" + ], + LINKFLAGS=[ + "-Os", + "-mcpu=cortex-m3", + "-ffreestanding", + "-mthumb", + "--specs=nano.specs", + "--specs=nosys.specs", + "-u_printf_float", + ], + ) diff --git a/platformio.ini b/platformio.ini index 94f893edfa..a918a94be4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -182,3 +182,12 @@ debug_server = -speed auto -noir + +[env:STM32F1] +platform = ststm32 +framework = arduino +board = genericSTM32F103RE +build_flags = !python Marlin/src/HAL/HAL_STM32F1/stm32f1_flag_script.py +lib_deps = ${common.lib_deps} +src_filter = ${common.default_src_filter} +