diff --git a/port/platform/stm32cube/mcu/stm32u5/runner/Makefile b/port/platform/stm32cube/mcu/stm32u5/runner/Makefile index 98aff7a7..e4a22d88 100644 --- a/port/platform/stm32cube/mcu/stm32u5/runner/Makefile +++ b/port/platform/stm32cube/mcu/stm32u5/runner/Makefile @@ -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.) diff --git a/port/platform/stm32cube/src/u_port_os_pure_cmsis.c b/port/platform/stm32cube/src/u_port_os_pure_cmsis.c index 0276db83..49da2517 100644 --- a/port/platform/stm32cube/src/u_port_os_pure_cmsis.c +++ b/port/platform/stm32cube/src/u_port_os_pure_cmsis.c @@ -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);