feat(freertos): make num of task notifications configurable

Closes https://github.com/espressif/esp-idf/issues/9349
This commit is contained in:
Jakob Hasse 2022-10-31 18:00:52 +01:00
parent fd9c88ac85
commit 73d9d83a2f
8 changed files with 87 additions and 3 deletions

View File

@ -129,7 +129,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b
#define configUSE_QUEUE_SETS 1 #define configUSE_QUEUE_SETS 1
#define configQUEUE_REGISTRY_SIZE CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE #define configQUEUE_REGISTRY_SIZE CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE
#define configUSE_TASK_NOTIFICATIONS 1 #define configUSE_TASK_NOTIFICATIONS 1
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 #define configTASK_NOTIFICATION_ARRAY_ENTRIES CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
// ----------------------- System -------------------------- // ----------------------- System --------------------------

View File

@ -158,7 +158,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b
#define configUSE_QUEUE_SETS 1 #define configUSE_QUEUE_SETS 1
#define configQUEUE_REGISTRY_SIZE CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE #define configQUEUE_REGISTRY_SIZE CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE
#define configUSE_TASK_NOTIFICATIONS 1 #define configUSE_TASK_NOTIFICATIONS 1
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 #define configTASK_NOTIFICATION_ARRAY_ENTRIES CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
// ----------------------- System -------------------------- // ----------------------- System --------------------------

View File

@ -190,6 +190,16 @@ menu "FreeRTOS"
Note: A value of 0 will disable queue registry functionality Note: A value of 0 will disable queue registry functionality
config FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
int "configTASK_NOTIFICATION_ARRAY_ENTRIES"
range 1 32
default 1
help
Set the size of the task notification array of each task. When increasing this value, keep in
mind that this means additional memory for each and every task on the system.
However, task notifications in general are more light weight compared to alternatives
such as semaphores.
config FREERTOS_USE_TRACE_FACILITY config FREERTOS_USE_TRACE_FACILITY
bool "configUSE_TRACE_FACILITY" bool "configUSE_TRACE_FACILITY"
default n default n

View File

@ -126,7 +126,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b
#define configUSE_QUEUE_SETS 1 #define configUSE_QUEUE_SETS 1
#define configQUEUE_REGISTRY_SIZE CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE #define configQUEUE_REGISTRY_SIZE CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE
#define configUSE_TASK_NOTIFICATIONS 1 #define configUSE_TASK_NOTIFICATIONS 1
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 #define configTASK_NOTIFICATION_ARRAY_ENTRIES CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
// ----------------------- System -------------------------- // ----------------------- System --------------------------

View File

@ -196,3 +196,44 @@ TEST_CASE("Test Task_Notify", "[freertos]")
TEST_ESP_OK(gptimer_del_timer(gptimers[i])); TEST_ESP_OK(gptimer_del_timer(gptimers[i]));
} }
} }
TEST_CASE("Notify too high index fails", "[ignore]")
{
uint32_t notification_value = 47;
xTaskNotifyIndexed(xTaskGetCurrentTaskHandle(), 2, notification_value, eNoAction);
}
TEST_CASE("Notify Wait too high index fails", "[ignore]")
{
uint32_t notification_value;
xTaskNotifyWaitIndexed(2, 0, 0, &notification_value, pdMS_TO_TICKS(10));
}
#if CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES > 1
const uint32_t NOTIFICATION_VALUE_0 = 47;
const uint32_t NOTIFICATION_VALUE_1 = 48;
void notify(void *arg)
{
TaskHandle_t main_task = (TaskHandle_t) arg;
xTaskNotifyIndexed(main_task, 0, NOTIFICATION_VALUE_0, eSetValueWithOverwrite);
xTaskNotifyIndexed(main_task, 1, NOTIFICATION_VALUE_1, eSetValueWithOverwrite);
vTaskDelete(NULL);
}
static TaskHandle_t notificator_task;
TEST_CASE("Notify to different indexes works", "[freertos]")
{
uint32_t notification_value_0 = 0;
uint32_t notification_value_1 = 0;
TaskHandle_t main_task = xTaskGetCurrentTaskHandle();
xTaskCreate(notify, "notificator", 2048, main_task, 2, &notificator_task);
xTaskNotifyWaitIndexed(0, 0, 0xFFFFFFFF, &notification_value_0, pdMS_TO_TICKS(10));
xTaskNotifyWaitIndexed(1, 0, 0xFFFFFFFF, &notification_value_1, pdMS_TO_TICKS(10));
TEST_ASSERT_EQUAL(notification_value_0, NOTIFICATION_VALUE_0);
TEST_ASSERT_EQUAL(notification_value_1, NOTIFICATION_VALUE_1);
}
#endif

View File

@ -21,3 +21,25 @@ def test_freertos(dut: Dut) -> None:
dut.write('![ignore]') dut.write('![ignore]')
# All of the FreeRTOS tests combined take > 60s to run. So we use a 120s timeout # All of the FreeRTOS tests combined take > 60s to run. So we use a 120s timeout
dut.expect_unity_test_output(timeout=120) dut.expect_unity_test_output(timeout=120)
@pytest.mark.supported_targets
@pytest.mark.generic
@pytest.mark.parametrize('config', ['freertos_options'], indirect=True)
def test_task_notify_too_high_index_fails(dut: Dut) -> None:
dut.expect_exact('Press ENTER to see the list of tests.')
dut.write('\"Notify too high index fails\"')
dut.expect('assert failed: xTaskGenericNotify', timeout=5)
dut.expect('uxIndexToNotify < [0-9]+')
dut.expect_exact('Rebooting...')
@pytest.mark.supported_targets
@pytest.mark.generic
@pytest.mark.parametrize('config', ['freertos_options'], indirect=True)
def test_task_notify_wait_too_high_index_fails(dut: Dut) -> None:
dut.expect_exact('Press ENTER to see the list of tests.')
dut.write('\"Notify Wait too high index fails\"')
dut.expect('assert failed: xTaskGenericNotifyWait', timeout=5)
dut.expect('uxIndexToWait < [0-9]+', timeout=5)
dut.expect_exact('Rebooting...')

View File

@ -16,3 +16,4 @@ CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y
CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_FREERTOS_FPU_IN_ISR=y CONFIG_FREERTOS_FPU_IN_ISR=y
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2

View File

@ -18,5 +18,15 @@ menu "FreeRTOS"
more details). more details).
Note: For most uses, the default of 16 characters is sufficient. Note: For most uses, the default of 16 characters is sufficient.
config FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
int "configTASK_NOTIFICATION_ARRAY_ENTRIES"
range 1 32
default 1
help
Set the size of the task notification array of each task. When increasing this value, keep in
mind that this means additional memory for each and every task on the system.
However, task notifications in general are more light weight compared to alternatives
such as semaphores.
endmenu endmenu
endmenu endmenu