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:
fl0wl0w 2023-12-13 16:32:53 -06:00 committed by Sudeep Mohanty
parent b8abf75a11
commit 90d1dcfd76
91 changed files with 361 additions and 307 deletions

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*/
#include "sdkconfig.h"
#include "esp_cpu.h"
#include "esp_log.h"
#include "esp_app_trace_membufs_proto.h"
@ -56,7 +57,7 @@ static bool esp_apptrace_riscv_host_data_pending(void);
const static char *TAG = "esp_apptrace";
static esp_apptrace_riscv_ctrl_block_t s_tracing_ctrl[portNUM_PROCESSORS];
static esp_apptrace_riscv_ctrl_block_t s_tracing_ctrl[CONFIG_FREERTOS_NUMBER_OF_CORES];
esp_apptrace_hw_t *esp_apptrace_jtag_hw_get(void **data)
{

View File

@ -39,7 +39,7 @@
* Thread/Task reference
**********************************************************/
#ifdef CONFIG_BT_BLUEDROID_PINNED_TO_CORE
#define UC_TASK_PINNED_TO_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#define UC_TASK_PINNED_TO_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < CONFIG_FREERTOS_NUMBER_OF_CORES ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define UC_TASK_PINNED_TO_CORE (0)
#endif

View File

@ -823,7 +823,7 @@ static int32_t IRAM_ATTR queue_recv_from_isr_wrapper(void *queue, void *item, vo
static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static void task_delete_wrapper(void *task_handle)

View File

@ -362,7 +362,7 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba
#endif // CONFIG_BT_BLUEDROID_ENABLED
static int task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static void task_delete_wrapper(void *task_handle)
@ -1235,4 +1235,3 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)

View File

@ -636,7 +636,7 @@ static int IRAM_ATTR queue_recv_from_isr_wrapper(void *queue, void *item, void *
static int task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static void task_delete_wrapper(void *task_handle)

View File

@ -357,7 +357,7 @@ static int task_create_wrapper(void *task_func, const char *name, uint32_t stack
void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle,
(core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
(core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static void task_delete_wrapper(void *task_handle)

View File

@ -351,7 +351,7 @@ static int task_create_wrapper(void *task_func, const char *name, uint32_t stack
void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle,
(core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
(core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static void task_delete_wrapper(void *task_handle)

View File

@ -8,6 +8,7 @@
#ifndef _BLE_MESH_KERNEL_H_
#define _BLE_MESH_KERNEL_H_
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
@ -22,7 +23,7 @@ extern "C" {
#ifdef CONFIG_BT_BLUEDROID_ENABLED
#ifdef CONFIG_BT_BLUEDROID_PINNED_TO_CORE
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < CONFIG_FREERTOS_NUMBER_OF_CORES ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define BLE_MESH_ADV_TASK_CORE (0)
#endif
@ -30,7 +31,7 @@ extern "C" {
#ifdef CONFIG_BT_NIMBLE_ENABLED
#ifdef CONFIG_BT_NIMBLE_PINNED_TO_CORE
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < CONFIG_FREERTOS_NUMBER_OF_CORES ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define BLE_MESH_ADV_TASK_CORE (0)
#endif

View File

@ -20,10 +20,11 @@
#ifndef _NIMBLE_PORT_H
#define _NIMBLE_PORT_H
#include "sdkconfig.h"
#include "esp_err.h"
#include "nimble/nimble_npl.h"
#define NIMBLE_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
#define NIMBLE_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < CONFIG_FREERTOS_NUMBER_OF_CORES ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
#define NIMBLE_HS_STACK_SIZE CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE

View File

@ -6,6 +6,7 @@
#include <vector>
#include <numeric>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -105,7 +106,7 @@ TEST_CASE("static initialization guards work as expected", "[misc]")
int task_count = 0;
// four tasks competing for static initialization of one object
task_count += start_slow_init_task<1>(0, PRO_CPU_NUM);
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
task_count += start_slow_init_task<1>(1, APP_CPU_NUM);
#endif
task_count += start_slow_init_task<1>(2, PRO_CPU_NUM);
@ -113,7 +114,7 @@ TEST_CASE("static initialization guards work as expected", "[misc]")
// four tasks competing for static initialization of another object
task_count += start_slow_init_task<2>(0, PRO_CPU_NUM);
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
task_count += start_slow_init_task<2>(1, APP_CPU_NUM);
#endif
task_count += start_slow_init_task<2>(2, PRO_CPU_NUM);

View File

@ -383,7 +383,7 @@ TEST_CASE("GPIO_interrupt_on_other_CPUs_test", "[gpio]")
TaskHandle_t gpio_task_handle;
test_gpio_config_mode_input_output(TEST_GPIO_INPUT_OUTPUT_IO1);
for (int cpu_num = 1; cpu_num < portNUM_PROCESSORS; ++cpu_num) {
for (int cpu_num = 1; cpu_num < CONFIG_FREERTOS_NUMBER_OF_CORES; ++cpu_num) {
// We assume unit-test task is running on core 0, so we install gpio interrupt on other cores
edge_intr_times = 0;
TEST_ESP_OK(gpio_set_level(TEST_GPIO_INPUT_OUTPUT_IO1, 0));

View File

@ -83,7 +83,7 @@ enum {
static BaseType_t get_other_core(void)
{
return (xPortGetCoreID() + 1) % portNUM_PROCESSORS;
return (xPortGetCoreID() + 1) % CONFIG_FREERTOS_NUMBER_OF_CORES;
}
static esp_event_loop_args_t test_event_get_default_loop_args(void)
@ -267,7 +267,7 @@ TEST_CASE("can register/unregister handlers simultaneously", "[event]")
registration_arg[i].done = xSemaphoreCreateBinary();
registration_arg[i].data = &registration_data[i];
xTaskCreatePinnedToCore(test_event_simple_handler_registration_task, "register", 2048, &registration_arg[i], uxTaskPriorityGet(NULL), NULL, i % portNUM_PROCESSORS);
xTaskCreatePinnedToCore(test_event_simple_handler_registration_task, "register", 2048, &registration_arg[i], uxTaskPriorityGet(NULL), NULL, i % CONFIG_FREERTOS_NUMBER_OF_CORES);
}
// Give the semaphores to the spawned registration task
@ -311,7 +311,7 @@ TEST_CASE("can register/unregister handlers simultaneously", "[event]")
unregistration_arg[i].start = xSemaphoreCreateBinary();
unregistration_arg[i].done = xSemaphoreCreateBinary();
xTaskCreatePinnedToCore(test_event_simple_handler_registration_task, "unregister", 2048, &unregistration_arg[i], uxTaskPriorityGet(NULL), NULL, i % portNUM_PROCESSORS);
xTaskCreatePinnedToCore(test_event_simple_handler_registration_task, "unregister", 2048, &unregistration_arg[i], uxTaskPriorityGet(NULL), NULL, i % CONFIG_FREERTOS_NUMBER_OF_CORES);
}
// Give the semaphores to the spawned unregistration task
@ -390,7 +390,7 @@ TEST_CASE("can post and run events simultaneously", "[event]")
post_event_arg[i].start = xSemaphoreCreateBinary();
post_event_arg[i].done = xSemaphoreCreateBinary();
xTaskCreatePinnedToCore(test_event_post_task, "post", 2048, &post_event_arg[i], uxTaskPriorityGet(NULL), NULL, i % portNUM_PROCESSORS);
xTaskCreatePinnedToCore(test_event_post_task, "post", 2048, &post_event_arg[i], uxTaskPriorityGet(NULL), NULL, i % CONFIG_FREERTOS_NUMBER_OF_CORES);
}
for (int i = 0; i < TEST_CONFIG_TASKS_TO_SPAWN; i++) {
@ -467,7 +467,7 @@ TEST_CASE("can post and run events simultaneously with instances", "[event]")
post_event_arg[i].start = xSemaphoreCreateBinary();
post_event_arg[i].done = xSemaphoreCreateBinary();
xTaskCreatePinnedToCore(test_event_post_task, "post", 2048, &post_event_arg[i], uxTaskPriorityGet(NULL), NULL, i % portNUM_PROCESSORS);
xTaskCreatePinnedToCore(test_event_post_task, "post", 2048, &post_event_arg[i], uxTaskPriorityGet(NULL), NULL, i % CONFIG_FREERTOS_NUMBER_OF_CORES);
}
for (int i = 0; i < TEST_CONFIG_TASKS_TO_SPAWN; i++) {

View File

@ -10,6 +10,7 @@
#pragma once
#include "sdkconfig.h"
#include <stdint.h>
#include <stdbool.h>
#include "soc/soc.h"
@ -77,11 +78,11 @@ typedef struct {
void *split_addr; /*!< Main I/D splitting address */
uint32_t mem_type_mask; /*!< Memory types required to protect. See esp_mprot_mem_t enum */
size_t target_cpu_count; /*!< Real CPU/core count (max 2) */
int target_cpu[portNUM_PROCESSORS]; /*!< Array of CPU/core IDs required to receive given PMS protection */
int target_cpu[CONFIG_FREERTOS_NUMBER_OF_CORES]; /*!< Array of CPU/core IDs required to receive given PMS protection */
} esp_memp_config_t;
//2-CPU configuration
#if portNUM_PROCESSORS > 1
#if CONFIG_FREERTOS_NUMBER_OF_CORES > 1
//default IDF configuration (basic memory regions, split line detection, locked, panic mode on)
#define ESP_MEMPROT_DEFAULT_CONFIG() { \

View File

@ -900,7 +900,7 @@ esp_err_t esp_mprot_set_prot(const esp_memp_config_t *memp_config)
if (memp_config->mem_type_mask == MEMPROT_TYPE_NONE) {
return ESP_ERR_NO_MEM;
}
if (memp_config->target_cpu_count < 1 || memp_config->target_cpu_count > portNUM_PROCESSORS) {
if (memp_config->target_cpu_count < 1 || memp_config->target_cpu_count > CONFIG_FREERTOS_NUMBER_OF_CORES) {
return ESP_ERR_MEMPROT_CPUID_INVALID;
}

View File

@ -197,7 +197,7 @@ TEST_CASE("context switch saves FP registers", "[fp]")
const int prio = UNITY_FREERTOS_PRIORITY + 1;
TEST_ASSERT(xTaskCreatePinnedToCore(tskTestFP, "tsk1", 2048, &state, prio, NULL, 0));
TEST_ASSERT(xTaskCreatePinnedToCore(tskTestFP, "tsk2", 2048, &state, prio, NULL, 0));
TEST_ASSERT(xTaskCreatePinnedToCore(tskTestFP, "tsk3", 2048, &state, prio, NULL, portNUM_PROCESSORS - 1));
TEST_ASSERT(xTaskCreatePinnedToCore(tskTestFP, "tsk3", 2048, &state, prio, NULL, CONFIG_FREERTOS_NUMBER_OF_CORES - 1));
TEST_ASSERT(xTaskCreatePinnedToCore(tskTestFP, "tsk4", 2048, &state, prio, NULL, 0));
for (int i = 0; i < 4; ++i) {
TEST_ASSERT(xSemaphoreTake(state.done, pdMS_TO_TICKS(5000)));

View File

@ -127,16 +127,16 @@ static skip_light_sleep_cb_t s_periph_skip_light_sleep_cb[PERIPH_SKIP_LIGHT_SLEE
* This in turn gets used in IDLE hook to decide if `waiti` needs
* to be invoked or not.
*/
static bool s_skipped_light_sleep[portNUM_PROCESSORS];
static bool s_skipped_light_sleep[CONFIG_FREERTOS_NUMBER_OF_CORES];
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
/* When light sleep is finished on one CPU, it is possible that the other CPU
* will enter light sleep again very soon, before interrupts on the first CPU
* get a chance to run. To avoid such situation, set a flag for the other CPU to
* skip light sleep attempt.
*/
static bool s_skip_light_sleep[portNUM_PROCESSORS];
#endif // portNUM_PROCESSORS == 2
static bool s_skip_light_sleep[CONFIG_FREERTOS_NUMBER_OF_CORES];
#endif // CONFIG_FREERTOS_NUMBER_OF_CORES == 2
static _lock_t s_skip_light_sleep_lock;
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
@ -144,12 +144,12 @@ static _lock_t s_skip_light_sleep_lock;
/* A flag indicating that Idle hook has run on a given CPU;
* Next interrupt on the same CPU will take s_rtos_lock_handle.
*/
static bool s_core_idle[portNUM_PROCESSORS];
static bool s_core_idle[CONFIG_FREERTOS_NUMBER_OF_CORES];
/* When no RTOS tasks are active, these locks are released to allow going into
* a lower power mode. Used by ISR hook and idle hook.
*/
static esp_pm_lock_handle_t s_rtos_lock_handle[portNUM_PROCESSORS];
static esp_pm_lock_handle_t s_rtos_lock_handle[CONFIG_FREERTOS_NUMBER_OF_CORES];
/* Lookup table of CPU frequency configs to be used in each mode.
* Initialized by esp_pm_impl_init and modified by esp_pm_configure.
@ -185,7 +185,7 @@ static uint32_t s_light_sleep_counts, s_light_sleep_reject_counts;
/* Indicates to the ISR hook that CCOMPARE needs to be updated on the given CPU.
* Used in conjunction with cross-core interrupt to update CCOMPARE on the other CPU.
*/
static volatile bool s_need_update_ccompare[portNUM_PROCESSORS];
static volatile bool s_need_update_ccompare[CONFIG_FREERTOS_NUMBER_OF_CORES];
/* Divider and multiplier used to adjust (ccompare - ccount) duration.
* Only set to non-zero values when switch is in progress.
@ -573,7 +573,7 @@ static void IRAM_ATTR on_freq_update(uint32_t old_ticks_per_us, uint32_t ticks_p
/* Update CCOMPARE value on this CPU */
update_ccompare();
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
/* Send interrupt to the other CPU to update CCOMPARE value */
int other_core_id = (core_id == 0) ? 1 : 0;
@ -586,7 +586,7 @@ static void IRAM_ATTR on_freq_update(uint32_t old_ticks_per_us, uint32_t ticks_p
assert(false && "failed to update CCOMPARE, possible deadlock");
}
}
#endif // portNUM_PROCESSORS == 2
#endif // CONFIG_FREERTOS_NUMBER_OF_CORES == 2
s_ccount_mul = 0;
s_ccount_div = 0;
@ -759,13 +759,13 @@ static inline bool IRAM_ATTR periph_should_skip_light_sleep(void)
static inline bool IRAM_ATTR should_skip_light_sleep(int core_id)
{
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
if (s_skip_light_sleep[core_id]) {
s_skip_light_sleep[core_id] = false;
s_skipped_light_sleep[core_id] = true;
return true;
}
#endif // portNUM_PROCESSORS == 2
#endif // CONFIG_FREERTOS_NUMBER_OF_CORES == 2
if (s_mode != PM_MODE_LIGHT_SLEEP || s_is_switching || periph_should_skip_light_sleep()) {
s_skipped_light_sleep[core_id] = true;
@ -777,7 +777,7 @@ static inline bool IRAM_ATTR should_skip_light_sleep(int core_id)
static inline void IRAM_ATTR other_core_should_skip_light_sleep(int core_id)
{
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
s_skip_light_sleep[!core_id] = true;
#endif
}
@ -933,11 +933,11 @@ void esp_pm_impl_init(void)
&s_rtos_lock_handle[0]));
ESP_ERROR_CHECK(esp_pm_lock_acquire(s_rtos_lock_handle[0]));
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
ESP_ERROR_CHECK(esp_pm_lock_create(ESP_PM_CPU_FREQ_MAX, 0, "rtos1",
&s_rtos_lock_handle[1]));
ESP_ERROR_CHECK(esp_pm_lock_acquire(s_rtos_lock_handle[1]));
#endif // portNUM_PROCESSORS == 2
#endif // CONFIG_FREERTOS_NUMBER_OF_CORES == 2
/* Configure all modes to use the default CPU frequency.
* This will be modified later by a call to esp_pm_configure.
@ -997,7 +997,7 @@ void IRAM_ATTR esp_pm_impl_isr_hook(void)
#else
uint32_t state = portSET_INTERRUPT_MASK_FROM_ISR();
#endif
#if defined(CONFIG_FREERTOS_SYSTICK_USES_CCOUNT) && (portNUM_PROCESSORS == 2)
#if defined(CONFIG_FREERTOS_SYSTICK_USES_CCOUNT) && (CONFIG_FREERTOS_NUMBER_OF_CORES == 2)
if (s_need_update_ccompare[core_id]) {
update_ccompare();
s_need_update_ccompare[core_id] = false;
@ -1006,7 +1006,7 @@ void IRAM_ATTR esp_pm_impl_isr_hook(void)
}
#else
leave_idle();
#endif // CONFIG_FREERTOS_SYSTICK_USES_CCOUNT && portNUM_PROCESSORS == 2
#endif // CONFIG_FREERTOS_SYSTICK_USES_CCOUNT && CONFIG_FREERTOS_NUMBER_OF_CORES == 2
#if CONFIG_FREERTOS_SMP
portRESTORE_INTERRUPTS(state);
#else

View File

@ -281,7 +281,7 @@ TEST_CASE("vTaskDelay duration is correct with light sleep enabled", "[pm]")
printf("CPU0: %d %d\n", args.delay_us, args.result);
TEST_ASSERT_INT32_WITHIN(1000 * portTICK_PERIOD_MS * 2, 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(done_sem, delay_ms * 10 / portTICK_PERIOD_MS) );
printf("CPU1: %d %d\n", args.delay_us, args.result);

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
@ -954,8 +955,8 @@ TEST_CASE("Test ring buffer SMP", "[esp_ringbuf]")
for (int prior_mod = -1; prior_mod < 2; prior_mod++) { //Test different relative priorities
//Test every permutation of core affinity
for (int send_core = 0; send_core < portNUM_PROCESSORS; send_core++) {
for (int rec_core = 0; rec_core < portNUM_PROCESSORS; rec_core ++) {
for (int send_core = 0; send_core < CONFIG_FREERTOS_NUMBER_OF_CORES; send_core++) {
for (int rec_core = 0; rec_core < CONFIG_FREERTOS_NUMBER_OF_CORES; rec_core ++) {
esp_rom_printf("Type: %d, PM: %d, SC: %d, RC: %d\n", buf_type, prior_mod, send_core, rec_core);
xTaskCreatePinnedToCore(send_task, "send tsk", 2048, (void *)&task_args, 10 + prior_mod, NULL, send_core);
xTaskCreatePinnedToCore(rec_task, "rec tsk", 2048, (void *)&task_args, 10, NULL, rec_core);
@ -998,8 +999,8 @@ TEST_CASE("Test static ring buffer SMP", "[esp_ringbuf]")
for (int prior_mod = -1; prior_mod < 2; prior_mod++) { //Test different relative priorities
//Test every permutation of core affinity
for (int send_core = 0; send_core < portNUM_PROCESSORS; send_core++) {
for (int rec_core = 0; rec_core < portNUM_PROCESSORS; rec_core ++) {
for (int send_core = 0; send_core < CONFIG_FREERTOS_NUMBER_OF_CORES; send_core++) {
for (int rec_core = 0; rec_core < CONFIG_FREERTOS_NUMBER_OF_CORES; rec_core ++) {
esp_rom_printf("Type: %d, PM: %d, SC: %d, RC: %d\n", buf_type, prior_mod, send_core, rec_core);
xTaskCreatePinnedToCore(send_task, "send tsk", 2048, (void *)&task_args, 10 + prior_mod, NULL, send_core);
xTaskCreatePinnedToCore(rec_task, "rec tsk", 2048, (void *)&task_args, 10, NULL, rec_core);

View File

@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdint.h>
#include "esp_attr.h"
#include "esp_err.h"
@ -26,7 +27,7 @@
#define REASON_TWDT_ABORT BIT(4)
static portMUX_TYPE reason_spinlock = portMUX_INITIALIZER_UNLOCKED;
static volatile uint32_t reason[portNUM_PROCESSORS];
static volatile uint32_t reason[CONFIG_FREERTOS_NUMBER_OF_CORES];
/*
ToDo: There is a small chance the CPU already has yielded when this ISR is serviced. In that case, it's running the intended task but
@ -91,7 +92,7 @@ void esp_crosscore_int_init(void)
reason[esp_cpu_get_core_id()] = 0;
portEXIT_CRITICAL(&reason_spinlock);
esp_err_t err __attribute__((unused)) = ESP_OK;
#if portNUM_PROCESSORS > 1
#if CONFIG_FREERTOS_NUMBER_OF_CORES > 1
if (esp_cpu_get_core_id() == 0) {
err = esp_intr_alloc(ETS_FROM_CPU_INTR0_SOURCE, ESP_INTR_FLAG_IRAM, esp_crosscore_isr, (void*)&reason[0], NULL);
} else {
@ -105,7 +106,7 @@ void esp_crosscore_int_init(void)
static void IRAM_ATTR esp_crosscore_int_send(int core_id, uint32_t reason_mask)
{
assert(core_id < portNUM_PROCESSORS);
assert(core_id < CONFIG_FREERTOS_NUMBER_OF_CORES);
//Mark the reason we interrupt the other CPU
portENTER_CRITICAL_ISR(&reason_spinlock);
reason[core_id] |= reason_mask;

View File

@ -1,9 +1,10 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@ -25,14 +26,14 @@
#define IPC_STACK_SIZE (CONFIG_ESP_IPC_TASK_STACK_SIZE)
#endif //CONFIG_COMPILER_OPTIMIZATION_NONE
static DRAM_ATTR StaticSemaphore_t s_ipc_mutex_buffer[portNUM_PROCESSORS];
static DRAM_ATTR StaticSemaphore_t s_ipc_ack_buffer[portNUM_PROCESSORS];
static DRAM_ATTR StaticSemaphore_t s_ipc_mutex_buffer[CONFIG_FREERTOS_NUMBER_OF_CORES];
static DRAM_ATTR StaticSemaphore_t s_ipc_ack_buffer[CONFIG_FREERTOS_NUMBER_OF_CORES];
static TaskHandle_t s_ipc_task_handle[portNUM_PROCESSORS];
static SemaphoreHandle_t s_ipc_mutex[portNUM_PROCESSORS]; // This mutex is used as a global lock for esp_ipc_* APIs
static SemaphoreHandle_t s_ipc_ack[portNUM_PROCESSORS]; // Semaphore used to acknowledge that task was woken up,
static volatile esp_ipc_func_t s_func[portNUM_PROCESSORS] = { 0 }; // Function which should be called by high priority task
static void * volatile s_func_arg[portNUM_PROCESSORS]; // Argument to pass into s_func
static TaskHandle_t s_ipc_task_handle[CONFIG_FREERTOS_NUMBER_OF_CORES];
static SemaphoreHandle_t s_ipc_mutex[CONFIG_FREERTOS_NUMBER_OF_CORES]; // This mutex is used as a global lock for esp_ipc_* APIs
static SemaphoreHandle_t s_ipc_ack[CONFIG_FREERTOS_NUMBER_OF_CORES]; // Semaphore used to acknowledge that task was woken up,
static volatile esp_ipc_func_t s_func[CONFIG_FREERTOS_NUMBER_OF_CORES] = { 0 }; // Function which should be called by high priority task
static void * volatile s_func_arg[CONFIG_FREERTOS_NUMBER_OF_CORES]; // Argument to pass into s_func
typedef enum {
IPC_WAIT_NO = 0,
IPC_WAIT_FOR_START,
@ -114,7 +115,7 @@ static void esp_ipc_init(void)
{
char task_name[] = "ipcX"; // up to 10 ipc tasks/cores (0-9)
for (int i = 0; i < portNUM_PROCESSORS; ++i) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; ++i) {
task_name[3] = i + (char)'0';
s_ipc_mutex[i] = xSemaphoreCreateMutexStatic(&s_ipc_mutex_buffer[i]);
s_ipc_ack[i] = xSemaphoreCreateBinaryStatic(&s_ipc_ack_buffer[i]);
@ -127,7 +128,7 @@ static void esp_ipc_init(void)
static esp_err_t esp_ipc_call_and_wait(uint32_t cpu_id, esp_ipc_func_t func, void* arg, esp_ipc_wait_t wait_for)
{
if (cpu_id >= portNUM_PROCESSORS) {
if (cpu_id >= CONFIG_FREERTOS_NUMBER_OF_CORES) {
return ESP_ERR_INVALID_ARG;
}
if (s_ipc_task_handle[cpu_id] == NULL) {

View File

@ -24,8 +24,8 @@
#define MAX_HOOKS 8
static portMUX_TYPE hooks_spinlock = portMUX_INITIALIZER_UNLOCKED;
static esp_freertos_idle_cb_t idle_cb[portNUM_PROCESSORS][MAX_HOOKS] = {0};
static esp_freertos_tick_cb_t tick_cb[portNUM_PROCESSORS][MAX_HOOKS] = {0};
static esp_freertos_idle_cb_t idle_cb[CONFIG_FREERTOS_NUMBER_OF_CORES][MAX_HOOKS] = {0};
static esp_freertos_tick_cb_t tick_cb[CONFIG_FREERTOS_NUMBER_OF_CORES][MAX_HOOKS] = {0};
void IRAM_ATTR esp_vApplicationTickHook(void)
{
@ -62,7 +62,7 @@ void esp_vApplicationIdleHook(void)
esp_err_t esp_register_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t new_idle_cb, UBaseType_t cpuid)
{
if (cpuid >= portNUM_PROCESSORS) {
if (cpuid >= CONFIG_FREERTOS_NUMBER_OF_CORES) {
return ESP_ERR_INVALID_ARG;
}
portENTER_CRITICAL(&hooks_spinlock);
@ -84,7 +84,7 @@ esp_err_t esp_register_freertos_idle_hook(esp_freertos_idle_cb_t new_idle_cb)
esp_err_t esp_register_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t new_tick_cb, UBaseType_t cpuid)
{
if (cpuid >= portNUM_PROCESSORS) {
if (cpuid >= CONFIG_FREERTOS_NUMBER_OF_CORES) {
return ESP_ERR_INVALID_ARG;
}
portENTER_CRITICAL(&hooks_spinlock);
@ -106,7 +106,7 @@ esp_err_t esp_register_freertos_tick_hook(esp_freertos_tick_cb_t new_tick_cb)
void esp_deregister_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t old_idle_cb, UBaseType_t cpuid)
{
if (cpuid >= portNUM_PROCESSORS) {
if (cpuid >= CONFIG_FREERTOS_NUMBER_OF_CORES) {
return;
}
portENTER_CRITICAL(&hooks_spinlock);
@ -121,7 +121,7 @@ void esp_deregister_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t old_idle_c
void esp_deregister_freertos_idle_hook(esp_freertos_idle_cb_t old_idle_cb)
{
portENTER_CRITICAL(&hooks_spinlock);
for (int m = 0; m < portNUM_PROCESSORS; m++) {
for (int m = 0; m < CONFIG_FREERTOS_NUMBER_OF_CORES; m++) {
esp_deregister_freertos_idle_hook_for_cpu(old_idle_cb, m);
}
portEXIT_CRITICAL(&hooks_spinlock);
@ -129,7 +129,7 @@ void esp_deregister_freertos_idle_hook(esp_freertos_idle_cb_t old_idle_cb)
void esp_deregister_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t old_tick_cb, UBaseType_t cpuid)
{
if (cpuid >= portNUM_PROCESSORS) {
if (cpuid >= CONFIG_FREERTOS_NUMBER_OF_CORES) {
return;
}
portENTER_CRITICAL(&hooks_spinlock);
@ -144,7 +144,7 @@ void esp_deregister_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t old_tick_c
void esp_deregister_freertos_tick_hook(esp_freertos_tick_cb_t old_tick_cb)
{
portENTER_CRITICAL(&hooks_spinlock);
for (int m = 0; m < portNUM_PROCESSORS; m++) {
for (int m = 0; m < CONFIG_FREERTOS_NUMBER_OF_CORES; m++) {
esp_deregister_freertos_tick_hook_for_cpu(old_tick_cb, m);
}
portEXIT_CRITICAL(&hooks_spinlock);

View File

@ -30,7 +30,7 @@ typedef enum {
} stall_state_t;
static stall_state_t volatile s_stall_state = STALL_STATE_IDLE;
static int32_t volatile s_count_of_nested_calls[portNUM_PROCESSORS] = { 0 };
static int32_t volatile s_count_of_nested_calls[CONFIG_FREERTOS_NUMBER_OF_CORES] = { 0 };
static BaseType_t s_stored_interrupt_level;
static uint32_t volatile esp_ipc_isr_finish_cmd;

View File

@ -139,7 +139,7 @@ Interrupt , a high-priority interrupt, is used for several things:
.data
_lx_intr_stack:
.space LX_INTR_STACK_SIZE*portNUM_PROCESSORS /* This allocates stacks for each individual CPU. */
.space LX_INTR_STACK_SIZE*CONFIG_FREERTOS_NUMBER_OF_CORES /* This allocates stacks for each individual CPU. */
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_ESP_INT_WDT
.global _lx_intr_livelock_counter

View File

@ -86,8 +86,8 @@ static twdt_obj_t *p_twdt_obj = NULL;
#if CONFIG_FREERTOS_SMP
#define CORE_USER_NAME_LEN 8 // Long enough for "CPU XXX"
static esp_task_wdt_user_handle_t core_user_handles[portNUM_PROCESSORS] = {NULL};
static char core_user_names[portNUM_PROCESSORS][CORE_USER_NAME_LEN];
static esp_task_wdt_user_handle_t core_user_handles[CONFIG_FREERTOS_NUMBER_OF_CORES] = {NULL};
static char core_user_names[CONFIG_FREERTOS_NUMBER_OF_CORES][CORE_USER_NAME_LEN];
#endif
// ----------------------------------------------------- Private -------------------------------------------------------
@ -338,7 +338,7 @@ static UBaseType_t get_task_affinity(const TaskHandle_t xTask)
if (xTask == NULL) {
/* User entry, we cannot predict on which core it is scheduled to run,
* so let's mark all cores as failing */
#if configNUM_CORES > 1
#if CONFIG_FREERTOS_NUMBER_OF_CORES > 1
return BIT(1) | BIT(0);
#else
return BIT(0);
@ -346,7 +346,7 @@ static UBaseType_t get_task_affinity(const TaskHandle_t xTask)
}
#if CONFIG_FREERTOS_SMP
#if configNUM_CORES > 1
#if CONFIG_FREERTOS_NUMBER_OF_CORES > 1
return vTaskCoreAffinityGet(xTask);
#else
return BIT(0);
@ -487,7 +487,7 @@ static void task_wdt_isr(void *arg)
}
ESP_EARLY_LOGE(TAG, "%s", DRAM_STR("Tasks currently running:"));
for (int x = 0; x < portNUM_PROCESSORS; x++) {
for (int x = 0; x < CONFIG_FREERTOS_NUMBER_OF_CORES; x++) {
ESP_EARLY_LOGE(TAG, "CPU %d: %s", x, pcTaskGetName(xTaskGetCurrentTaskHandleForCore(x)));
}
portEXIT_CRITICAL_ISR(&spinlock);
@ -511,7 +511,7 @@ static void task_wdt_isr(void *arg)
esp_err_t esp_task_wdt_init(const esp_task_wdt_config_t *config)
{
ESP_RETURN_ON_FALSE((config != NULL && config->idle_core_mask < (1 << portNUM_PROCESSORS)), ESP_ERR_INVALID_ARG, TAG, "Invalid arguments");
ESP_RETURN_ON_FALSE((config != NULL && config->idle_core_mask < (1 << CONFIG_FREERTOS_NUMBER_OF_CORES)), ESP_ERR_INVALID_ARG, TAG, "Invalid arguments");
ESP_RETURN_ON_FALSE(p_twdt_obj == NULL, ESP_ERR_INVALID_STATE, TAG, "TWDT already initialized");
esp_err_t ret = ESP_OK;
twdt_obj_t *obj = NULL;
@ -554,7 +554,7 @@ err:
esp_err_t esp_task_wdt_reconfigure(const esp_task_wdt_config_t *config)
{
ESP_RETURN_ON_FALSE((config != NULL && config->idle_core_mask < (1 << portNUM_PROCESSORS)), ESP_ERR_INVALID_ARG, TAG, "Invalid arguments");
ESP_RETURN_ON_FALSE((config != NULL && config->idle_core_mask < (1 << CONFIG_FREERTOS_NUMBER_OF_CORES)), ESP_ERR_INVALID_ARG, TAG, "Invalid arguments");
ESP_RETURN_ON_FALSE(p_twdt_obj != NULL, ESP_ERR_INVALID_STATE, TAG, "TWDT not initialized yet");
uint32_t old_core_mask = 0;
esp_err_t ret = ESP_OK;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "sys/param.h"
#include "esp_timer_impl.h"
#include "esp_timer.h"
@ -88,7 +89,7 @@ static const char* TAG = "esp_timer_impl";
/* Interrupt handle returned by the interrupt allocator */
#ifdef CONFIG_ESP_TIMER_ISR_AFFINITY_NO_AFFINITY
#define ISR_HANDLERS (portNUM_PROCESSORS)
#define ISR_HANDLERS (CONFIG_FREERTOS_NUMBER_OF_CORES)
#else
#define ISR_HANDLERS (1)
#endif

View File

@ -40,7 +40,7 @@ static const char *TAG = "esp_timer_systimer";
/* Interrupt handle returned by the interrupt allocator */
#ifdef CONFIG_ESP_TIMER_ISR_AFFINITY_NO_AFFINITY
#define ISR_HANDLERS (portNUM_PROCESSORS)
#define ISR_HANDLERS (CONFIG_FREERTOS_NUMBER_OF_CORES)
#else
#define ISR_HANDLERS (1)
#endif

View File

@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
@ -106,14 +107,14 @@ static void set_alarm_task(void* arg)
TEST_CASE("esp_timer_impl_set_alarm stress test", "[esp_timer]")
{
SemaphoreHandle_t done = xSemaphoreCreateCounting(portNUM_PROCESSORS, 0);
SemaphoreHandle_t done = xSemaphoreCreateCounting(CONFIG_FREERTOS_NUMBER_OF_CORES, 0);
xTaskCreatePinnedToCore(&set_alarm_task, "set_alarm_0", 4096, done, UNITY_FREERTOS_PRIORITY, NULL, 0);
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
xTaskCreatePinnedToCore(&set_alarm_task, "set_alarm_1", 4096, done, UNITY_FREERTOS_PRIORITY, NULL, 1);
#endif
TEST_ASSERT(xSemaphoreTake(done, test_time_sec * 2 * 1000 / portTICK_PERIOD_MS));
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
TEST_ASSERT(xSemaphoreTake(done, test_time_sec * 2 * 1000 / portTICK_PERIOD_MS));
#endif
vSemaphoreDelete(done);
@ -458,14 +459,14 @@ TEST_CASE("esp_timer_get_time returns monotonic values", "[esp_timer]")
{
ref_clock_init();
test_monotonic_values_state_t states[portNUM_PROCESSORS] = {0};
SemaphoreHandle_t done = xSemaphoreCreateCounting(portNUM_PROCESSORS, 0);
for (int i = 0; i < portNUM_PROCESSORS; ++i) {
test_monotonic_values_state_t states[CONFIG_FREERTOS_NUMBER_OF_CORES] = {0};
SemaphoreHandle_t done = xSemaphoreCreateCounting(CONFIG_FREERTOS_NUMBER_OF_CORES, 0);
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; ++i) {
states[i].done = done;
xTaskCreatePinnedToCore(&timer_test_monotonic_values_task, "test", 4096, &states[i], 6, NULL, i);
}
for (int i = 0; i < portNUM_PROCESSORS; ++i) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; ++i) {
TEST_ASSERT_TRUE(xSemaphoreTake(done, portMAX_DELAY));
printf("CPU%d: %s test_cnt=%d error_cnt=%d avg_diff=%d |max_error|=%d\n",
i, states[i].pass ? "PASS" : "FAIL",
@ -476,7 +477,7 @@ TEST_CASE("esp_timer_get_time returns monotonic values", "[esp_timer]")
vSemaphoreDelete(done);
ref_clock_deinit();
for (int i = 0; i < portNUM_PROCESSORS; ++i) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; ++i) {
TEST_ASSERT(states[i].pass);
}
}

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@ -301,7 +302,7 @@ static uint32_t event_group_wait_bits_wrapper(void *event, uint32_t bits_to_wait
static int32_t task_create_pinned_to_core_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle)

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@ -244,7 +245,7 @@ static uint32_t event_group_wait_bits_wrapper(void *event, uint32_t bits_to_wait
static int32_t task_create_pinned_to_core_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle)

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@ -247,7 +248,7 @@ static uint32_t event_group_wait_bits_wrapper(void *event, uint32_t bits_to_wait
static int32_t task_create_pinned_to_core_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle)

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@ -250,7 +251,7 @@ static uint32_t event_group_wait_bits_wrapper(void *event, uint32_t bits_to_wait
static int32_t task_create_pinned_to_core_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle)

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@ -292,7 +293,7 @@ static uint32_t event_group_wait_bits_wrapper(void *event, uint32_t bits_to_wait
static int32_t task_create_pinned_to_core_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle)

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@ -295,7 +296,7 @@ static uint32_t event_group_wait_bits_wrapper(void *event, uint32_t bits_to_wait
static int32_t task_create_pinned_to_core_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
{
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
}
static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle)

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -263,7 +264,7 @@ TEST_CASE("(raw) multiple tasks can use same volume", "[fatfs]")
read_test_arg_t args4 = READ_TEST_ARG_INIT(names[3], 0x34343434);
const int cpuid_0 = 0;
const int cpuid_1 = portNUM_PROCESSORS - 1;
const int cpuid_1 = CONFIG_FREERTOS_NUMBER_OF_CORES - 1;
const int stack_size = 4096;
printf("reading files 1.txt 2.txt 3.txt 4.txt \n");

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -902,7 +903,7 @@ void test_fatfs_concurrent(const char* filename_prefix)
printf("writing f1 and f2\n");
const int cpuid_0 = 0;
const int cpuid_1 = portNUM_PROCESSORS - 1;
const int cpuid_1 = CONFIG_FREERTOS_NUMBER_OF_CORES - 1;
const int stack_size = 4096;
xTaskCreatePinnedToCore(&read_write_task, "rw1", stack_size, &args1, 3, NULL, cpuid_0);
xTaskCreatePinnedToCore(&read_write_task, "rw2", stack_size, &args2, 3, NULL, cpuid_1);

View File

@ -20,7 +20,7 @@ menu "FreeRTOS"
their implementation and features.
config FREERTOS_UNICORE
# Todo: Replace with CONFIG_NUM_CORES (IDF-4986)
# Todo: Replace with CONFIG_NUMBER_OF_CORES (IDF-9156)
bool "Run FreeRTOS only on first core"
default "y" if IDF_TARGET_ESP32S2 || IDF_TARGET_LINUX
select ESP_SYSTEM_SINGLE_CORE_MODE
@ -583,4 +583,12 @@ menu "FreeRTOS"
default y
depends on !ESP_PANIC_HANDLER_IRAM
config FREERTOS_NUMBER_OF_CORES
# Invisible option to configure the number of cores on which FreeRTOS runs
# Todo: Unhide this option and deprecate CONFIG_FREERTOS_UNICORE (IDF-9156)
int
range 1 2
default 1 if FREERTOS_UNICORE
default 2 if !FREERTOS_UNICORE
endmenu # FreeRTOS

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -95,6 +95,9 @@
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configKERNEL_INTERRUPT_PRIORITY 1 /*Todo: This currently isn't used anywhere */
#define configNUMBER_OF_CORES CONFIG_FREERTOS_NUMBER_OF_CORES
/* For compatibility */
#define configNUM_CORES configNUMBER_OF_CORES
/* ------------- Synchronization Primitives ---------------- */
@ -260,13 +263,6 @@
* ------------------------------------------------------------------------------------------------------------------ */
#if CONFIG_FREERTOS_SMP
#ifdef CONFIG_FREERTOS_UNICORE
#define configNUM_CORES 1
#else
#define configNUM_CORES 2
#endif /* CONFIG_FREERTOS_UNICORE */
/* For compatibility */
#define configNUMBER_OF_CORES configNUM_CORES
#define configRUN_MULTIPLE_PRIORITIES 1
#define configUSE_TASK_PREEMPTION_DISABLE 1
#endif /* CONFIG_FREERTOS_SMP */
@ -276,13 +272,6 @@
* ------------------------------------------------------------------------------------------------------------------ */
#if !CONFIG_FREERTOS_SMP
#ifdef CONFIG_FREERTOS_UNICORE
#define configNUMBER_OF_CORES 1
#else
#define configNUMBER_OF_CORES 2
#endif /* CONFIG_FREERTOS_UNICORE */
/* For compatibility */
#define configNUM_CORES configNUMBER_OF_CORES
#ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
#define configTASKLIST_INCLUDE_COREID 1
#endif /* CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID */
@ -298,4 +287,7 @@
* - Any other macros required by the rest of ESP-IDF
* ------------------------------------------------------------------------------------------------------------------ */
#define portNUM_PROCESSORS configNUM_CORES
/* portNUM_PROCESSORS is deprecated and will be removed in ESP-IDF v6.0 (IDF-8785)
* Please use the Kconfig option CONFIG_FREERTOS_NUMBER_OF_CORES instead.
*/
#define portNUM_PROCESSORS configNUMBER_OF_CORES

View File

@ -94,7 +94,7 @@ void vSystimerSetup(void)
systimer_hal_select_alarm_mode(&systimer_hal, alarm_id, SYSTIMER_ALARM_MODE_ONESHOT);
}
for (cpuid = 0; cpuid < portNUM_PROCESSORS; ++cpuid) {
for (cpuid = 0; cpuid < configNUM_CORES; ++cpuid) {
uint32_t alarm_id = SYSTIMER_ALARM_OS_TICK_CORE0 + cpuid;
/* configure the timer */

View File

@ -5,7 +5,7 @@
*/
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -61,7 +61,7 @@ TEST_CASE("FreeRTOS Event Groups", "[freertos]")
signal it, or they get out of sync.
*/
for (int c = 0; c < NUM_TASKS; c++) {
xTaskCreatePinnedToCore(task_event_group_call_response, "tsk_call_resp", 4096, (void *)c, configMAX_PRIORITIES - 1, &task_handles[c], c % portNUM_PROCESSORS);
xTaskCreatePinnedToCore(task_event_group_call_response, "tsk_call_resp", 4096, (void *)c, configMAX_PRIORITIES - 1, &task_handles[c], c % CONFIG_FREERTOS_NUMBER_OF_CORES);
}
/* Tasks all start instantly, but this task will resume running at the same time as the higher priority tasks on the
@ -115,7 +115,7 @@ TEST_CASE("FreeRTOS Event Group Sync", "[freertos]")
done_sem = xSemaphoreCreateCounting(NUM_TASKS, 0);
for (int c = 0; c < NUM_TASKS; c++) {
xTaskCreatePinnedToCore(task_test_sync, "task_test_sync", 4096, (void *)c, configMAX_PRIORITIES - 1, NULL, c % portNUM_PROCESSORS);
xTaskCreatePinnedToCore(task_test_sync, "task_test_sync", 4096, (void *)c, configMAX_PRIORITIES - 1, NULL, c % CONFIG_FREERTOS_NUMBER_OF_CORES);
}
for (int c = 0; c < NUM_TASKS; c++) {

View File

@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "FreeRTOS.h"
#include "semphr.h"
#include "freertos_test_utils.h"
#if ( configNUM_CORES > 1 )
#if ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 )
typedef struct {
const TestFunction_t pxTestCode;
@ -28,8 +29,8 @@ static void test_func_task(void * pvParameters)
void vTestOnAllCores(TestFunction_t pxTestCode, void * pvTestCodeArg, uint32_t ulStackDepth, UBaseType_t uxPriority)
{
SemaphoreHandle_t xTaskDoneSem = xSemaphoreCreateCounting(configNUM_CORES, 0);
TaskHandle_t xTaskHandles[ configNUM_CORES ];
SemaphoreHandle_t xTaskDoneSem = xSemaphoreCreateCounting(CONFIG_FREERTOS_NUMBER_OF_CORES, 0);
TaskHandle_t xTaskHandles[ CONFIG_FREERTOS_NUMBER_OF_CORES ];
TestArgs_t xTestArgs = {
.pxTestCode = pxTestCode,
.pvTestCodeArg = pvTestCodeArg,
@ -37,7 +38,7 @@ void vTestOnAllCores(TestFunction_t pxTestCode, void * pvTestCodeArg, uint32_t u
};
/* Create a separate task on each core to run the test function */
for (BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++) {
for (BaseType_t xCoreID = 0; xCoreID < CONFIG_FREERTOS_NUMBER_OF_CORES; xCoreID++) {
#if ( CONFIG_FREERTOS_SMP == 1 )
xTaskCreateAffinitySet(test_func_task,
"task",
@ -58,15 +59,15 @@ void vTestOnAllCores(TestFunction_t pxTestCode, void * pvTestCodeArg, uint32_t u
}
/* Wait for each tasks to complete test */
for (BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++) {
for (BaseType_t xCoreID = 0; xCoreID < CONFIG_FREERTOS_NUMBER_OF_CORES; xCoreID++) {
xSemaphoreTake(xTaskDoneSem, portMAX_DELAY);
}
/* Cleanup */
for (BaseType_t xCoreID = 0; xCoreID < configNUM_CORES; xCoreID++) {
for (BaseType_t xCoreID = 0; xCoreID < CONFIG_FREERTOS_NUMBER_OF_CORES; xCoreID++) {
vTaskDelete(xTaskHandles[ xCoreID ]);
}
vSemaphoreDelete(xTaskDoneSem);
}
#endif /* ( configNUM_CORES > 1 ) */
#endif /* ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 ) */

View File

@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdint.h>
#include "FreeRTOS.h"
#if ( configNUM_CORES > 1 )
#if ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 )
/**
* @brief Prototype for test function.
@ -29,4 +30,4 @@ typedef void (* TestFunction_t)(void *);
*/
void vTestOnAllCores(TestFunction_t pxTestCode, void * pvTestCodeArg, uint32_t ulStackDepth, UBaseType_t uxPriority);
#endif /* ( configNUM_CORES > 1 ) */
#endif /* ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 ) */

View File

@ -25,6 +25,7 @@
* the following test cases (see Queue Registry test cases instead)
* For more details please refer the the ESP-IDF FreeRTOS changes documentation
*/
#include "sdkconfig.h"
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
@ -167,7 +168,7 @@ TEST_CASE("Test FreeRTOS backported Queue and Semphr functions", "[freertos]")
static StackType_t task_stack[STACK_SIZE]; //Static buffer for task stack
static StaticTask_t task_buffer; //Static buffer for TCB
static bool has_run[portNUM_PROCESSORS];
static bool has_run[CONFIG_FREERTOS_NUMBER_OF_CORES];
static void task(void *arg)
{
@ -177,7 +178,7 @@ static void task(void *arg)
TEST_CASE("Test FreeRTOS static task allocation", "[freertos]")
{
for (int core = 0; core < portNUM_PROCESSORS; core++) {
for (int core = 0; core < CONFIG_FREERTOS_NUMBER_OF_CORES; core++) {
has_run[core] = false; //Clear has_run flag
TaskHandle_t handle = xTaskCreateStaticPinnedToCore(task, "static task", STACK_SIZE, NULL,
UNITY_FREERTOS_PRIORITY + 1, (StackType_t *)&task_stack,

View File

@ -12,6 +12,7 @@
*
*/
#include "sdkconfig.h"
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
@ -21,11 +22,11 @@
#include "test_utils.h"
#if (CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE > 0)
#define NO_OF_QUEUES_PER_CORE ((int)((CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE - 3)/portNUM_PROCESSORS)) //Save space for some preallocated tasks
#define NO_OF_QUEUES_TOTAL (NO_OF_QUEUES_PER_CORE * portNUM_PROCESSORS)
#define NO_OF_QUEUES_PER_CORE ((int)((CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE - 3)/CONFIG_FREERTOS_NUMBER_OF_CORES)) //Save space for some preallocated tasks
#define NO_OF_QUEUES_TOTAL (NO_OF_QUEUES_PER_CORE * CONFIG_FREERTOS_NUMBER_OF_CORES)
#define QUEUE_NAME_MAX_LENGTH 30
static SemaphoreHandle_t start_sem[portNUM_PROCESSORS];
static SemaphoreHandle_t start_sem[CONFIG_FREERTOS_NUMBER_OF_CORES];
static SemaphoreHandle_t done_sem = NULL;
static char *names[NO_OF_QUEUES_TOTAL];
static QueueHandle_t handles[NO_OF_QUEUES_TOTAL];
@ -61,18 +62,18 @@ void test_queue_registry_task(void *arg)
TEST_CASE("Test FreeRTOS Queue Registry", "[freertos]")
{
//Create synchronization semaphores and tasks to test queue registry
done_sem = xSemaphoreCreateCounting(portNUM_PROCESSORS, 0);
for (int i = 0; i < portNUM_PROCESSORS; i++) {
done_sem = xSemaphoreCreateCounting(CONFIG_FREERTOS_NUMBER_OF_CORES, 0);
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
start_sem[i] = xSemaphoreCreateBinary();
xTaskCreatePinnedToCore(test_queue_registry_task, "testing task", 4096, NULL, UNITY_FREERTOS_PRIORITY + 1, NULL, i);
}
portDISABLE_INTERRUPTS();
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
xSemaphoreGive(start_sem[i]); //Trigger start
}
portENABLE_INTERRUPTS();
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
xSemaphoreTake(done_sem, portMAX_DELAY); //Wait for tasks to complete vQueueAddToRegistry
}
for (int i = 0; i < NO_OF_QUEUES_TOTAL; i++) {
@ -81,11 +82,11 @@ TEST_CASE("Test FreeRTOS Queue Registry", "[freertos]")
}
portDISABLE_INTERRUPTS();
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
xSemaphoreGive(start_sem[i]); //Trigger start
}
portENABLE_INTERRUPTS();
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
xSemaphoreTake(done_sem, portMAX_DELAY); //Wait for tasks to complete vQueueUnregisterQueue
}
for (int i = 0; i < NO_OF_QUEUES_TOTAL; i++) {
@ -99,7 +100,7 @@ TEST_CASE("Test FreeRTOS Queue Registry", "[freertos]")
free(names[i]);
names[i] = NULL;
}
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
vSemaphoreDelete(start_sem[i]);
start_sem[i] = NULL;
}

View File

@ -1,9 +1,10 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
@ -139,16 +140,16 @@ static void send_func(void *arg)
TEST_CASE("Test queue sets multi-core", "[freertos]")
{
// Create done semaphore
done_sem = xSemaphoreCreateCounting(portNUM_PROCESSORS - 1, 0);
done_sem = xSemaphoreCreateCounting(CONFIG_FREERTOS_NUMBER_OF_CORES - 1, 0);
TEST_ASSERT_NOT_EQUAL(NULL, done_sem);
// Create queues and queue set
QueueHandle_t queues[portNUM_PROCESSORS];
QueueHandle_t queues[CONFIG_FREERTOS_NUMBER_OF_CORES];
QueueSetHandle_t queue_set;
allocate_resources(portNUM_PROCESSORS, QUEUE_LEN, queues, &queue_set);
allocate_resources(CONFIG_FREERTOS_NUMBER_OF_CORES, QUEUE_LEN, queues, &queue_set);
// Create tasks of the same priority for all cores except for core 0
for (int i = 1; i < portNUM_PROCESSORS; i++) {
for (int i = 1; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(send_func, "send", 2048, (void *)queues[i], UNITY_FREERTOS_PRIORITY, NULL, i));
}
@ -156,30 +157,30 @@ TEST_CASE("Test queue sets multi-core", "[freertos]")
send_func((void *)queues[0]);
// Wait for all other cores to be done
for (int i = 1; i < portNUM_PROCESSORS; i++) {
for (int i = 1; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
xSemaphoreTake(done_sem, portMAX_DELAY);
}
// Read queues from the queue set, then read an item from the queue
uint32_t queues_check_count[portNUM_PROCESSORS] = {0};
uint32_t queues_check_count[CONFIG_FREERTOS_NUMBER_OF_CORES] = {0};
QueueSetMemberHandle_t member = xQueueSelectFromSet(queue_set, 0);
while (member != NULL) {
// Read the core ID from the queue, check that core ID is sane
BaseType_t core_id;
TEST_ASSERT_EQUAL(pdTRUE, xQueueReceive(member, &core_id, 0));
TEST_ASSERT_LESS_THAN(portNUM_PROCESSORS, core_id);
TEST_ASSERT_LESS_THAN(CONFIG_FREERTOS_NUMBER_OF_CORES, core_id);
queues_check_count[core_id]++;
// Get next member
member = xQueueSelectFromSet(queue_set, 0);
}
// Check that all items from all queues have been read
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
TEST_ASSERT_EQUAL(QUEUE_LEN, queues_check_count[i]);
}
// Cleanup queues and queue set
free_resources(portNUM_PROCESSORS, queues, queue_set);
free_resources(CONFIG_FREERTOS_NUMBER_OF_CORES, queues, queue_set);
// Cleanup done sem
vSemaphoreDelete(done_sem);
done_sem = NULL;

View File

@ -1,9 +1,10 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "unity.h"
@ -49,13 +50,13 @@ static void loop_task(void *arg)
TEST_CASE("Test eTaskGetState", "[freertos]")
{
TaskHandle_t blocked_tasks[portNUM_PROCESSORS];
TaskHandle_t suspended_tasks[portNUM_PROCESSORS];
TaskHandle_t ready_tasks[portNUM_PROCESSORS];
TaskHandle_t running_tasks[portNUM_PROCESSORS];
TaskHandle_t blocked_tasks[CONFIG_FREERTOS_NUMBER_OF_CORES];
TaskHandle_t suspended_tasks[CONFIG_FREERTOS_NUMBER_OF_CORES];
TaskHandle_t ready_tasks[CONFIG_FREERTOS_NUMBER_OF_CORES];
TaskHandle_t running_tasks[CONFIG_FREERTOS_NUMBER_OF_CORES];
// Create tasks of each state on each core
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
TEST_ASSERT_EQUAL(pdPASS, xTaskCreatePinnedToCore(blocked_task, "blkd", configMINIMAL_STACK_SIZE * 2, NULL, UNITY_FREERTOS_PRIORITY - 1, &blocked_tasks[i], i));
TEST_ASSERT_EQUAL(pdPASS, xTaskCreatePinnedToCore(suspended_task, "susp", configMINIMAL_STACK_SIZE * 2, NULL, UNITY_FREERTOS_PRIORITY - 1, &suspended_tasks[i], i));
TEST_ASSERT_EQUAL(pdPASS, xTaskCreatePinnedToCore(loop_task, "rdy", configMINIMAL_STACK_SIZE * 2, NULL, UNITY_FREERTOS_PRIORITY - 1, &ready_tasks[i], i));
@ -70,7 +71,7 @@ TEST_CASE("Test eTaskGetState", "[freertos]")
vTaskDelay(10);
// Check the state of the created tasks
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
TEST_ASSERT_EQUAL(eBlocked, eTaskGetState(blocked_tasks[i]));
TEST_ASSERT_EQUAL(eSuspended, eTaskGetState(suspended_tasks[i]));
TEST_ASSERT_EQUAL(eReady, eTaskGetState(ready_tasks[i]));
@ -78,7 +79,7 @@ TEST_CASE("Test eTaskGetState", "[freertos]")
}
// Clean up created tasks
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
vTaskDelete(blocked_tasks[i]);
vTaskDelete(suspended_tasks[i]);
vTaskDelete(ready_tasks[i]);

View File

@ -58,7 +58,7 @@ TEST_CASE("FreeRTOS tick hook", "[freertos]")
const unsigned SLEEP_FOR = 20;
tick_count = before;
vTaskDelay(SLEEP_FOR);
TEST_ASSERT_UINT32_WITHIN_MESSAGE(3 * portNUM_PROCESSORS, before + SLEEP_FOR * portNUM_PROCESSORS, tick_count,
TEST_ASSERT_UINT32_WITHIN_MESSAGE(3 * CONFIG_FREERTOS_NUMBER_OF_CORES, before + SLEEP_FOR * CONFIG_FREERTOS_NUMBER_OF_CORES, tick_count,
"The FreeRTOS tick hook should have been called approx 1 time per tick per CPU");
}
@ -81,7 +81,7 @@ void vTaskPreDeletionHook(void *pxTCB)
TEST_CASE("static task cleanup hook is called based on config", "[freertos]")
{
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
printf("Creating task CPU %d\n", i);
TaskHandle_t new_task = NULL;
deleted_tcb = NULL;

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdbool.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
@ -51,7 +52,7 @@ Test flow as follows:
static QueueHandle_t core0_run_order_queue;
static QueueHandle_t core1_run_order_queue;
static uint32_t total_iter_count[configNUM_CORES] = {0};
static uint32_t total_iter_count[CONFIG_FREERTOS_NUMBER_OF_CORES] = {0};
static void spin_task(void *arg)
{

View File

@ -17,7 +17,7 @@
* deletion callbacks will still be carried out by the Idle Task.
*/
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -57,7 +57,7 @@ TEST_CASE("FreeRTOS Delete Tasks", "[freertos]")
/* -------------- Test vTaskDelete() on currently running tasks ----------------*/
uint32_t before_count = uxTaskGetNumberOfTasks();
uint32_t before_heap = heap_caps_get_free_size(HEAP_CAPS);
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
for (int j = 0; j < NO_OF_TSKS; j++) {
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(tsk_self_del, "tsk_self", 1024, NULL, configMAX_PRIORITIES - 1, NULL, i));
}
@ -116,8 +116,8 @@ static void tsk_blocks_frequently(void *param)
TEST_CASE("FreeRTOS Delete Blocked Tasks", "[freertos]")
{
TaskHandle_t blocking_tasks[portNUM_PROCESSORS + 1]; // one per CPU, plus one unpinned task
tsk_blocks_param_t params[portNUM_PROCESSORS + 1] = { 0 };
TaskHandle_t blocking_tasks[CONFIG_FREERTOS_NUMBER_OF_CORES + 1]; // one per CPU, plus one unpinned task
tsk_blocks_param_t params[CONFIG_FREERTOS_NUMBER_OF_CORES + 1] = { 0 };
unsigned before = heap_caps_get_free_size(MALLOC_CAP_8BIT);
printf("Free memory at start %u\n", before);
@ -131,19 +131,19 @@ TEST_CASE("FreeRTOS Delete Blocked Tasks", "[freertos]")
for (unsigned iter = 0; iter < 1000; iter++) {
// Create everything
SemaphoreHandle_t sem = xSemaphoreCreateMutex();
for (unsigned i = 0; i < portNUM_PROCESSORS + 1; i++) {
for (unsigned i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES + 1; i++) {
params[i].deleted = false;
params[i].sem = sem;
TEST_ASSERT_EQUAL(pdTRUE,
xTaskCreatePinnedToCore(tsk_blocks_frequently, "tsk_block", 4096, &params[i],
UNITY_FREERTOS_PRIORITY - 1, &blocking_tasks[i],
i < portNUM_PROCESSORS ? i : tskNO_AFFINITY));
i < CONFIG_FREERTOS_NUMBER_OF_CORES ? i : tskNO_AFFINITY));
}
vTaskDelay(5); // Let the tasks juggle the mutex for a bit
for (unsigned i = 0; i < portNUM_PROCESSORS + 1; i++) {
for (unsigned i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES + 1; i++) {
vTaskDelete(blocking_tasks[i]);
params[i].deleted = true;
}

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -11,6 +11,7 @@
vTaskNotifyGiveFromISR(), whereas the receiver task will test
xTaskNotifyWait() and ulTaskNotifyTake().
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
@ -28,7 +29,7 @@ static uint32_t send_core_message = 0;
static TaskHandle_t recv_task_handle;
static bool isr_give = false;
static bool test_start = false;
static gptimer_handle_t gptimers[portNUM_PROCESSORS];
static gptimer_handle_t gptimers[CONFIG_FREERTOS_NUMBER_OF_CORES];
static SemaphoreHandle_t trigger_send_semphr;
static SemaphoreHandle_t task_delete_semphr;
@ -155,7 +156,7 @@ TEST_CASE("Test Task_Notify", "[freertos]")
test_start = false;
trigger_send_semphr = xSemaphoreCreateBinary();
task_delete_semphr = xQueueCreateCountingSemaphore(10, 0);
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
xTaskCreatePinnedToCore(install_gptimer_on_core, "install_gptimer", 4096, (void *const)i, UNITY_FREERTOS_PRIORITY + 1, NULL, i);
TEST_ASSERT(xSemaphoreTake(task_delete_semphr, pdMS_TO_TICKS(1000)));
}
@ -163,8 +164,8 @@ TEST_CASE("Test Task_Notify", "[freertos]")
vTaskDelay(10);
// test start
test_start = true;
for (int i = 0; i < portNUM_PROCESSORS; i++) { //Sending Core
for (int j = 0; j < portNUM_PROCESSORS; j++) { //Receiving Core
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) { //Sending Core
for (int j = 0; j < CONFIG_FREERTOS_NUMBER_OF_CORES; j++) { //Receiving Core
//Reset Values
notifs_sent = 0;
notifs_rec = 0;
@ -190,7 +191,7 @@ TEST_CASE("Test Task_Notify", "[freertos]")
//Delete Semaphroes and timer ISRs
vSemaphoreDelete(trigger_send_semphr);
vSemaphoreDelete(task_delete_semphr);
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
TEST_ESP_OK(gptimer_disable(gptimers[i]));
TEST_ESP_OK(gptimer_del_timer(gptimers[i]));
}

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
@ -26,7 +27,7 @@ TEST_CASE("FreeRTOS xTaskGetHandle()", "[freertos]")
{
vTaskDelay(10); //Small delay to let init/daemon tasks finish running
for (int core = 0; core < configNUM_CORES; core++) {
for (int core = 0; core < CONFIG_FREERTOS_NUMBER_OF_CORES; core++) {
TaskHandle_t test_task_hdl;
TaskHandle_t ret_task_hdl;
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(test_task_get_handle, "test0", 1024, NULL, UNITY_FREERTOS_PRIORITY + 1, &test_task_hdl, core));
@ -85,7 +86,7 @@ TEST_CASE("FreeRTOS xTaskAbortDelay()", "[freertos]")
test_objs.stream_buffer = xStreamBufferCreate(STREAM_BUFFER_LEN, 1);
test_objs.evt_grp = xEventGroupCreate();
for (int core = 0; core < configNUM_CORES; core++) {
for (int core = 0; core < CONFIG_FREERTOS_NUMBER_OF_CORES; core++) {
//Take the MUX so that test task will block on it
TEST_ASSERT_EQUAL(pdTRUE, xSemaphoreTake(test_objs.mux, 0));

View File

@ -13,6 +13,7 @@
*
* Note: uxTaskGetSystemState() is tested in a separate unit test
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -26,7 +27,7 @@
#ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY
#define TSK_PRIORITY (UNITY_FREERTOS_PRIORITY + 1)
#define NO_OF_CORES portNUM_PROCESSORS
#define NO_OF_CORES CONFIG_FREERTOS_NUMBER_OF_CORES
#define BIN_SEM_QUEUE_TYPE queueQUEUE_TYPE_BINARY_SEMAPHORE //Expected Queue Type
static QueueHandle_t test_queues[NO_OF_CORES];

View File

@ -85,7 +85,7 @@ TEST_CASE("Yield from lower priority task, same CPU", "[freertos]")
}
}
#if (portNUM_PROCESSORS == 2) && !CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH
#if (CONFIG_FREERTOS_NUMBER_OF_CORES == 2) && !CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH
TEST_CASE("Yield from lower priority task, other CPU", "[freertos]")
{
uint32_t trigger_ccount, yield_ccount, now_ccount, delta;

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "FreeRTOS.h"
#include "task.h"
#include "unity.h"
@ -28,7 +29,7 @@ Expected:
- task_B should never have run
*/
#if ( configNUM_CORES == 1 )
#if ( CONFIG_FREERTOS_NUMBER_OF_CORES == 1 )
#define UNITY_TASK_DELAY_TICKS 10
@ -79,4 +80,4 @@ TEST_CASE("Tasks: Test priority scheduling", "[freertos]")
vTaskPrioritySet(NULL, configTEST_UNITY_TASK_PRIORITY);
}
#endif /* configNUM_CORES == 1 */
#endif /* CONFIG_FREERTOS_NUMBER_OF_CORES == 1 */

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -31,13 +31,13 @@ Expected:
- None of the task_Bs should have run
*/
#if ( defined( CONFIG_FREERTOS_SMP ) && ( configNUM_CORES > 1 ) && ( configRUN_MULTIPLE_PRIORITIES == 1 ) ) \
|| ( !defined( CONFIG_FREERTOS_SMP ) && ( configNUM_CORES > 1 ) )
#if ( defined( CONFIG_FREERTOS_SMP ) && ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 ) && ( configRUN_MULTIPLE_PRIORITIES == 1 ) ) \
|| ( !defined( CONFIG_FREERTOS_SMP ) && ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 ) )
#define UNITY_TASK_DELAY_TICKS 10
static BaseType_t task_A_ran[configNUM_CORES];
static BaseType_t task_B_ran[configNUM_CORES];
static BaseType_t task_A_ran[CONFIG_FREERTOS_NUMBER_OF_CORES];
static BaseType_t task_B_ran[CONFIG_FREERTOS_NUMBER_OF_CORES];
static void task_A(void *arg)
{
@ -61,8 +61,8 @@ static void task_B(void *arg)
TEST_CASE("Tasks: Test priority scheduling (SMP)", "[freertos]")
{
TaskHandle_t task_A_handles[configNUM_CORES];
TaskHandle_t task_B_handles[configNUM_CORES];
TaskHandle_t task_A_handles[CONFIG_FREERTOS_NUMBER_OF_CORES];
TaskHandle_t task_B_handles[CONFIG_FREERTOS_NUMBER_OF_CORES];
memset(task_A_ran, pdFALSE, sizeof(task_A_ran));
memset(task_B_ran, pdFALSE, sizeof(task_B_ran));
@ -70,12 +70,12 @@ TEST_CASE("Tasks: Test priority scheduling (SMP)", "[freertos]")
vTaskPrioritySet(NULL, configMAX_PRIORITIES - 1);
/* Create task_A for each core */
for (UBaseType_t x = 0; x < configNUM_CORES; x++) {
for (UBaseType_t x = 0; x < CONFIG_FREERTOS_NUMBER_OF_CORES; x++) {
xTaskCreate(task_A, "task_A", configTEST_DEFAULT_STACK_SIZE, (void *)x, configMAX_PRIORITIES - 2, &task_A_handles[x]);
}
/* Create task_B for each core */
for (UBaseType_t x = 0; x < configNUM_CORES; x++) {
for (UBaseType_t x = 0; x < CONFIG_FREERTOS_NUMBER_OF_CORES; x++) {
xTaskCreate(task_B, "task_B", configTEST_DEFAULT_STACK_SIZE, (void *)x, configMAX_PRIORITIES - 3, &task_B_handles[x]);
}
@ -83,13 +83,13 @@ TEST_CASE("Tasks: Test priority scheduling (SMP)", "[freertos]")
vTaskDelay(UNITY_TASK_DELAY_TICKS);
/* Check that all the task_As have run, and none of the task_Bs have run */
for (UBaseType_t x = 0; x < configNUM_CORES; x++) {
for (UBaseType_t x = 0; x < CONFIG_FREERTOS_NUMBER_OF_CORES; x++) {
TEST_ASSERT_EQUAL(pdTRUE, task_A_ran[x]);
TEST_ASSERT_EQUAL(pdFALSE, task_B_ran[x]);
}
/* Cleanup */
for (UBaseType_t x = 0; x < configNUM_CORES; x++) {
for (UBaseType_t x = 0; x < CONFIG_FREERTOS_NUMBER_OF_CORES; x++) {
vTaskDelete(task_A_handles[x]);
vTaskDelete(task_B_handles[x]);
}
@ -98,5 +98,5 @@ TEST_CASE("Tasks: Test priority scheduling (SMP)", "[freertos]")
vTaskPrioritySet(NULL, configTEST_UNITY_TASK_PRIORITY);
}
#endif /* ( defined( CONFIG_FREERTOS_SMP ) && ( configNUM_CORES > 1 ) && ( configRUN_MULTIPLE_PRIORITIES == 1 ) )
|| ( !defined( CONFIG_FREERTOS_SMP ) && ( configNUM_CORES > 1 ) ) */
#endif /* ( defined( CONFIG_FREERTOS_SMP ) && ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 ) && ( configRUN_MULTIPLE_PRIORITIES == 1 ) )
|| ( !defined( CONFIG_FREERTOS_SMP ) && ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 ) ) */

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
@ -79,7 +80,7 @@ TEST_CASE("Tasks: Test vTaskDelay", "[freertos]")
{
portTEST_REF_CLOCK_INIT();
#if ( configNUM_CORES > 1 )
#if ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 )
vTestOnAllCores(test_vTaskDelay, NULL, configTEST_DEFAULT_STACK_SIZE, configTEST_UNITY_TASK_PRIORITY - 1);
#else
/* Test vTaskDelay directly on the current core */
@ -166,7 +167,7 @@ TEST_CASE("Tasks: Test vTaskDelayUntil", "[freertos]")
{
portTEST_REF_CLOCK_INIT();
#if ( configNUM_CORES > 1 )
#if ( CONFIG_FREERTOS_NUMBER_OF_CORES > 1 )
vTestOnAllCores(test_vTaskDelayUntil, NULL, configTEST_DEFAULT_STACK_SIZE, configTEST_UNITY_TASK_PRIORITY - 1);
#else
/* Test vTaskDelay directly on the current core */

View File

@ -11,7 +11,7 @@
#include <esp_types.h>
#include <stdio.h>
#include <strings.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "unity.h"
@ -28,20 +28,20 @@ static void counter_task(void *param)
TEST_CASE("Get/Set Priorities", "[freertos]")
{
/* Two tasks per processor */
TaskHandle_t tasks[portNUM_PROCESSORS][2] = { 0 };
unsigned volatile counters[portNUM_PROCESSORS][2] = { 0 };
TaskHandle_t tasks[CONFIG_FREERTOS_NUMBER_OF_CORES][2] = { 0 };
unsigned volatile counters[CONFIG_FREERTOS_NUMBER_OF_CORES][2] = { 0 };
TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY, uxTaskPriorityGet(NULL));
/* create a matrix of counter tasks on each core */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < CONFIG_FREERTOS_NUMBER_OF_CORES; cpu++) {
for (int task = 0; task < 2; task++) {
xTaskCreatePinnedToCore(counter_task, "count", 2048, (void *) & (counters[cpu][task]), UNITY_FREERTOS_PRIORITY - task, &(tasks[cpu][task]), cpu);
}
}
/* check they were created with the expected priorities */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < CONFIG_FREERTOS_NUMBER_OF_CORES; cpu++) {
for (int task = 0; task < 2; task++) {
TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY - task, uxTaskPriorityGet(tasks[cpu][task]));
}
@ -50,25 +50,25 @@ TEST_CASE("Get/Set Priorities", "[freertos]")
vTaskDelay(10);
/* at this point, only the higher priority tasks (first index) should be counting */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < CONFIG_FREERTOS_NUMBER_OF_CORES; cpu++) {
TEST_ASSERT_NOT_EQUAL(0, counters[cpu][0]);
TEST_ASSERT_EQUAL(0, counters[cpu][1]);
}
/* swap priorities! */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < CONFIG_FREERTOS_NUMBER_OF_CORES; cpu++) {
vTaskPrioritySet(tasks[cpu][0], UNITY_FREERTOS_PRIORITY - 1);
vTaskPrioritySet(tasks[cpu][1], UNITY_FREERTOS_PRIORITY);
}
/* check priorities have swapped... */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < CONFIG_FREERTOS_NUMBER_OF_CORES; cpu++) {
TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY - 1, uxTaskPriorityGet(tasks[cpu][0]));
TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY, uxTaskPriorityGet(tasks[cpu][1]));
}
/* check the tasks which are counting have also swapped now... */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < CONFIG_FREERTOS_NUMBER_OF_CORES; cpu++) {
unsigned old_counters[2];
old_counters[0] = counters[cpu][0];
old_counters[1] = counters[cpu][1];
@ -78,7 +78,7 @@ TEST_CASE("Get/Set Priorities", "[freertos]")
}
/* clean up */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < CONFIG_FREERTOS_NUMBER_OF_CORES; cpu++) {
for (int task = 0; task < 2; task++) {
vTaskDelete(tasks[cpu][task]);
}

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -206,10 +206,10 @@ static void test_multicore_taskB(void *arg)
TEST_CASE("Test vTaskSuspendAll() and xTaskResumeAll() multicore", "[freertos]")
{
SemaphoreHandle_t done_sem = xSemaphoreCreateCounting(portNUM_PROCESSORS, 0);
SemaphoreHandle_t done_sem = xSemaphoreCreateCounting(CONFIG_FREERTOS_NUMBER_OF_CORES, 0);
TEST_ASSERT_NOT_EQUAL(NULL, done_sem);
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
// Create tasks on core A and core B
TaskHandle_t taskA_hdl;
TaskHandle_t taskB_hdl;
@ -369,10 +369,10 @@ static void test_unblk_b1_task(void *arg)
TEST_CASE("Test vTaskSuspendAll allows scheduling on other cores", "[freertos]")
{
test_unblk_done_sem = xSemaphoreCreateCounting(portNUM_PROCESSORS, 0);
test_unblk_done_sem = xSemaphoreCreateCounting(CONFIG_FREERTOS_NUMBER_OF_CORES, 0);
TEST_ASSERT_NOT_EQUAL(NULL, test_unblk_done_sem);
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
test_unblk_sync = 0;
// Create a tasks
TaskHandle_t a1_task_hdl;
@ -571,7 +571,7 @@ static void test_pended_running_task(void *arg)
// Created blocked tasks pinned to each core
for (int i = 0; i < TEST_PENDED_NUM_BLOCKED_TASKS; i++) {
has_run[i] = false;
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(test_pended_blkd_task, "blkd", 4096, (void *)&has_run[i], UNITY_FREERTOS_PRIORITY + 2, &blkd_tsks[i], i % portNUM_PROCESSORS));
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(test_pended_blkd_task, "blkd", 4096, (void *)&has_run[i], UNITY_FREERTOS_PRIORITY + 2, &blkd_tsks[i], i % CONFIG_FREERTOS_NUMBER_OF_CORES));
}
vTaskDelay(10);
@ -626,7 +626,7 @@ static void test_pended_running_task(void *arg)
TEST_CASE("Test xTaskResumeAll resumes pended tasks", "[freertos]")
{
// Run the test on each core
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
TaskHandle_t susp_tsk_hdl;
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(test_pended_running_task, "susp", 2048, (void *)xTaskGetCurrentTaskHandle(), UNITY_FREERTOS_PRIORITY + 1, &susp_tsk_hdl, i));
// Wait for to be notified to test completion
@ -673,7 +673,7 @@ static void test_susp_task(void *arg)
vTaskSuspendAll();
for (int i = 0; i < TEST_PENDED_NUM_BLOCKED_TASKS; i++) {
if ((i % portNUM_PROCESSORS) == xPortGetCoreID()) {
if ((i % CONFIG_FREERTOS_NUMBER_OF_CORES) == xPortGetCoreID()) {
// Unblock the blocked tasks pinned to this core.
// We use the FromISR() call to create an ISR scenario and to force the unblocked task to be placed
// on the pending ready list
@ -704,7 +704,7 @@ TEST_CASE("Test xTaskSuspendAll on all cores pends all tasks and xTaskResumeAll
// Creat blocked tasks pinned to each core
for (int i = 0; i < TEST_PENDED_NUM_BLOCKED_TASKS; i++) {
has_run[i] = false;
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(test_pended_blkd_task, "blkd", 4096, (void *)&has_run[i], UNITY_FREERTOS_PRIORITY + 2, &blkd_tasks[i], i % portNUM_PROCESSORS));
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(test_pended_blkd_task, "blkd", 4096, (void *)&has_run[i], UNITY_FREERTOS_PRIORITY + 2, &blkd_tasks[i], i % CONFIG_FREERTOS_NUMBER_OF_CORES));
}
vTaskDelay(10);
@ -716,7 +716,7 @@ TEST_CASE("Test xTaskSuspendAll on all cores pends all tasks and xTaskResumeAll
vTaskSuspendAll();
for (int i = 0; i < TEST_PENDED_NUM_BLOCKED_TASKS; i++) {
if ((i % portNUM_PROCESSORS) == xPortGetCoreID()) {
if ((i % CONFIG_FREERTOS_NUMBER_OF_CORES) == xPortGetCoreID()) {
// Unblock the blocked tasks pinned to this core.
// We use the FromISR() call to create an ISR scenario and to force the unblocked task to be placed
// on the pending ready list

View File

@ -8,6 +8,7 @@
* Unit tests for FreeRTOS task yielding
*/
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -445,7 +446,7 @@ TEST_CASE("Task yield must happed when a task raises the priority of another pri
TEST_ASSERT_EQUAL(2, task_yield_sequence[idx++]);
}
#if (portNUM_PROCESSORS > 1) && !(CONFIG_FREERTOS_UNICORE)
#if (CONFIG_FREERTOS_NUMBER_OF_CORES > 1) && !(CONFIG_FREERTOS_UNICORE)
/*
* Test yielding behavior when a task on one core forces an yield on the other core
*
@ -655,4 +656,4 @@ TEST_CASE("Task yield on other core must not happen when scheduler is suspended"
TEST_ASSERT_EQUAL(2, task_yield_sequence[idx1++]);
}
#endif // !CONFIG_FREERTOS_SMP
#endif // (portNUM_PROCESSORS > 1) && !(CONFIG_FREERTOS_UNICORE)
#endif // (CONFIG_FREERTOS_NUMBER_OF_CORES > 1) && !(CONFIG_FREERTOS_UNICORE)

View File

@ -11,7 +11,7 @@
#include <esp_types.h>
#include <stdio.h>
#include <stdlib.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -50,7 +50,7 @@ TEST_CASE("Test for per-task non-reentrant tasks", "[freertos]")
const uint32_t stack_size = 3072;
xTaskCreatePinnedToCore(tskTestRand, "tsk1", stack_size, (void *)100, 3, NULL, 0);
xTaskCreatePinnedToCore(tskTestRand, "tsk2", stack_size, (void *)200, 3, NULL, 0);
xTaskCreatePinnedToCore(tskTestRand, "tsk3", stack_size, (void *)300, 3, NULL, portNUM_PROCESSORS - 1);
xTaskCreatePinnedToCore(tskTestRand, "tsk3", stack_size, (void *)300, 3, NULL, CONFIG_FREERTOS_NUMBER_OF_CORES - 1);
xTaskCreatePinnedToCore(tskTestRand, "tsk4", stack_size, (void *)400, 3, NULL, 0);
while (done != 4) {
vTaskDelay(1000 / portTICK_PERIOD_MS);

View File

@ -64,33 +64,33 @@ static void pinned_task(void *arg)
TEST_CASE("FPU: Usage in task", "[freertos]")
{
SemaphoreHandle_t done_sem = xSemaphoreCreateCounting(configNUM_CORES * TEST_PINNED_NUM_TASKS, 0);
SemaphoreHandle_t done_sem = xSemaphoreCreateCounting(CONFIG_FREERTOS_NUMBER_OF_CORES * TEST_PINNED_NUM_TASKS, 0);
TEST_ASSERT_NOT_EQUAL(NULL, done_sem);
for (int iter = 0; iter < TEST_PINNED_NUM_ITERS; iter++) {
TaskHandle_t task_handles[configNUM_CORES][TEST_PINNED_NUM_TASKS];
TaskHandle_t task_handles[CONFIG_FREERTOS_NUMBER_OF_CORES][TEST_PINNED_NUM_TASKS];
// Create test tasks for each core
for (int i = 0; i < configNUM_CORES; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
for (int j = 0; j < TEST_PINNED_NUM_TASKS; j++) {
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(pinned_task, "task", 4096, (void *)done_sem, UNITY_FREERTOS_PRIORITY + 1, &task_handles[i][j], i));
}
}
// Start the created tasks simultaneously
for (int i = 0; i < configNUM_CORES; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
for (int j = 0; j < TEST_PINNED_NUM_TASKS; j++) {
xTaskNotifyGive(task_handles[i][j]);
}
}
// Wait for the tasks to complete
for (int i = 0; i < configNUM_CORES * TEST_PINNED_NUM_TASKS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES * TEST_PINNED_NUM_TASKS; i++) {
xSemaphoreTake(done_sem, portMAX_DELAY);
}
// Delete the tasks
for (int i = 0; i < configNUM_CORES; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
for (int j = 0; j < TEST_PINNED_NUM_TASKS; j++) {
vTaskDelete(task_handles[i][j]);
}
@ -123,7 +123,7 @@ Expected:
- Each task cleans up its FPU context on deletion
*/
#if configNUM_CORES > 1
#if CONFIG_FREERTOS_NUMBER_OF_CORES > 1
#define TEST_UNPINNED_NUM_ITERS 5
@ -248,5 +248,5 @@ TEST_CASE("FPU: Unsolicited context switch between tasks using FPU", "[freertos]
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
}
#endif // configNUM_CORES > 1
#endif // CONFIG_FREERTOS_NUMBER_OF_CORES > 1
#endif // SOC_CPU_HAS_FPU

View File

@ -51,7 +51,7 @@ TEST_CASE("xPortInIsrContext test", "[freertos]")
{
xTaskCreatePinnedToCore(testthread, "tst", 4096, NULL, 3, NULL, 0);
vTaskDelay(150 / portTICK_PERIOD_MS);
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
xTaskCreatePinnedToCore(testthread, "tst", 4096, NULL, 3, NULL, 1);
vTaskDelay(150 / portTICK_PERIOD_MS);
#endif

View File

@ -11,7 +11,7 @@
#include <esp_types.h>
#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -78,7 +78,7 @@ TEST_CASE("portMUX recursive locks (no contention)", "[freertos]")
BENCHMARK_END("no contention recursive");
}
#if portNUM_PROCESSORS == 2
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
static volatile int shared_value;
static portMUX_TYPE *shared_mux;
@ -164,6 +164,6 @@ TEST_CASE("portMUX high contention, PSRAM", "[freertos]")
}
#endif// CONFIG_SPIRAM_USE_MALLOC || CONFIG_SPIRAM_USE_CAPS_ALLOC
#endif // portNUM_PROCESSORS == 2
#endif // CONFIG_FREERTOS_NUMBER_OF_CORES == 2
#endif // !CONFIG_FREERTOS_SMP

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -60,17 +60,17 @@ static void tlsp_task(void *arg)
TEST_CASE("Test TLSP deletion callbacks", "[freertos]")
{
TaskHandle_t tasks[portNUM_PROCESSORS];
int tlsps[portNUM_PROCESSORS][NUM_TLSP];
TaskHandle_t tasks[CONFIG_FREERTOS_NUMBER_OF_CORES];
int tlsps[CONFIG_FREERTOS_NUMBER_OF_CORES][NUM_TLSP];
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
TEST_ASSERT_EQUAL(pdPASS, xTaskCreatePinnedToCore(tlsp_task, "tlsp_tsk", configMINIMAL_STACK_SIZE * 2, (void *)&tlsps[i], UNITY_FREERTOS_PRIORITY - 1, &tasks[i], i));
}
// Significant delay to let tasks run and delete themselves
vTaskDelay(pdMS_TO_TICKS(100));
// Check the values of the TLSPs to see if the del cb have ran
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
for (int index = 0; index < NUM_TLSP; index++) {
// Del cb should have set the TLSP to a negative value
TEST_ASSERT_EQUAL(-index, tlsps[i][index]);

View File

@ -1,8 +1,9 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include "sdkconfig.h"
#include <assert.h>
#include <stdint.h>
#include <stddef.h>
@ -179,7 +180,7 @@ TEST_CASE("stdatomic - test_8bit_atomics", "[newlib_stdatomic]")
pthread_t thread1; \
pthread_t thread2; \
esp_pthread_cfg_t cfg = esp_pthread_get_default_config(); \
cfg.pin_to_core = (xPortGetCoreID() + 1) % portNUM_PROCESSORS; \
cfg.pin_to_core = (xPortGetCoreID() + 1) % CONFIG_FREERTOS_NUMBER_OF_CORES; \
esp_pthread_set_cfg(&cfg); \
pthread_create(&thread1, NULL, exclusion_task_ ## n, (void*) 1); \
cfg.pin_to_core = xPortGetCoreID(); \
@ -237,7 +238,7 @@ TEST_CASE("stdatomic - test_" #NAME, "[newlib_stdatomic]")
pthread_t thread_id2; \
var_##NAME = (INIT); \
esp_pthread_cfg_t cfg = esp_pthread_get_default_config(); \
cfg.pin_to_core = (xPortGetCoreID() + 1) % portNUM_PROCESSORS; \
cfg.pin_to_core = (xPortGetCoreID() + 1) % CONFIG_FREERTOS_NUMBER_OF_CORES; \
esp_pthread_set_cfg(&cfg); \
pthread_create (&thread_id1, NULL, test_thread_##NAME, NULL); \
cfg.pin_to_core = xPortGetCoreID(); \
@ -271,7 +272,7 @@ TEST_CASE("stdatomic - test_" #NAME, "[newlib_stdatomic]") \
var_##NAME = (INIT); \
const LHSTYPE EXPECTED = (FINAL); \
esp_pthread_cfg_t cfg = esp_pthread_get_default_config(); \
cfg.pin_to_core = (xPortGetCoreID() + 1) % portNUM_PROCESSORS; \
cfg.pin_to_core = (xPortGetCoreID() + 1) % CONFIG_FREERTOS_NUMBER_OF_CORES; \
esp_pthread_set_cfg(&cfg); \
pthread_create (&thread_id1, NULL, test_thread_##NAME, NULL); \
cfg.pin_to_core = xPortGetCoreID(); \

View File

@ -49,7 +49,7 @@
#include "hal/cache_ll.h"
#endif
#if (portNUM_PROCESSORS == 2) && CONFIG_IDF_TARGET_ARCH_XTENSA
#if (CONFIG_FREERTOS_NUMBER_OF_CORES == 2) && CONFIG_IDF_TARGET_ARCH_XTENSA
// https://github.com/espressif/arduino-esp32/issues/120
/* Test for hardware bug, not needed for newer chips */
@ -92,7 +92,7 @@ TEST_CASE("Reading RTC registers on APP CPU doesn't affect clock", "[newlib]")
TEST_ASSERT_TRUE(xSemaphoreTake(done, 5000 / portTICK_PERIOD_MS));
}
#endif // (portNUM_PROCESSORS == 2) && CONFIG_IDF_TARGET_ARCH_XTENSA
#endif // (CONFIG_FREERTOS_NUMBER_OF_CORES == 2) && CONFIG_IDF_TARGET_ARCH_XTENSA
TEST_CASE("test adjtime function", "[newlib]")
{

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <time.h>
#include <errno.h>
#include <pthread.h>
@ -325,7 +326,7 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
task_name = pthread_cfg->thread_name;
}
if (pthread_cfg->pin_to_core >= 0 && pthread_cfg->pin_to_core < portNUM_PROCESSORS) {
if (pthread_cfg->pin_to_core >= 0 && pthread_cfg->pin_to_core < CONFIG_FREERTOS_NUMBER_OF_CORES) {
core_id = pthread_cfg->pin_to_core;
}

View File

@ -124,7 +124,7 @@ TEST_CASE("flash write and erase work both on PRO CPU and on APP CPU", "[spi_fla
// TODO: This test is disabled on S3 with legacy impl - IDF-3505
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32, ESP32S2, ESP32S3, ESP32C3, ESP32P4)
#if portNUM_PROCESSORS > 1
#if CONFIG_FREERTOS_NUMBER_OF_CORES > 1
TEST_CASE("spi_flash deadlock with high priority busy-waiting task", "[spi_flash][esp_flash]")
{
typedef struct {
@ -180,7 +180,7 @@ TEST_CASE("spi_flash deadlock with high priority busy-waiting task", "[spi_flash
/* Check that current task priority is still correct */
TEST_ASSERT_EQUAL_INT(uxTaskPriorityGet(NULL), UNITY_FREERTOS_PRIORITY);
}
#endif // portNUM_PROCESSORS > 1
#endif // CONFIG_FREERTOS_NUMBER_OF_CORES > 1
#endif // !TEMPORARY_DISABLED_FOR_TARGETS(ESP32, ESP32S2, ESP32S3, ESP32C3)

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -43,7 +44,7 @@ TEST_CASE("spi_flash_cache_enabled() works on both CPUs", "[spi_flash][esp_flash
{
result_queue = xQueueCreate(1, sizeof(bool));
for(int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for(int cpu = 0; cpu < CONFIG_FREERTOS_NUMBER_OF_CORES; cpu++) {
for(int disable = 0; disable <= 1; disable++) {
bool do_disable = disable;
bool result;

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -519,7 +520,7 @@ static void test_spiffs_concurrent(const char* filename_prefix)
printf("writing f1 and f2\n");
const int cpuid_0 = 0;
const int cpuid_1 = portNUM_PROCESSORS - 1;
const int cpuid_1 = CONFIG_FREERTOS_NUMBER_OF_CORES - 1;
xTaskCreatePinnedToCore(&read_write_task, "rw1", stack_size, &args1, 3, NULL, cpuid_0);
xTaskCreatePinnedToCore(&read_write_task, "rw2", stack_size, &args2, 3, NULL, cpuid_1);

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@ -176,7 +177,7 @@ TEST_CASE("VFS can handle concurrent open/close requests", "[vfs]")
TEST_ASSERT_NOT_NULL(param8.done);
const int cpuid0 = 0;
const int cpuid1 = portNUM_PROCESSORS - 1;
const int cpuid1 = CONFIG_FREERTOS_NUMBER_OF_CORES - 1;
srand(time(NULL));

View File

@ -149,7 +149,7 @@ TEST(wear_levelling, multiple_tasks_single_handle)
printf("writing 1 and 2\n");
const int cpuid_0 = 0;
const int cpuid_1 = portNUM_PROCESSORS - 1;
const int cpuid_1 = CONFIG_FREERTOS_NUMBER_OF_CORES - 1;
xTaskCreatePinnedToCore(&read_write_task, "rw1", stack_size, &args1, 3, NULL, cpuid_0);
xTaskCreatePinnedToCore(&read_write_task, "rw2", stack_size, &args2, 3, NULL, cpuid_1);

View File

@ -10,6 +10,7 @@
*
****************************************************************************/
#include "sdkconfig.h"
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
@ -34,7 +35,7 @@
* Thread/Task reference
**********************************************************/
#ifdef CONFIG_BLUEDROID_PINNED_TO_CORE
#define BLUETOOTH_TASK_PINNED_TO_CORE (CONFIG_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#define BLUETOOTH_TASK_PINNED_TO_CORE (CONFIG_BLUEDROID_PINNED_TO_CORE < CONFIG_FREERTOS_NUMBER_OF_CORES ? CONFIG_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define BLUETOOTH_TASK_PINNED_TO_CORE (0)
#endif

View File

@ -37,7 +37,7 @@
* Thread/Task reference
**********************************************************/
#ifdef CONFIG_BLUEDROID_PINNED_TO_CORE
#define BLUETOOTH_TASK_PINNED_TO_CORE (CONFIG_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#define BLUETOOTH_TASK_PINNED_TO_CORE (CONFIG_BLUEDROID_PINNED_TO_CORE < CONFIG_FREERTOS_NUMBER_OF_CORES ? CONFIG_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define BLUETOOTH_TASK_PINNED_TO_CORE (0)
#endif

View File

@ -7,6 +7,7 @@
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
@ -108,7 +109,7 @@ static esp_err_t iperf_start_report(void)
{
int ret;
ret = xTaskCreatePinnedToCore(iperf_report_task, IPERF_REPORT_TASK_NAME, IPERF_REPORT_TASK_STACK, NULL, IPERF_REPORT_TASK_PRIORITY, NULL, portNUM_PROCESSORS - 1);
ret = xTaskCreatePinnedToCore(iperf_report_task, IPERF_REPORT_TASK_NAME, IPERF_REPORT_TASK_STACK, NULL, IPERF_REPORT_TASK_PRIORITY, NULL, CONFIG_FREERTOS_NUMBER_OF_CORES - 1);
if (ret != pdPASS) {
ESP_LOGE(TAG, "create task %s failed", IPERF_REPORT_TASK_NAME);
@ -584,7 +585,7 @@ esp_err_t iperf_start(iperf_cfg_t *cfg)
return ESP_FAIL;
}
memset(s_iperf_ctrl.buffer, 0, s_iperf_ctrl.buffer_len);
ret = xTaskCreatePinnedToCore(iperf_task_traffic, IPERF_TRAFFIC_TASK_NAME, IPERF_TRAFFIC_TASK_STACK, NULL, IPERF_TRAFFIC_TASK_PRIORITY, NULL, portNUM_PROCESSORS - 1);
ret = xTaskCreatePinnedToCore(iperf_task_traffic, IPERF_TRAFFIC_TASK_NAME, IPERF_TRAFFIC_TASK_STACK, NULL, IPERF_TRAFFIC_TASK_PRIORITY, NULL, CONFIG_FREERTOS_NUMBER_OF_CORES - 1);
if (ret != pdPASS) {
ESP_LOGE(TAG, "create task %s failed", IPERF_TRAFFIC_TASK_NAME);
free(s_iperf_ctrl.buffer);

View File

@ -7,6 +7,7 @@
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
@ -109,7 +110,7 @@ static esp_err_t print_real_time_stats(TickType_t xTicksToWait)
//Check if matching task found
if (k >= 0) {
uint32_t task_elapsed_time = end_array[k].ulRunTimeCounter - start_array[i].ulRunTimeCounter;
uint32_t percentage_time = (task_elapsed_time * 100UL) / (total_elapsed_time * portNUM_PROCESSORS);
uint32_t percentage_time = (task_elapsed_time * 100UL) / (total_elapsed_time * CONFIG_FREERTOS_NUMBER_OF_CORES);
printf("| %s | %"PRIu32" | %"PRIu32"%%\n", start_array[i].pcTaskName, task_elapsed_time, percentage_time);
}
}

View File

@ -7,6 +7,7 @@
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -133,7 +134,7 @@ static void example_task(void *p)
void app_main(void)
{
static example_event_data_t event_data[portNUM_PROCESSORS];
static example_event_data_t event_data[CONFIG_FREERTOS_NUMBER_OF_CORES];
#if CONFIG_APPTRACE_SV_ENABLE && CONFIG_USE_CUSTOM_EVENT_ID
// Currently OpenOCD does not support requesting module info from target. So do the following...
@ -146,7 +147,7 @@ void app_main(void)
SEGGER_SYSVIEW_RegisterModule(&s_example_sysview_module);
#endif
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
gptimer_config_t timer_config = {
.clk_src = GPTIMER_CLK_SRC_DEFAULT,
.direction = GPTIMER_COUNT_UP,
@ -156,7 +157,7 @@ void app_main(void)
event_data[i].period = 1000000 * (i + 1);
}
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < CONFIG_FREERTOS_NUMBER_OF_CORES; i++) {
sprintf(event_data->task_name, "svtrace%d", i);
xTaskCreatePinnedToCore(example_task, event_data->task_name, 4096, &event_data[i], 3, &event_data[i].thnd, i);
ESP_LOGI(TAG, "Created task %p", event_data[i].thnd);

View File

@ -7,6 +7,7 @@
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "sdkconfig.h"
#include <inttypes.h>
#include "esp_sysview_trace.h"
#include "esp_heap_trace.h"
@ -50,7 +51,7 @@ static void alloc_task(void *p)
return;
}
snprintf(task_name, sizeof(task_name), "free%d", task_args->idx);
xTaskCreatePinnedToCore(free_task, task_name, 2500, queue, 5, NULL, portNUM_PROCESSORS-1);
xTaskCreatePinnedToCore(free_task, task_name, 2500, queue, 5, NULL, CONFIG_FREERTOS_NUMBER_OF_CORES-1);
// here GDB will stop at brekpoint and execute OpenOCD command to start tracing
for(int i = 1; i < 10; i++) {

View File

@ -75,7 +75,7 @@ void app_main(void)
// If the TWDT was not initialized automatically on startup, manually intialize it now
esp_task_wdt_config_t twdt_config = {
.timeout_ms = TWDT_TIMEOUT_MS,
.idle_core_mask = (1 << portNUM_PROCESSORS) - 1, // Bitmask of all cores
.idle_core_mask = (1 << CONFIG_FREERTOS_NUMBER_OF_CORES) - 1, // Bitmask of all cores
.trigger_panic = false,
};
ESP_ERROR_CHECK(esp_task_wdt_init(&twdt_config));

View File

@ -11,6 +11,7 @@
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "freertos/queue.h"
@ -282,7 +283,7 @@ esp_err_t esp_wifi_set_ant_soft_switch(const wifi_antenna_auto_switch_config_t
/**< Select the optimal antenna*/
antenna_switch_function(config);
ret = xTaskCreatePinnedToCore(antenna_soft_switching_task, SOFT_SWITCHING_NAME, SOFT_SWITCHING_STACK, (void *)config, SOFT_SWITCHING_PRIORITY, &antenna_task_handle, portNUM_PROCESSORS - 1);
ret = xTaskCreatePinnedToCore(antenna_soft_switching_task, SOFT_SWITCHING_NAME, SOFT_SWITCHING_STACK, (void *)config, SOFT_SWITCHING_PRIORITY, &antenna_task_handle, CONFIG_FREERTOS_NUMBER_OF_CORES - 1);
if (ret != pdPASS) {
ESP_LOGE(TAG, "create task %s failed", SOFT_SWITCHING_NAME);
return ESP_FAIL;

View File

@ -45,4 +45,12 @@ menu "FreeRTOS"
bool
default y
config FREERTOS_NUMBER_OF_CORES
# Invisible option to configure the number of cores on which FreeRTOS runs
# Todo: Unhide this option and deprecate CONFIG_FREERTOS_UNICORE (IDF-9156)
int
range 1 2
default 1 if FREERTOS_UNICORE
default 2 if !FREERTOS_UNICORE
endmenu

View File

@ -59,17 +59,17 @@ static void tlsp_task(void *arg)
TEST_CASE("Test TLSP deletion callbacks", "[freertos]")
{
TaskHandle_t tasks[portNUM_PROCESSORS];
int tlsps[portNUM_PROCESSORS][NUM_TLSP];
TaskHandle_t tasks[configNUM_CORES];
int tlsps[configNUM_CORES][NUM_TLSP];
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < configNUM_CORES; i++) {
TEST_ASSERT_EQUAL(pdPASS, xTaskCreatePinnedToCore(tlsp_task, "tlsp_tsk", configMINIMAL_STACK_SIZE * 2, (void *)&tlsps[i], CONFIG_UNITY_FREERTOS_PRIORITY - 1, &tasks[i], i));
}
// Significant delay to let tasks run and delete themselves
vTaskDelay(pdMS_TO_TICKS(100));
// Check the values of the TLSPs to see if the del cb have ran
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < configNUM_CORES; i++) {
for (int index = 0; index < NUM_TLSP; index++) {
// Del cb should have set the TLSP to a negative value
TEST_ASSERT_EQUAL(-index, tlsps[i][index]);

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
@ -138,16 +139,16 @@ static void send_func(void *arg)
TEST_CASE("Test queue sets multi-core", "[freertos]")
{
// Create done semaphore
done_sem = xSemaphoreCreateCounting(portNUM_PROCESSORS - 1, 0);
done_sem = xSemaphoreCreateCounting(configNUM_CORES - 1, 0);
TEST_ASSERT_NOT_EQUAL(NULL, done_sem);
// Create queues and queue set
QueueHandle_t queues[portNUM_PROCESSORS];
QueueHandle_t queues[configNUM_CORES];
QueueSetHandle_t queue_set;
allocate_resources(portNUM_PROCESSORS, QUEUE_LEN, queues, &queue_set);
allocate_resources(configNUM_CORES, QUEUE_LEN, queues, &queue_set);
// Create tasks of the same priority for all cores except for core 0
for (int i = 1; i < portNUM_PROCESSORS; i++) {
for (int i = 1; i < configNUM_CORES; i++) {
TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(send_func, "send", 2048, (void *)queues[i], CONFIG_UNITY_FREERTOS_PRIORITY, NULL, i));
}
@ -155,30 +156,30 @@ TEST_CASE("Test queue sets multi-core", "[freertos]")
send_func((void *)queues[0]);
// Wait for all other cores to be done
for (int i = 1; i < portNUM_PROCESSORS; i++) {
for (int i = 1; i < configNUM_CORES; i++) {
xSemaphoreTake(done_sem, portMAX_DELAY);
}
// Read queues from the queue set, then read an item from the queue
uint32_t queues_check_count[portNUM_PROCESSORS] = {0};
uint32_t queues_check_count[configNUM_CORES] = {0};
QueueSetMemberHandle_t member = xQueueSelectFromSet(queue_set, 0);
while (member != NULL) {
// Read the core ID from the queue, check that core ID is sane
BaseType_t core_id;
TEST_ASSERT_EQUAL(pdTRUE, xQueueReceive(member, &core_id, 0));
TEST_ASSERT_LESS_THAN(portNUM_PROCESSORS, core_id);
TEST_ASSERT_LESS_THAN(configNUM_CORES, core_id);
queues_check_count[core_id]++;
// Get next member
member = xQueueSelectFromSet(queue_set, 0);
}
// Check that all items from all queues have been read
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < configNUM_CORES; i++) {
TEST_ASSERT_EQUAL(QUEUE_LEN, queues_check_count[i]);
}
// Cleanup queues and queue set
free_resources(portNUM_PROCESSORS, queues, queue_set);
free_resources(configNUM_CORES, queues, queue_set);
// Cleanup done sem
vSemaphoreDelete(done_sem);
done_sem = NULL;

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "unity.h"
@ -48,13 +49,13 @@ static void loop_task(void *arg)
TEST_CASE("Test eTaskGetState", "[freertos]")
{
TaskHandle_t blocked_tasks[portNUM_PROCESSORS];
TaskHandle_t suspended_tasks[portNUM_PROCESSORS];
TaskHandle_t ready_tasks[portNUM_PROCESSORS];
TaskHandle_t running_tasks[portNUM_PROCESSORS];
TaskHandle_t blocked_tasks[configNUM_CORES];
TaskHandle_t suspended_tasks[configNUM_CORES];
TaskHandle_t ready_tasks[configNUM_CORES];
TaskHandle_t running_tasks[configNUM_CORES];
// Create tasks of each state on each core
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < configNUM_CORES; i++) {
TEST_ASSERT_EQUAL(pdPASS, xTaskCreatePinnedToCore(blocked_task, "blkd", configMINIMAL_STACK_SIZE * 2, NULL, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &blocked_tasks[i], i));
TEST_ASSERT_EQUAL(pdPASS, xTaskCreatePinnedToCore(suspended_task, "susp", configMINIMAL_STACK_SIZE * 2, NULL, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &suspended_tasks[i], i));
TEST_ASSERT_EQUAL(pdPASS, xTaskCreatePinnedToCore(loop_task, "rdy", configMINIMAL_STACK_SIZE * 2, NULL, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &ready_tasks[i], i));
@ -69,7 +70,7 @@ TEST_CASE("Test eTaskGetState", "[freertos]")
vTaskDelay(10);
// Check the state of the created tasks
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < configNUM_CORES; i++) {
TEST_ASSERT_EQUAL(eBlocked, eTaskGetState(blocked_tasks[i]));
TEST_ASSERT_EQUAL(eSuspended, eTaskGetState(suspended_tasks[i]));
TEST_ASSERT_EQUAL(eReady, eTaskGetState(ready_tasks[i]));
@ -77,7 +78,7 @@ TEST_CASE("Test eTaskGetState", "[freertos]")
}
// Clean up created tasks
for (int i = 0; i < portNUM_PROCESSORS; i++) {
for (int i = 0; i < configNUM_CORES; i++) {
vTaskDelete(blocked_tasks[i]);
vTaskDelete(suspended_tasks[i]);
vTaskDelete(ready_tasks[i]);

View File

@ -17,7 +17,7 @@
* deletion callbacks will still be carried out by the Idle Task.
*/
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -62,8 +62,8 @@ static void tsk_blocks_frequently(void *param)
TEST_CASE("FreeRTOS Delete Blocked Tasks", "[freertos][ignore]") // TODO: esp_rom_delay_us is interrupted by signal
{
TaskHandle_t blocking_tasks[portNUM_PROCESSORS + 1]; // one per CPU, plus one unpinned task
tsk_blocks_param_t params[portNUM_PROCESSORS + 1] = { 0 };
TaskHandle_t blocking_tasks[configNUM_CORES + 1]; // one per CPU, plus one unpinned task
tsk_blocks_param_t params[configNUM_CORES + 1] = { 0 };
esp_rom_delay_us(100);
@ -79,19 +79,19 @@ TEST_CASE("FreeRTOS Delete Blocked Tasks", "[freertos][ignore]") // TODO: esp_ro
for(unsigned iter = 0; iter < 1000; iter++) {
// Create everything
SemaphoreHandle_t sem = xSemaphoreCreateMutex();
for(unsigned i = 0; i < portNUM_PROCESSORS + 1; i++) {
for(unsigned i = 0; i < configNUM_CORES + 1; i++) {
params[i].deleted = false;
params[i].sem = sem;
TEST_ASSERT_EQUAL(pdTRUE,
xTaskCreatePinnedToCore(tsk_blocks_frequently, "tsk_block", 4096, &params[i],
CONFIG_UNITY_FREERTOS_PRIORITY - 1, &blocking_tasks[i],
i < portNUM_PROCESSORS ? i : tskNO_AFFINITY));
i < configNUM_CORES ? i : tskNO_AFFINITY));
}
vTaskDelay(5); // Let the tasks juggle the mutex for a bit
for(unsigned i = 0; i < portNUM_PROCESSORS + 1; i++) {
for(unsigned i = 0; i < configNUM_CORES + 1; i++) {
vTaskDelete(blocking_tasks[i]);
params[i].deleted = true;
}

View File

@ -11,7 +11,7 @@
#include <esp_types.h>
#include <stdio.h>
#include <strings.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "unity.h"
@ -29,20 +29,20 @@ static void counter_task(void *param)
TEST_CASE("Get/Set Priorities", "[freertos]")
{
/* Two tasks per processor */
TaskHandle_t tasks[portNUM_PROCESSORS][2] = { 0 };
unsigned volatile counters[portNUM_PROCESSORS][2] = { 0 };
TaskHandle_t tasks[configNUM_CORES][2] = { 0 };
unsigned volatile counters[configNUM_CORES][2] = { 0 };
TEST_ASSERT_EQUAL(CONFIG_UNITY_FREERTOS_PRIORITY, uxTaskPriorityGet(NULL));
/* create a matrix of counter tasks on each core */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < configNUM_CORES; cpu++) {
for (int task = 0; task < 2; task++) {
xTaskCreatePinnedToCore(counter_task, "count", 2048, (void *)&(counters[cpu][task]), CONFIG_UNITY_FREERTOS_PRIORITY - task, &(tasks[cpu][task]), cpu);
}
}
/* check they were created with the expected priorities */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < configNUM_CORES; cpu++) {
for (int task = 0; task < 2; task++) {
TEST_ASSERT_EQUAL(CONFIG_UNITY_FREERTOS_PRIORITY - task, uxTaskPriorityGet(tasks[cpu][task]));
}
@ -51,25 +51,25 @@ TEST_CASE("Get/Set Priorities", "[freertos]")
vTaskDelay(10);
/* at this point, only the higher priority tasks (first index) should be counting */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < configNUM_CORES; cpu++) {
TEST_ASSERT_NOT_EQUAL(0, counters[cpu][0]);
TEST_ASSERT_EQUAL(0, counters[cpu][1]);
}
/* swap priorities! */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < configNUM_CORES; cpu++) {
vTaskPrioritySet(tasks[cpu][0], CONFIG_UNITY_FREERTOS_PRIORITY - 1);
vTaskPrioritySet(tasks[cpu][1], CONFIG_UNITY_FREERTOS_PRIORITY);
}
/* check priorities have swapped... */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < configNUM_CORES; cpu++) {
TEST_ASSERT_EQUAL(CONFIG_UNITY_FREERTOS_PRIORITY -1, uxTaskPriorityGet(tasks[cpu][0]));
TEST_ASSERT_EQUAL(CONFIG_UNITY_FREERTOS_PRIORITY, uxTaskPriorityGet(tasks[cpu][1]));
}
/* check the tasks which are counting have also swapped now... */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < configNUM_CORES; cpu++) {
unsigned old_counters[2];
old_counters[0] = counters[cpu][0];
old_counters[1] = counters[cpu][1];
@ -79,7 +79,7 @@ TEST_CASE("Get/Set Priorities", "[freertos]")
}
/* clean up */
for (int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) {
for (int cpu = 0; cpu < configNUM_CORES; cpu++) {
for (int task = 0; task < 2; task++) {
vTaskDelete(tasks[cpu][task]);
}

View File

@ -8,6 +8,7 @@
* Unit tests for FreeRTOS task yielding
*/
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@ -444,7 +445,7 @@ TEST_CASE("Task yield must happed when a task raises the priority of another pri
TEST_ASSERT_EQUAL(2, task_yield_sequence[idx++]);
}
#if (portNUM_PROCESSORS > 1) && !(CONFIG_FREERTOS_UNICORE)
#if (configNUM_CORES > 1) && !(CONFIG_FREERTOS_UNICORE)
/*
* Test yielding behavior when a task on one core forces an yield on the other core
*
@ -654,4 +655,4 @@ TEST_CASE("Task yield on other core must not happen when scheduler is suspended"
TEST_ASSERT_EQUAL(2, task_yield_sequence[idx1++]);
}
#endif // !CONFIG_FREERTOS_SMP
#endif // (portNUM_PROCESSORS > 1) && !(CONFIG_FREERTOS_UNICORE)
#endif // (configNUM_CORES > 1) && !(CONFIG_FREERTOS_UNICORE)

View File

@ -626,7 +626,7 @@ esp_memp_config_t memp_cfg = {
.lock_feature = false,
.split_addr = NULL,
.mem_type_mask = MEMPROT_TYPE_ALL,
#if portNUM_PROCESSORS > 1
#if configNUM_CORES > 1
.target_cpu_count = 2,
.target_cpu = {PRO_CPU_NUM, APP_CPU_NUM}
#else
@ -689,7 +689,7 @@ void app_main(void)
xSemaphoreTake(ctx.sem, portMAX_DELAY);
//multicore setup
if (portNUM_PROCESSORS > 1) {
if (configNUM_CORES > 1) {
ctx.core = APP_CPU_NUM;
xTaskCreatePinnedToCore(task_on_CPU, "task_APP_CPU", 4096, &ctx, 3, NULL, APP_CPU_NUM);
xSemaphoreTake(ctx.sem, portMAX_DELAY);