FreeRTOS-Kernel icon indicating copy to clipboard operation
FreeRTOS-Kernel copied to clipboard

Fix RP2040 build without configASSERT defined

Open jackwilsdon opened this issue 1 year ago • 5 comments

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.

jackwilsdon avatar Oct 31 '24 14:10 jackwilsdon

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.

ActoryOu avatar Nov 01 '24 03:11 ActoryOu

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'

jackwilsdon avatar Nov 01 '24 04:11 jackwilsdon

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.

ActoryOu avatar Nov 01 '24 06:11 ActoryOu

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.

jackwilsdon avatar Nov 01 '24 09:11 jackwilsdon

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.

ActoryOu avatar Nov 04 '24 08:11 ActoryOu