aboutsummaryrefslogtreecommitdiff
path: root/platforms
diff options
context:
space:
mode:
authorStefan Kerkmann <karlk90@pm.me>2021-11-20 21:04:16 +0100
committerGitHub <noreply@github.com>2021-11-20 20:04:16 +0000
commit5c2052fd476cb1d15eab66c23016a1add93f6767 (patch)
tree318fc95b5a958075a9b5d1955696e294769793ac /platforms
parent32215d5bff52262542a2f8d2a221b0303f02c019 (diff)
downloadqmk_firmware-5c2052fd476cb1d15eab66c23016a1add93f6767.tar.gz
qmk_firmware-5c2052fd476cb1d15eab66c23016a1add93f6767.zip
[Core] RISC-V toolchain and picolibc fixes (#15109)
* [Core] Fix RISC-V toolchain installation The risc-v toolchain is only available on distributions based on Debian 11+ so we check for their availability before installing them. * [Core] Fix heap symbols and syscalls for picolibc picolibc internally uses __heap_start and __heap_end instead of the defacto chibios linker script standard __heap_base__ and __heap_end__ therefore we introduce these symbols as an alias. Usually all memory used within QMK is statically allocated, but some algorithms make usage of malloc and friends. Also the timeval struct is not defined by picolibc for syscalls, therefore it is declared as stub.
Diffstat (limited to 'platforms')
-rw-r--r--platforms/chibios/platform.mk19
-rw-r--r--platforms/chibios/syscall-fallbacks.c1
2 files changed, 12 insertions, 8 deletions
diff --git a/platforms/chibios/platform.mk b/platforms/chibios/platform.mk
index 6b298732c..1c8d43007 100644
--- a/platforms/chibios/platform.mk
+++ b/platforms/chibios/platform.mk
@@ -316,7 +316,7 @@ endif
316# 316#
317 317
318# Use defined stack sizes of the main thread in linker scripts 318# Use defined stack sizes of the main thread in linker scripts
319LDSYMBOLS =--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE) 319SHARED_LDSYMBOLS = -Wl,--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE)
320 320
321# Shared Compiler flags for all toolchains 321# Shared Compiler flags for all toolchains
322SHARED_CFLAGS = -fomit-frame-pointer \ 322SHARED_CFLAGS = -fomit-frame-pointer \
@@ -327,7 +327,6 @@ SHARED_CFLAGS = -fomit-frame-pointer \
327 327
328# Shared Linker flags for all toolchains 328# Shared Linker flags for all toolchains
329SHARED_LDFLAGS = -T $(LDSCRIPT) \ 329SHARED_LDFLAGS = -T $(LDSCRIPT) \
330 -Wl,$(LDSYMBOLS) \
331 -Wl,--gc-sections \ 330 -Wl,--gc-sections \
332 -nostartfiles 331 -nostartfiles
333 332
@@ -346,14 +345,18 @@ ifeq ($(strip $(MCU)), risc-v)
346 endif 345 endif
347 endif 346 endif
348 347
349 # Default to compiling with picolibc for RISC-V targets if available, 348 # Default to compiling with picolibc for RISC-V targets if available, which
350 # which is available by default on current (bullseye) debian based systems. 349 # is available by default on distributions based on Debian 11+.
351 ifeq ($(shell $(TOOLCHAIN)gcc --specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) 350 ifeq ($(shell $(TOOLCHAIN)gcc --specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
352 # Toolchain specific Compiler flags 351 # Toolchain specific Compiler flags Note that we still link with our own
353 # Note that we still link with our own linker script 352 # linker script by providing it via the -T flag in SHARED_LDFLAGS.
354 # by providing it via the -T flag above.
355 TOOLCHAIN_CFLAGS = --specs=picolibc.specs 353 TOOLCHAIN_CFLAGS = --specs=picolibc.specs
356 354
355 # picolibc internally uses __heap_start and __heap_end instead of the
356 # defacto chibios linker script standard __heap_base__ and __heap_end__
357 # therefore we introduce these symbols as an alias.
358 TOOLCHAIN_LDSYMBOLS = -Wl,--defsym=__heap_start=__heap_base__,--defsym=__heap_end=__heap_end__
359
357 # Tell QMK that we are compiling with picolibc. 360 # Tell QMK that we are compiling with picolibc.
358 OPT_DEFS += -DUSE_PICOLIBC 361 OPT_DEFS += -DUSE_PICOLIBC
359 endif 362 endif
@@ -404,7 +407,7 @@ CFLAGS += $(SHARED_CFLAGS) $(TOOLCHAIN_CFLAGS)
404CXXFLAGS += $(CFLAGS) $(SHARED_CXXFLAGS) $(TOOLCHAIN_CXXFLAGS) -fno-rtti 407CXXFLAGS += $(CFLAGS) $(SHARED_CXXFLAGS) $(TOOLCHAIN_CXXFLAGS) -fno-rtti
405 408
406# Linker flags 409# Linker flags
407LDFLAGS += $(SHARED_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MCUFLAGS) 410LDFLAGS += $(SHARED_LDFLAGS) $(SHARED_LDSYMBOLS) $(TOOLCHAIN_LDFLAGS) $(TOOLCHAIN_LDSYMBOLS) $(MCUFLAGS)
408 411
409# Tell QMK that we are hosting it on ChibiOS. 412# Tell QMK that we are hosting it on ChibiOS.
410OPT_DEFS += -DPROTOCOL_CHIBIOS 413OPT_DEFS += -DPROTOCOL_CHIBIOS
diff --git a/platforms/chibios/syscall-fallbacks.c b/platforms/chibios/syscall-fallbacks.c
index 4569879c7..7150a4632 100644
--- a/platforms/chibios/syscall-fallbacks.c
+++ b/platforms/chibios/syscall-fallbacks.c
@@ -22,6 +22,7 @@
22 * the _reent struct has to be defined. */ 22 * the _reent struct has to be defined. */
23#if defined(USE_PICOLIBC) 23#if defined(USE_PICOLIBC)
24struct _reent; 24struct _reent;
25struct timeval;
25#endif 26#endif
26 27
27#pragma GCC diagnostic ignored "-Wmissing-prototypes" 28#pragma GCC diagnostic ignored "-Wmissing-prototypes"