Skip to content

Commit

Permalink
change(docs): Update multicore tags to SOC_HP_CPU_HAS_MULTIPLE_CORES
Browse files Browse the repository at this point in the history
Previously, documentation sections that were only meant for multicore ESP
targets would use tags that depend on CONFIG_FREERTOS_UNICORE. This is not
ideal as project configuration can be changed by the user.

This commit updates those tags to use SOC_HP_CPU_HAS_MULTIPLE_CORES which is
always defined in multicore targets regardless of project configuration.
  • Loading branch information
Dazza0 committed Dec 7, 2023
1 parent a7e2ea7 commit 3c8cccc
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions docs/en/api-guides/app_trace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ Data Visualization

After trace data are collected, users can use a special tool to visualize the results and inspect behavior of the program.

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

Unfortunately, SystemView does not support tracing from multiple cores. So when tracing from {IDF_TARGET_NAME} with JTAG interfaces in the dual-core mode, two files are generated: one for PRO CPU and another for APP CPU. Users can load each file into separate instances of the tool. For tracing over UART, users can select ``Component config`` > ``Application Level Tracing`` > ``FreeRTOS SystemView Tracing`` in menuconfig Pro or App to choose which CPU has to be traced.

Expand All @@ -432,7 +432,7 @@ Good instructions on how to install, configure, and visualize data in Impulse fr

ESP-IDF uses its own mapping for SystemView FreeRTOS events IDs, so users need to replace the original file mapping ``$SYSVIEW_INSTALL_DIR/Description/SYSVIEW_FreeRTOS.txt`` with ``$IDF_PATH/tools/esp_app_trace/SYSVIEW_FreeRTOS.txt``. Also, contents of that ESP-IDF-specific file should be used when configuring SystemView serializer using the above link.

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

Configure Impulse for Dual Core Traces
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
12 changes: 6 additions & 6 deletions docs/en/api-guides/performance/speed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Executing the target multiple times can help average out factors, e.g., RTOS con
- It is also possible to use the standard Unix ``gettimeofday()`` and ``utime()`` functions, although the overhead is slightly higher.
- Otherwise, including ``hal/cpu_hal.h`` and calling the HAL function ``cpu_hal_get_cycle_count()`` returns the number of CPU cycles executed. This function has lower overhead than the others, which is good for measuring very short execution times with high precision.

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

The CPU cycles are counted per-core, so only use this method from an interrupt handler, or a task that is pinned to a single core.

Expand Down Expand Up @@ -159,7 +159,7 @@ Common priorities are:

.. Note: the following two lists should be kept the same, but the second list also shows CPU affinities
.. only:: CONFIG_FREERTOS_UNICORE
.. only:: not SOC_HP_CPU_HAS_MULTIPLE_CORES

.. list::

Expand All @@ -176,7 +176,7 @@ Common priorities are:
- If using the :doc:`/api-reference/protocols/mqtt` component, it creates a task with default priority 5 (:ref:`configurable<CONFIG_MQTT_TASK_PRIORITY>`), depending on :ref:`CONFIG_MQTT_USE_CUSTOM_CONFIG`, and also configurable at runtime by ``task_prio`` field in the :cpp:class:`esp_mqtt_client_config_t`)
- To see what is the task priority for ``mDNS`` service, please check `Performance Optimization <https://docs.espressif.com/projects/esp-protocols/mdns/docs/latest/en/index.html#performance-optimization>`__.

.. only :: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

.. list::

Expand Down Expand Up @@ -204,11 +204,11 @@ Common priorities are:
Choosing Task Priorities of the Application
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. only:: CONFIG_FREERTOS_UNICORE
.. only:: not SOC_HP_CPU_HAS_MULTIPLE_CORES

In general, it is not recommended to set task priorities higher than the built-in {IDF_TARGET_RF_TYPE} operations as starving them of CPU may make the system unstable. For very short timing-critical operations that do not use the network, use an ISR or a very restricted task (with very short bursts of runtime only) at the highest priority (24). Choosing priority 19 allows lower-layer {IDF_TARGET_RF_TYPE} functionality to run without delays, but still preempts the lwIP TCP/IP stack and other less time-critical internal functionality - this is the best option for time-critical tasks that do not perform network operations. Any task that does TCP/IP network operations should run at a lower priority than the lwIP TCP/IP task (18) to avoid priority-inversion issues.

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

With a few exceptions, most importantly the lwIP TCP/IP task, in the default configuration most built-in tasks are pinned to Core 0. This makes it quite easy for the application to place high priority tasks on Core 1. Using priority 19 or higher guarantees that an application task can run on Core 1 without being preempted by any built-in task. To further isolate the tasks running on each CPU, configure the :ref:`lwIP task <CONFIG_LWIP_TCPIP_TASK_AFFINITY>` to only run on Core 0 instead of either core, which may reduce total TCP/IP throughput depending on what other tasks are running.

Expand All @@ -234,7 +234,7 @@ To obtain the best performance for a particular interrupt handler:
.. list::

- Assign more important interrupts a higher priority using a flag such as ``ESP_INTR_FLAG_LEVEL2`` or ``ESP_INTR_FLAG_LEVEL3`` when calling :cpp:func:`esp_intr_alloc`.
:not CONFIG_FREERTOS_UNICORE: - Assign the interrupt on a CPU where built-in {IDF_TARGET_RF_TYPE} tasks are not configured to run, which means assigning the interrupt on Core 1 by default, see :ref:`built-in-task-priorities`. Interrupts are assigned on the same CPU where the :cpp:func:`esp_intr_alloc` function call is made.
:SOC_HP_CPU_HAS_MULTIPLE_CORES: - Assign the interrupt on a CPU where built-in {IDF_TARGET_RF_TYPE} tasks are not configured to run, which means assigning the interrupt on Core 1 by default, see :ref:`built-in-task-priorities`. Interrupts are assigned on the same CPU where the :cpp:func:`esp_intr_alloc` function call is made.
- If you are sure the entire interrupt handler can run from IRAM (see :ref:`iram-safe-interrupt-handlers`) then set the ``ESP_INTR_FLAG_IRAM`` flag when calling :cpp:func:`esp_intr_alloc` to assign the interrupt. This prevents it being temporarily disabled if the application firmware writes to the internal SPI flash.
- Even if the interrupt handler is not IRAM-safe, if it is going to be executed frequently then consider moving the handler function to IRAM anyhow. This minimizes the chance of a flash cache miss when the interrupt code is executed (see :ref:`speed-targeted-optimizations`). It is possible to do this without adding the ``ESP_INTR_FLAG_IRAM`` flag to mark the interrupt as IRAM-safe, if only part of the handler is guaranteed to be in IRAM.

Expand Down
16 changes: 8 additions & 8 deletions docs/en/api-guides/startup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ This process is explained in detail in the following sections.
First Stage Bootloader
^^^^^^^^^^^^^^^^^^^^^^

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

After SoC reset, PRO CPU will start running immediately, executing reset vector code, while APP CPU will be held in reset. During startup process, PRO CPU does all the initialization. APP CPU reset is de-asserted in the ``call_start_cpu0`` function of application startup code. Reset vector code is located in the mask ROM of the {IDF_TARGET_NAME} chip and cannot be modified.

.. only:: CONFIG_FREERTOS_UNICORE
.. only:: not SOC_HP_CPU_HAS_MULTIPLE_CORES

After SoC reset, the CPU will start running immediately to perform initialization. The reset vector code is located in the mask ROM of the {IDF_TARGET_NAME} chip and cannot be modified.

Expand Down Expand Up @@ -76,7 +76,7 @@ For the selected partition, second stage bootloader reads the binary image from
- For segments with load addresses in internal :ref:`iram` or :ref:`dram`, the contents are copied from flash to the load address.
- For segments which have load addresses in :ref:`drom` or :ref:`irom` regions, the flash MMU is configured to provide the correct mapping from the flash to the load address.

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

Note that the second stage bootloader configures flash MMU for both PRO and APP CPUs, but it only enables flash MMU for PRO CPU. Reason for this is that second stage bootloader code is loaded into the memory region used by APP CPU cache. The duty of enabling cache for APP CPU is passed on to the application.

Expand Down Expand Up @@ -114,13 +114,13 @@ This port-layer initialization function initializes the basic C Runtime Environm
- Set the CPU clocks to the frequencies configured for the project.
:CONFIG_ESP_SYSTEM_MEMPROT_FEATURE: - Initialize memory protection if configured.
:esp32: - Reconfigure the main SPI flash based on the app header settings (necessary for compatibility with bootloader versions before ESP-IDF V4.0, see :ref:`bootloader-compatibility`).
:not CONFIG_FREERTOS_UNICORE: - If the app is configured to run on multiple cores, start the other core and wait for it to initialize as well (inside the similar "port layer" initialization function ``call_start_cpu1``).
:SOC_HP_CPU_HAS_MULTIPLE_CORES: - If the app is configured to run on multiple cores, start the other core and wait for it to initialize as well (inside the similar "port layer" initialization function ``call_start_cpu1``).

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

Once ``call_start_cpu0`` completes running, it calls the "system layer" initialization function ``start_cpu0`` found in :idf_file:`components/esp_system/startup.c`. Other cores will also complete port-layer initialization and call ``start_other_cores`` found in the same file.

.. only:: CONFIG_FREERTOS_UNICORE
.. only:: not SOC_HP_CPU_HAS_MULTIPLE_CORES

Once ``call_start_cpu0`` completes running, it calls the "system layer" initialization function ``start_cpu0`` found in :idf_file:`components/esp_system/startup.c`.

Expand Down Expand Up @@ -156,13 +156,13 @@ After doing some more initialization tasks (that require the scheduler to have s

The main task that runs ``app_main`` has a fixed RTOS priority (one higher than the minimum) and a :ref:`configurable stack size <CONFIG_ESP_MAIN_TASK_STACK_SIZE>`.

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

The main task core affinity is also configurable: :ref:`CONFIG_ESP_MAIN_TASK_AFFINITY`.

Unlike normal FreeRTOS tasks (or embedded C ``main`` functions), the ``app_main`` task is allowed to return. If this happens, The task is cleaned up and the system will continue running with other RTOS tasks scheduled normally. Therefore, it is possible to implement ``app_main`` as either a function that creates other application tasks and then returns, or as a main application task itself.

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

Second Core Startup
-------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ Under this condition, all CPUs should always execute code and access data from i

When :ref:`CONFIG_SPIRAM_FETCH_INSTRUCTIONS` and :ref:`CONFIG_SPIRAM_RODATA` are both enabled, these APIs will not disable the caches.

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

The way that these APIs disable the caches suspends all the other tasks. Besides, all non-IRAM-safe interrupts will be disabled. The other core will be polling in a busy loop. These will be restored until the Flash operation completes.

.. only:: CONFIG_FREERTOS_UNICORE
.. only:: not SOC_HP_CPU_HAS_MULTIPLE_CORES

The way that these APIs disable the caches also disables non-IRAM-safe interrupts. These will be restored until the Flash operation completes.

Expand Down
2 changes: 1 addition & 1 deletion docs/en/api-reference/system/freertos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ For the full list of user configurable kernel options, see :doc:`/api-reference/

- :ref:`CONFIG_FREERTOS_UNICORE` runs FreeRTOS only on CPU0. Note that this is **not equivalent to running Vanilla FreeRTOS**. Furthermore, this option may affect behavior of components other than :component:`freertos`. For more details regarding the effects of running FreeRTOS on a single core, refer to :ref:`freertos-smp-single-core` (if using ESP-IDF FreeRTOS) or the official Amazon SMP FreeRTOS documentation. Alternatively, users can also search for occurrences of ``CONFIG_FREERTOS_UNICORE`` in the ESP-IDF components.

.. only:: CONFIG_FREERTOS_UNICORE
.. only:: not SOC_HP_CPU_HAS_MULTIPLE_CORES

.. note::
As {IDF_TARGET_NAME} is a single core SoC, the :ref:`CONFIG_FREERTOS_UNICORE` configuration is always set.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/api-reference/system/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ System API
heap_debug
esp_timer
internal-unstable
:not CONFIG_FREERTOS_UNICORE: ipc
:SOC_HP_CPU_HAS_MULTIPLE_CORES: ipc
intr_alloc
log
misc_system_api
Expand Down
2 changes: 1 addition & 1 deletion docs/en/api-reference/system/intr_alloc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ If you have confirmed that the application is indeed running out of interrupts,

.. list::

:not CONFIG_FREERTOS_UNICORE: - On multi-core SoCs, try initializing some of the peripheral drivers from a task pinned to the second core. Interrupts are typically allocated on the same core where the peripheral driver initialization function runs. Therefore by running the initialization function on the second core, more interrupt inputs can be used.
:SOC_HP_CPU_HAS_MULTIPLE_CORES: - On multi-core SoCs, try initializing some of the peripheral drivers from a task pinned to the second core. Interrupts are typically allocated on the same core where the peripheral driver initialization function runs. Therefore by running the initialization function on the second core, more interrupt inputs can be used.
- Determine the interrupts which can tolerate higher latency, and allocate them using ``ESP_INTR_FLAG_SHARED`` flag (optionally ORed with ``ESP_INTR_FLAG_LOWMED``). Using this flag for two or more peripherals will let them use a single interrupt input, and therefore save interrupt inputs for other peripherals. See :ref:`intr-alloc-shared-interrupts` above.
:not SOC_CPU_HAS_FLEXIBLE_INTC: - Some peripheral driver may default to allocating interrupts with ``ESP_INTR_FLAG_LEVEL1`` flag, so priority 2 and 3 interrupts do not get used by default. If :cpp:func:`esp_intr_dump` shows that some priority 2 or 3 interrupts are available, try changing the interrupt allocation flags when initializing the driver to ``ESP_INTR_FLAG_LEVEL2`` or ``ESP_INTR_FLAG_LEVEL3``.
- Check if some of the peripheral drivers do not need to be used all the time, and initialize or deinitialize them on demand. This can reduce the number of simultaneously allocated interrupts.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/api-reference/system/pthread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ The API :cpp:func:`esp_pthread_set_cfg` defined in the ``esp_pthreads.h`` header
.. list::
- Default stack size of new threads, if not specified when calling ``pthread_create()`` (overrides :ref:`CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT`).
- RTOS priority of new threads (overrides :ref:`CONFIG_PTHREAD_TASK_PRIO_DEFAULT`).
:not CONFIG_FREERTOS_UNICORE: - Core affinity / core pinning of new threads (overrides :ref:`CONFIG_PTHREAD_TASK_CORE_DEFAULT`).
:SOC_HP_CPU_HAS_MULTIPLE_CORES: - Core affinity / core pinning of new threads (overrides :ref:`CONFIG_PTHREAD_TASK_CORE_DEFAULT`).
- FreeRTOS task name for new threads (overrides :ref:`CONFIG_PTHREAD_TASK_NAME_DEFAULT`)

This configuration is scoped to the calling thread (or FreeRTOS task), meaning that :cpp:func:`esp_pthread_set_cfg` can be called independently in different threads or tasks. If the ``inherit_cfg`` flag is set in the current configuration then any new thread created will inherit the creator's configuration (if that thread calls ``pthread_create()`` recursively), otherwise the new thread will have the default configuration.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/api-reference/system/wdts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ The following config options control TWDT configuration. They are all enabled by
- :ref:`CONFIG_ESP_TASK_WDT_EN` - enables TWDT feature. If this option is disabled, TWDT cannot be used, even if initialized at runtime.
- :ref:`CONFIG_ESP_TASK_WDT_INIT` - the TWDT is initialized automatically during startup. If this option is disabled, it is still possible to initialize the Task WDT at runtime by calling :cpp:func:`esp_task_wdt_init`.
- :ref:`CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0` - {IDF_TARGET_IDLE_TASK} is subscribed to the TWDT during startup. If this option is disabled, it is still possible to subscribe the idle task by calling :cpp:func:`esp_task_wdt_init` again.
:not CONFIG_FREERTOS_UNICORE: - :ref:`CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1` - CPU1 Idle task is subscribed to the TWDT during startup.
:SOC_HP_CPU_HAS_MULTIPLE_CORES: - :ref:`CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1` - CPU1 Idle task is subscribed to the TWDT during startup.


.. note::
Expand Down
4 changes: 2 additions & 2 deletions docs/zh_CN/api-guides/app_trace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ Start 子命令语法:

收集到跟踪数据后,用户可以使用特殊的工具对结果进行可视化并分析程序行为。

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

遗憾的是,SystemView 不支持从多个核心进行跟踪。所以当使用 JTAG 追踪双核模式下的 {IDF_TARGET_NAME} 时会生成两个文件:一个用于 PRO CPU,另一个用于 APP CPU。用户可以将每个文件加载到工具中单独分析。使用 UART 进行追踪时,用户可以在 menuconfig Pro 或 App 中点击 ``Component config`` > ``Application Level Tracing`` > ``FreeRTOS SystemView Tracing`` 并选择要追踪的 CPU。

Expand All @@ -432,7 +432,7 @@ Start 子命令语法:

ESP-IDF 使用自己的 SystemView FreeRTOS 事件 ID 映射,因此用户需要将 ``$SYSVIEW_INSTALL_DIR/Description/SYSVIEW_FreeRTOS.txt`` 替换成 ``$IDF_PATH/tools/esp_app_trace/SYSVIEW_FreeRTOS.txt``。在使用上述链接配置 SystemView 序列化程序时,也应该使用该特定文件的内容。

.. only:: not CONFIG_FREERTOS_UNICORE
.. only:: SOC_HP_CPU_HAS_MULTIPLE_CORES

配置 Impulse 实现双核跟踪
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Loading

0 comments on commit 3c8cccc

Please sign in to comment.