diff --git a/platformio.ini b/platformio.ini
index 95d72ac9e..8b8e9f2c7 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -19,6 +19,7 @@ extra_configs =
lib_archive = no
debug_tool = stlink
upload_protocol = dfu
+platform_packages = toolchain-gccarmnoneeabi@~1.120301.0
build_src_filter = +<*> -<.git/> -<.svn/> - - - - - - -
extra_scripts =
pre:script/pre_script.py
@@ -34,8 +35,7 @@ build_flags =
[stm32]
extends = common
-platform = ststm32
-platform_packages = toolchain-gccarmnoneeabi@~1.90201.0
+platform = ststm32@~17.0.0
build_src_filter = ${common.build_src_filter} +
framework = stm32cube
board_build.stm32cube.custom_system_setup = yes
@@ -136,7 +136,6 @@ extends = stm32h743
[at32]
extends = common
platform = https://github.com/ArteryTek/platform-arterytekat32.git#5729d36
-platform_packages = toolchain-gccarmnoneeabi@~1.90201.0
framework = at32firmlib
board_build.at32firmlib.custom_system_setup = yes
build_src_filter = ${common.build_src_filter} +
diff --git a/script/post_script.py b/script/post_script.py
index 9997db638..9d37b9be4 100644
--- a/script/post_script.py
+++ b/script/post_script.py
@@ -22,8 +22,8 @@ def before_upload(source, target, env):
time.sleep(2)
-remove_flags = ["-lgcc", "-lstdc++"]
-for scope in ("ASFLAGS", "CCFLAGS", "LINKFLAGS"):
+remove_flags = ["gcc", "stdc++", "nosys", "--specs=nosys.specs"]
+for scope in ("ASFLAGS", "CCFLAGS", "LINKFLAGS", "LIBS"):
for option in remove_flags:
while option in env[scope]:
env[scope].remove(option)
diff --git a/script/pre_script.py b/script/pre_script.py
index 19a8e5b53..258b4e669 100644
--- a/script/pre_script.py
+++ b/script/pre_script.py
@@ -28,7 +28,7 @@
]
if env.GetBuildType() == "release":
- common_flags.insert(0, "-flto")
+ common_flags.insert(0, "-flto=auto")
common_flags.insert(0, "-Ofast")
git_version = porcelain.describe(".")
diff --git a/src/core/syscalls.c b/src/core/syscalls.c
new file mode 100644
index 000000000..f3c3f6031
--- /dev/null
+++ b/src/core/syscalls.c
@@ -0,0 +1,22 @@
+#include
+
+register char *stack_ptr asm("sp");
+uint __heap_limit = 0xcafedead;
+
+__attribute__((__used__)) void *_sbrk(ptrdiff_t incr) {
+ extern char end asm("end"); /* Defined by the linker. */
+ static char *heap_end;
+
+ if (heap_end == NULL)
+ heap_end = &end;
+
+ const char *prev_heap_end = heap_end;
+
+ if ((heap_end + incr > stack_ptr) ||
+ (__heap_limit != 0xcafedead && heap_end + incr > (char *)__heap_limit)) {
+ return (void *)-1;
+ }
+
+ heap_end += incr;
+ return (void *)prev_heap_end;
+}