Fix RP2040 build without configASSERT defined
Description
Fixes building the RP2040 port without configASSERT defined. It seems like no other ports use configASSERT in portmacro.h, so this isn't an issue anywhere else. Normally FreeRTOS.h defines configASSERT, but that can't be included in portmacro.h.
This may be a bit easier to review with whitespace changes ignored: https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/1170/files?w=1
Test Steps
Build the RP2040 port without configASSERT defined.
Checklist:
- [ ] I have tested my changes. No regression in existing tests.
- [ ] I have modified and/or added unit-tests to cover the code changes in this Pull Request.
Related Issue
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Hello @jackwilsdon, Could you help share the compile error log when configASSERT is not defined without this PR? The fix here is inside a inline function. It should be no issue If the caller also includes the FreeRTOS.h (before portmacro.h).
Thank you.
FreeRTOS.h imports portable.h (which imports portmacro.h) before it defines a default for configASSERT.
In file included from vendor/FreeRTOS-Kernel/include/portable.h:53,
from vendor/FreeRTOS-Kernel/include/FreeRTOS.h:107,
from src/main.c:1:
vendor/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/include/portmacro.h: In function 'vPortRecursiveLock':
vendor/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/include/portmacro.h:216:5: warning: implicit declaration of function 'configASSERT' [-Wimplicit-function-declaration]
216 | configASSERT( ulLockNum < portRTOS_SPINLOCK_COUNT );
| ^~~~~~~~~~~~
/usr/lib/gcc/arm-none-eabi/13.2.1/../../../arm-none-eabi/bin/ld: vendor/FreeRTOS-Kernel/tasks.c.obj: in function `vPortRecursiveLock':
vendor/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/include/portmacro.h:216:(.text.prvCheckForRunStateChange+0x30): undefined reference to `configASSERT'
Hi @jackwilsdon,
May I know the configASSERT definition in your FreeRTOSConfig.h?
If there is no definition, would it be easier to define it to nothing like below if you don't need it?
#define configASSERT( x )
EDIT: FreeRTOS.h includes FreeRTOSConfig.h at line 58. The configASSERT is defined before including portable.h. EDIT2: Sorry that I missed the default setting part below. Let me bring the discussion back to the team then reply you. But the method I provided here should help you solve this as workaround.
Thank you.
I'm already defining an empty configASSERT as a workaround (which does fix the issue) - it'd be nice if it was consistent with other ports though.
Hi @jackwilsdon,
Thanks for your patient! We had a discussion about this topic.
We'll create a separate PR to move configASSERT definition above before including portable.h.
Then we don't need to handle this in the port layer anymore!
Will make a note here once the PR is created.
Thank you.