Skip to content

Commit

Permalink
STM32Cube platform, STM32U5 change only: build with ARM GCC 13.2.1.
Browse files Browse the repository at this point in the history
The changes of commit a8603c0 (for the STM32Cube platform, STM32F4 case) are now applied to the STM32Cube platform STM32U5 case.
  • Loading branch information
RobMeades committed Jun 25, 2024
1 parent c82dd23 commit b6b995f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion port/platform/stm32cube/mcu/stm32u5/runner/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ override CFLAGS += \
$(DEFINES) -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -std=gnu11 -g3 -O0 -Wall \
-ffunction-sections -fdata-sections -fstack-usage --specs=nano.specs -MMD -MP $(U_FLAGS)

# Note: the --no-warn-rwx-segments suppression was added in moving from
# GCC ARM "10-2020-q4-major" to "13.2.rel1" as the behaviour of the linker
# file is outside our control
override LDFLAGS += \
-debug -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -static -T"$(PLATFORM_PATH)/app/STM32U575ZITX_FLASH.ld" \
-Wl,-Map="$(OUTPUT_DIRECTORY)/runner.map" -Wl,--gc-sections --specs=nano.specs -Wl,--start-group -lc -lm -Wl,--end-group \
-Wl,--defsym=RTOS2_BYTE_POOL_SIZE=753664
-Wl,--defsym=RTOS2_BYTE_POOL_SIZE=753664 \
-Wl,--no-warn-rwx-segments

# Include STM32 common files; this requires STM32CUBE_HAL_PATH and will give us the
# common parts of STM32CUBE_FW_SRC and STM32CUBE_FW_INC (i.e. the HAL etc.)
Expand Down
19 changes: 14 additions & 5 deletions port/platform/stm32cube/src/u_port_os_pure_cmsis.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,20 @@ int32_t uPortTaskDelete(const uPortTaskHandle_t taskHandle)
// When _LITE_EXIT is enabled the stdio streams stdout, stdin and stderr are not closed
// when deallocating the task, resulting in memory leaks if the deleted task have been using
// these io streams.
// Note: The workaround below only works when a task deletes itself, which is always
// the case with CMSIS on FreeRTOS and is never the case otherwise (i.e. with ThreadX).
#if defined(U_PORT_STM32_CMSIS_ON_FREERTOS) && \
defined(__NEWLIB__) && defined(_LITE_EXIT) && defined(_REENT_SMALL) && \
!defined(_REENT_GLOBAL_STDIO_STREAMS) && !defined(_UNBUF_STREAM_OPT)
// Note: The workaround below only works when a task deletes itself.
// Note: we used to switch this code in and out based on the following conditional:
//
// #if defined(__NEWLIB__) && defined(_LITE_EXIT) && defined(_REENT_SMALL) &&
// !defined(_REENT_GLOBAL_STDIO_STREAMS) && !defined(_UNBUF_STREAM_OPT)
//
// However, this doesn't work for GCC ARM version 11 and later, ALL printf()'s just stop here.
// config.h, newlib.h and reent.h are not changed between the versions, so we can only
// surmise that newlib library is being built with a different set of WANT_ switches.
// It would be best to switch the code in or out based on the GCC version but that doesn't
// seem to be available in a header file. Instead, the point at which the behaviour
// changed was also the point at which the newlib major version changed to 4, so we
// use that instead.
#if defined(__NEWLIB__) && (__NEWLIB__ < 4)
if (taskHandle == NULL) {
if (stdout) {
fclose(stdout);
Expand Down

0 comments on commit b6b995f

Please sign in to comment.