Describe the bug
Building the full demo FreeRTOS/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC with make FULL_DEMO=1 with latest kernel fails with following compilation error:
/tmp/tmp-test/FreeRTOS/FreeRTOS/Source/event_groups.c: In function 'vEventGroupDelete':
/tmp/tmp-test/FreeRTOS/FreeRTOS/Source/event_groups.c:59:46: error: conversion from 'long unsigned int' to 'TickType_t' {aka 'const short unsigned int'} changes value from '33554432' to '0' [-Werror=overflow]
59 | #define eventUNBLOCKED_DUE_TO_BIT_SET 0x02000000UL
| ^~~~~~~~~~~~
/tmp/tmp-test/FreeRTOS/FreeRTOS/Source/event_groups.c:652:88: note: in expansion of macro 'eventUNBLOCKED_DUE_TO_BIT_SET'
652 | vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );
Target
- Development board: M3 MPS2 QEMU
- Instruction Set Architecture: Armv7-M
- IDE and version: None
- Toolchain and version: arm-none-eabi-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
Host
- Host OS: Ubuntu
- Version: 20.04
To Reproduce
- git clone git@github.com:FreeRTOS/FreeRTOS.git --recurse-submodules
- cd FreeRTOS/FreeRTOS/Source
- git fetch -all
- git checkout main
- cd ../Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC
- make FULL_DEMO=1
Expected behavior
Build succeeds without failure
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Digging further into this, the build fails because the TickType_t gets typedefed to uint16_t instead of uint32_t at https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/portable/GCC/ARM_CM3_MPU/portmacro.h#L60 even though configUSE_16_BIT_TICKS is set to 0.
It seems like the backward compatibility support for configUSE_16_BIT_TICKS added as part of adding support for 64-bit events #597 isn't working as expected. The PR introduces a new macro configTICK_TYPE_WIDTH_IN_BITS which is undefined when portmacro.h is included in FreeRTOS.h. The macro gets defined further down in FreeRTOS.h to support backward compatibility for configUSE_16_BIT_TICKS macro. Since the macro configTICK_TYPE_WIDTH_IN_BITS isn't undefined when portmacro.h is included, configTICK_TYPE_WIDTH_IN_BITS is evaluated as 0 in the expression which causes the equality to succeed and TickType_t to typedef'ed to uint16_t. The undefined macros can be checked by enabling -Wundef after https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile#L45.
Describe the bug
Building the full demo FreeRTOS/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC with
make FULL_DEMO=1with latest kernel fails with following compilation error:Target
Host
To Reproduce
Expected behavior
Build succeeds without failure
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Digging further into this, the build fails because the
TickType_tgetstypedefed to uint16_t instead of uint32_t at https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/portable/GCC/ARM_CM3_MPU/portmacro.h#L60 even though configUSE_16_BIT_TICKS is set to 0.It seems like the backward compatibility support for
configUSE_16_BIT_TICKSadded as part of adding support for 64-bit events #597 isn't working as expected. The PR introduces a new macroconfigTICK_TYPE_WIDTH_IN_BITSwhich is undefined whenportmacro.his included in FreeRTOS.h. The macro gets defined further down in FreeRTOS.h to support backward compatibility forconfigUSE_16_BIT_TICKSmacro. Since the macroconfigTICK_TYPE_WIDTH_IN_BITSisn't undefined whenportmacro.his included,configTICK_TYPE_WIDTH_IN_BITSis evaluated as0in the expression which causes the equality to succeed andTickType_tto typedef'ed touint16_t. The undefined macros can be checked by enabling-Wundefafter https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile#L45.