Browse Source

Add platformio support for stm32 (#8246)

[2.0] Add platformio support for stm32
Alexey Shvetsov 6 years ago
parent
commit
83555933aa

+ 1
- 1
Marlin/src/HAL/HAL.h View File

@@ -45,7 +45,7 @@
45 45
   #define CPU_32_BIT
46 46
   #include "math_32bit.h"
47 47
   #include "HAL_LPC1768/HAL.h"
48
-#elif defined(__STM32F1__)
48
+#elif defined(__STM32F1__) || defined(TARGET_STM32F1)
49 49
   #define CPU_32_BIT
50 50
   #include "math_32bit.h"
51 51
   #include "HAL_STM32F1/HAL_Stm32f1.h"

+ 14
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.h View File

@@ -42,11 +42,25 @@
42 42
 
43 43
 #include "Arduino.h"
44 44
 
45
+// --------------------------------------------------------------------------
46
+// Undefine DEBUG_ settings
47
+// --------------------------------------------------------------------------
48
+
49
+
50
+#undef DEBUG_NONE
51
+#undef DEBUG_FAULT
52
+#undef DEBUG_ALL
53
+
54
+// --------------------------------------------------------------------------
55
+// Includes
56
+// --------------------------------------------------------------------------
57
+
45 58
 #include "fastio_Stm32f1.h"
46 59
 #include "watchdog_Stm32f1.h"
47 60
 
48 61
 #include "HAL_timers_Stm32f1.h"
49 62
 
63
+
50 64
 // --------------------------------------------------------------------------
51 65
 // Defines
52 66
 // --------------------------------------------------------------------------

+ 55
- 0
Marlin/src/HAL/HAL_STM32F1/stm32f1_flag_script.py View File

@@ -0,0 +1,55 @@
1
+from __future__ import print_function
2
+import sys
3
+
4
+#dynamic build flags for generic compile options
5
+if __name__ == "__main__":
6
+  args = " ".join([ "-std=gnu11",
7
+                    "-std=gnu++11",
8
+                    "-Os",
9
+                    "-mcpu=cortex-m3",
10
+                    "-mthumb",
11
+
12
+                    "-ffreestanding",
13
+                    "-fsigned-char",
14
+                    "-fno-move-loop-invariants",
15
+                    "-fno-strict-aliasing",
16
+
17
+                    "--specs=nano.specs",
18
+                    "--specs=nosys.specs",
19
+
20
+                    "-IMarlin/src/HAL",
21
+
22
+                    "-MMD",
23
+                    "-MP",
24
+                    "-DTARGET_STM32F1"
25
+                  ])
26
+
27
+  for i in range(1, len(sys.argv)):
28
+    args += " " + sys.argv[i]
29
+
30
+  print(args)
31
+
32
+# extra script for linker options
33
+else:
34
+  from SCons.Script import DefaultEnvironment
35
+  env = DefaultEnvironment()
36
+  env.Append(
37
+      ARFLAGS=["rcs"],
38
+
39
+      ASFLAGS=["-x", "assembler-with-cpp"],
40
+
41
+      CXXFLAGS=[
42
+          "-fabi-version=0",
43
+          "-fno-use-cxa-atexit",
44
+          "-fno-threadsafe-statics"
45
+      ],
46
+      LINKFLAGS=[
47
+          "-Os",
48
+          "-mcpu=cortex-m3",
49
+          "-ffreestanding",
50
+          "-mthumb",
51
+          "--specs=nano.specs",
52
+          "--specs=nosys.specs",
53
+          "-u_printf_float",
54
+      ],
55
+  )

+ 9
- 0
platformio.ini View File

@@ -182,3 +182,12 @@ debug_server   =
182 182
   -speed
183 183
   auto
184 184
   -noir
185
+
186
+[env:STM32F1]
187
+platform    = ststm32
188
+framework   = arduino
189
+board       = genericSTM32F103RE
190
+build_flags = !python Marlin/src/HAL/HAL_STM32F1/stm32f1_flag_script.py
191
+lib_deps    = ${common.lib_deps}
192
+src_filter  = ${common.default_src_filter}
193
+

Loading…
Cancel
Save