feat(freertos): Introduced new Kconfig option CONFIG_FREERTOS_NUMBER_OF_CORES
This commit replaces the use of portNUM_PROCESSORS and configNUM_CORES macros in all of ESP-IDF. These macros are needed to realize an SMP scenario by fetching the number of active cores FreeRTOS is running on. Instead, a new Kconfig option, CONFIG_FREERTOS_NUMBER_OF_CORES, has been added as a proxy for the FreeRTOS config option, configNUMBER_OF_CORES. This new commit is now used to realize an SMP scenario in various places in ESP-IDF. [Sudeep Mohanty: Added new Kconfig option CONFIG_FREERTOS_NUMBER_OF_CORES] Signed-off-by: Sudeep Mohanty <sudeep.mohanty@espressif.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
@@ -56,7 +57,7 @@ TEST_CASE("esp_rom_delay_us produces correct delay on CPUs", "[delay]")
|
||||
TEST_ASSERT(xSemaphoreTake(args.done, delay_ms * 2 / portTICK_PERIOD_MS));
|
||||
TEST_ASSERT_INT32_WITHIN(1000, args.delay_us, args.result);
|
||||
|
||||
#if portNUM_PROCESSORS == 2
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
||||
xTaskCreatePinnedToCore(test_delay_task, "", 2048, (void *)&args, 3, NULL, 1);
|
||||
TEST_ASSERT(xSemaphoreTake(args.done, delay_ms * 2 / portTICK_PERIOD_MS));
|
||||
TEST_ASSERT_INT32_WITHIN(1000, args.delay_us, args.result);
|
||||
@@ -79,7 +80,7 @@ TEST_CASE("vTaskDelay produces correct delay on CPUs", "[delay]")
|
||||
TEST_ASSERT(xSemaphoreTake(args.done, delay_ms * 2 / portTICK_PERIOD_MS));
|
||||
TEST_ASSERT_INT32_WITHIN(1000, args.delay_us, args.result);
|
||||
|
||||
#if portNUM_PROCESSORS == 2
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
||||
xTaskCreatePinnedToCore(test_delay_task, "", 2048, (void *)&args, 3, NULL, 1);
|
||||
TEST_ASSERT(xSemaphoreTake(args.done, delay_ms * 2 / portTICK_PERIOD_MS));
|
||||
TEST_ASSERT_INT32_WITHIN(1000, args.delay_us, args.result);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -111,12 +111,12 @@ TEST_CASE("Test multiple ipc_calls", "[ipc]")
|
||||
const int max_tasks = 5;
|
||||
UBaseType_t priority = uxTaskPriorityGet(NULL);
|
||||
ESP_LOGI("test", "priority = %d, cpu = %d", priority, xPortGetCoreID());
|
||||
test_semaphore_args_t test_semaphore[max_tasks * portNUM_PROCESSORS];
|
||||
test_semaphore_args_t test_semaphore[max_tasks * CONFIG_FREERTOS_NUMBER_OF_CORES];
|
||||
|
||||
for (int task_num = 0; task_num < max_tasks; ++task_num) {
|
||||
++priority;
|
||||
ESP_LOGI("test", "task prio = %d", priority);
|
||||
for (int cpu_num = 0; cpu_num < portNUM_PROCESSORS; ++cpu_num) {
|
||||
for (int cpu_num = 0; cpu_num < CONFIG_FREERTOS_NUMBER_OF_CORES; ++cpu_num) {
|
||||
unsigned i = task_num * 2 + cpu_num;
|
||||
test_semaphore[i].start = xSemaphoreCreateBinary();
|
||||
test_semaphore[i].done = xSemaphoreCreateBinary();
|
||||
@@ -124,11 +124,11 @@ TEST_CASE("Test multiple ipc_calls", "[ipc]")
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < max_tasks * portNUM_PROCESSORS; ++i) {
|
||||
for (int i = 0; i < max_tasks * CONFIG_FREERTOS_NUMBER_OF_CORES; ++i) {
|
||||
xSemaphoreGive(test_semaphore[i].start);
|
||||
}
|
||||
|
||||
for (int i = 0; i < max_tasks * portNUM_PROCESSORS; ++i) {
|
||||
for (int i = 0; i < max_tasks * CONFIG_FREERTOS_NUMBER_OF_CORES; ++i) {
|
||||
xSemaphoreTake(test_semaphore[i].done, portMAX_DELAY);
|
||||
vSemaphoreDelete(test_semaphore[i].done);
|
||||
vSemaphoreDelete(test_semaphore[i].start);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
#include <inttypes.h>
|
||||
#include "unity.h"
|
||||
#include "esp_system.h"
|
||||
@@ -211,7 +212,7 @@ static void do_restart(void)
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
#if portNUM_PROCESSORS > 1
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES > 1
|
||||
static void do_restart_from_app_cpu(void)
|
||||
{
|
||||
setup_values();
|
||||
@@ -239,7 +240,7 @@ TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_SW after restart", "[reset_reaso
|
||||
do_restart,
|
||||
check_reset_reason_sw);
|
||||
|
||||
#if portNUM_PROCESSORS > 1
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES > 1
|
||||
TEST_CASE_MULTIPLE_STAGES("reset reason ESP_RST_SW after restart from APP CPU", "[reset_reason][reset="RESET"]",
|
||||
do_restart_from_app_cpu,
|
||||
check_reset_reason_sw);
|
||||
|
||||
@@ -132,11 +132,11 @@ TEST_CASE("light sleep stress test", "[deepsleep]")
|
||||
SemaphoreHandle_t done = xSemaphoreCreateCounting(2, 0);
|
||||
esp_sleep_enable_timer_wakeup(1000);
|
||||
xTaskCreatePinnedToCore(&test_light_sleep, "ls0", 4096, done, UNITY_FREERTOS_PRIORITY + 1, NULL, 0);
|
||||
#if portNUM_PROCESSORS == 2
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
||||
xTaskCreatePinnedToCore(&test_light_sleep, "ls1", 4096, done, UNITY_FREERTOS_PRIORITY + 1, NULL, 1);
|
||||
#endif
|
||||
xSemaphoreTake(done, portMAX_DELAY);
|
||||
#if portNUM_PROCESSORS == 2
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
||||
xSemaphoreTake(done, portMAX_DELAY);
|
||||
#endif
|
||||
vSemaphoreDelete(done);
|
||||
@@ -158,11 +158,11 @@ TEST_CASE("light sleep stress test with periodic esp_timer", "[deepsleep]")
|
||||
TEST_ESP_OK(esp_timer_create(&config, &timer));
|
||||
esp_timer_start_periodic(timer, 500);
|
||||
xTaskCreatePinnedToCore(&test_light_sleep, "ls1", 4096, done, UNITY_FREERTOS_PRIORITY + 1, NULL, 0);
|
||||
#if portNUM_PROCESSORS == 2
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
||||
xTaskCreatePinnedToCore(&test_light_sleep, "ls1", 4096, done, UNITY_FREERTOS_PRIORITY + 1, NULL, 1);
|
||||
#endif
|
||||
xSemaphoreTake(done, portMAX_DELAY);
|
||||
#if portNUM_PROCESSORS == 2
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
||||
xSemaphoreTake(done, portMAX_DELAY);
|
||||
#endif
|
||||
vSemaphoreDelete(done);
|
||||
|
||||
Reference in New Issue
Block a user