Skip to content

Commit

Permalink
freertos: remove FREERTOS_ASSERT option
Browse files Browse the repository at this point in the history
Freertos asserts are now configured the same way as all other asserts in IDF,
i.e. by configuring COMPILER_OPTIMIZATION_ASSERTION_LEVEL.
  • Loading branch information
ESP-Marius committed Jan 7, 2022
1 parent 4bf67af commit 7255497
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 68 deletions.
Expand Up @@ -115,18 +115,6 @@ int xt_clock_freq(void) __attribute__((deprecated));
#endif
#endif // __ASSEMBLER__

// If CONFIG_FREERTOS_ASSERT_DISABLE is set then configASSERT is defined empty later in FreeRTOS.h and the macro
// configASSERT_DEFINED remains unset (meaning some warnings are avoided)

#if defined(CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE)
#define configASSERT(a) if (unlikely(!(a))) { \
esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \
__FUNCTION__); \
}
#elif defined(CONFIG_FREERTOS_ASSERT_FAIL_ABORT)
#define configASSERT(a) assert(a)
#endif

#if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
#define UNTESTED_FUNCTION() { esp_rom_printf("Untested FreeRTOS function %s\r\n", __FUNCTION__); configASSERT(false); } while(0)
#else
Expand Down
33 changes: 0 additions & 33 deletions components/freertos/Kconfig
Expand Up @@ -175,39 +175,6 @@ menu "FreeRTOS"
This value must be at least 1. Index 0 is reserved for use by the pthreads API
thread-local-storage. Other indexes can be used for any desired purpose.

choice FREERTOS_ASSERT
prompt "FreeRTOS assertions"
default FREERTOS_ASSERT_FAIL_ABORT if !COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
default FREERTOS_ASSERT_DISABLE if COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
help
Failed FreeRTOS configASSERT() assertions can be configured to
behave in different ways.

By default these behave the same as the global project assert settings.

config FREERTOS_ASSERT_FAIL_ABORT
bool "abort() on failed assertions"
depends on !COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
help
If a FreeRTOS configASSERT() fails, FreeRTOS will abort() and
halt execution. The panic handler can be configured to handle
the outcome of an abort() in different ways.

If assertions are disabled for the entire project, they are also
disabled in FreeRTOS and this option is unavailable.

config FREERTOS_ASSERT_FAIL_PRINT_CONTINUE
bool "Print and continue failed assertions"
help
If a FreeRTOS assertion fails, print it out and continue.

config FREERTOS_ASSERT_DISABLE
bool "Disable FreeRTOS assertions"
help
FreeRTOS configASSERT() will not be compiled into the binary.

endchoice

config FREERTOS_IDLE_TASK_STACKSIZE
int "Idle Task stack size"
range 768 32768
Expand Down
Expand Up @@ -100,17 +100,7 @@
#ifndef __ASSEMBLER__
#include <assert.h>

// If CONFIG_FREERTOS_ASSERT_DISABLE is set then configASSERT is defined empty later in FreeRTOS.h and the macro
// configASSERT_DEFINED remains unset (meaning some warnings are avoided)

#if defined(CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE)
#define configASSERT(a) if (unlikely(!(a))) { \
esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \
__FUNCTION__); \
}
#elif defined(CONFIG_FREERTOS_ASSERT_FAIL_ABORT)
#define configASSERT(a) assert(a)
#endif

#if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
#define UNTESTED_FUNCTION() { esp_rom_printf("Untested FreeRTOS function %s\r\n", __FUNCTION__); configASSERT(false); } while(0)
Expand Down
2 changes: 1 addition & 1 deletion components/freertos/test/test_freertos_mutex.c
Expand Up @@ -5,7 +5,7 @@
#include "test_utils.h"

/* If assertions aren't set to fail this code still crashes, but not with an abort... */
#if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER && CONFIG_FREERTOS_ASSERT_FAIL_ABORT
#if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER && !CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE

static void mutex_release_task(void* arg)
{
Expand Down
1 change: 0 additions & 1 deletion components/mdns/test_afl_fuzz_host/sdkconfig.h
Expand Up @@ -180,7 +180,6 @@
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
#define CONFIG_FREERTOS_INTERRUPT_BACKTRACE 1
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1
#define CONFIG_FREERTOS_IDLE_TASK_STACKSIZE 1536
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
#define CONFIG_FREERTOS_MAX_TASK_NAME_LEN 16
Expand Down
12 changes: 12 additions & 0 deletions docs/en/migration-guides/freertos.rst
@@ -0,0 +1,12 @@
Migrate FreeRTOS to ESP-IDF 5.0
==================================

Tasks Snapshot
--------------

The header ``task_snapshot.h`` has been removed from ``freertos/task.h``. ESP-IDF developers should include ``"freertos/task_snapshot.h``` in case they need tasks snapshot API.


FreeRTOS Asserts
----------------
Previously FreeRTOS asserts were configured separately from the rest of the system using the `FREERTOS_ASSERT` kconfig option. This option has now been removed and the configuration is now done through `COMPILER_OPTIMIZATION_ASSERTION_LEVEL`.
1 change: 1 addition & 0 deletions docs/en/migration-guides/index.rst
Expand Up @@ -9,5 +9,6 @@ ESP-IDF 5.0 Migration Guides
Peripherals <peripherals>
Build System <build-system>
System <system>
FreeRTOS <freertos>
Ethernet <ethernet>
Removed or deprecated components <removed-components>
5 changes: 0 additions & 5 deletions docs/en/migration-guides/system.rst
Expand Up @@ -34,11 +34,6 @@ ROM
---
Deprecated ROM related header files from `components/esp32/rom/` (old include path: `rom/*.h`) have been deleted. Please update to use the new target-specific path from `components/esp_rom/include/{IDF_TARGET_NAME}/` (new include path: `{IDF_TARGET_NAME}/rom/*.h`).

Tasks snapshot
--------------

The header ``task_snapshot.h`` has been removed from ``freertos/task.h``. ESP-IDF developers should include ``"freertos/task_snapshot.h``` in case they need tasks snapshot API.

ESP HW Support
--------------

Expand Down
1 change: 1 addition & 0 deletions docs/zh_CN/migration-guides/freertos.rst
@@ -0,0 +1 @@
.. include:: ../../en/migration-guides/freertos.rst
1 change: 1 addition & 0 deletions docs/zh_CN/migration-guides/index.rst
Expand Up @@ -9,5 +9,6 @@ ESP-IDF 5.0 迁移指南
外设 <peripherals>
构建系统 <build-system>
系统 <system>
FreeRTOS <freertos>
以太网 <ethernet>
Removed or deprecated components <removed-components>
@@ -1,5 +1,4 @@
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y
CONFIG_FREERTOS_ASSERT_DISABLE=y
CONFIG_COMPILER_HIDE_PATHS_MACROS=n

# compiling as many files as possible here (we don't have 100% coverage of course, due to config options, but
Expand Down
@@ -1,5 +1,4 @@
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y
CONFIG_FREERTOS_ASSERT_DISABLE=y
CONFIG_COMPILER_HIDE_PATHS_MACROS=n

# the other sdkconfig builds Bluedroid, build NimBLE here
Expand Down
@@ -1,5 +1,4 @@
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_FREERTOS_ASSERT_DISABLE=y
CONFIG_COMPILER_HIDE_PATHS_MACROS=n

# the other sdkconfig builds Bluedroid, build NimBLE here
Expand Down
1 change: 0 additions & 1 deletion tools/unit-test-app/configs/freertos_options
Expand Up @@ -10,7 +10,6 @@ CONFIG_FREERTOS_HZ=500
CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL=y
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
CONFIG_FREERTOS_INTERRUPT_BACKTRACE=n
CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE=y
CONFIG_FREERTOS_LEGACY_HOOKS=y
CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=y
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=10
Expand Down
1 change: 0 additions & 1 deletion tools/unit-test-app/configs/freertos_options_c3
Expand Up @@ -10,7 +10,6 @@ CONFIG_FREERTOS_HZ=500
CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL=y
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
CONFIG_FREERTOS_INTERRUPT_BACKTRACE=n
CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE=y
CONFIG_FREERTOS_LEGACY_HOOKS=y
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=y
Expand Down
1 change: 0 additions & 1 deletion tools/unit-test-app/configs/freertos_options_s2
Expand Up @@ -10,7 +10,6 @@ CONFIG_FREERTOS_HZ=500
CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL=y
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
CONFIG_FREERTOS_INTERRUPT_BACKTRACE=n
CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE=y
CONFIG_FREERTOS_LEGACY_HOOKS=y
CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=y
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=10
Expand Down

0 comments on commit 7255497

Please sign in to comment.