Skip to content

Commit

Permalink
update gcc, stop using nosys
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Oct 15, 2023
1 parent 7a9b067 commit d9e5ff3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
5 changes: 2 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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/> -<example/> -<examples/> -<test/> -<tests/> -<system/> -<driver/stm32> -<driver/at32>
extra_scripts =
pre:script/pre_script.py
Expand All @@ -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} +<driver/stm32>
framework = stm32cube
board_build.stm32cube.custom_system_setup = yes
Expand Down Expand Up @@ -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} +<driver/at32>
Expand Down
4 changes: 2 additions & 2 deletions script/post_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion script/pre_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(".")
Expand Down
22 changes: 22 additions & 0 deletions src/core/syscalls.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <sys/types.h>

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;
}

0 comments on commit d9e5ff3

Please sign in to comment.