freertos_additions.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. FreeRTOS Additions
  2. ==================
  3. Overview
  4. --------
  5. ESP-IDF FreeRTOS is based on the Xtensa port of FreeRTOS v10.2.0 with significant modifications
  6. for SMP compatibility (see :doc:`ESP-IDF FreeRTOS SMP Changes<../../api-guides/freertos-smp>`).
  7. However various features specific to ESP-IDF FreeRTOS have been added. The features are as follows:
  8. :ref:`ring-buffers`: Ring buffers were added to provide a form of buffer that could accept
  9. entries of arbitrary lengths.
  10. :ref:`hooks`: ESP-IDF FreeRTOS hooks provides support for registering extra Idle and
  11. Tick hooks at run time. Moreover, the hooks can be asymmetric amongst both CPUs.
  12. :ref:`component-specific-properties`: Currently added only one component specific property `ORIG_INCLUDE_PATH`.
  13. .. _ring-buffers:
  14. Ring Buffers
  15. ------------
  16. The ESP-IDF FreeRTOS ring buffer is a strictly FIFO buffer that supports arbitrarily sized items.
  17. Ring buffers are a more memory efficient alternative to FreeRTOS queues in situations where the
  18. size of items is variable. The capacity of a ring buffer is not measured by the number of items
  19. it can store, but rather by the amount of memory used for storing items. The ring buffer provides API
  20. to send an item, or to allocate space for an item in the ring buffer to be filled manually by the user.
  21. For efficiency reasons,
  22. **items are always retrieved from the ring buffer by reference**. As a result, all retrieved
  23. items *must also be returned* to the ring buffer by using :cpp:func:`vRingbufferReturnItem` or :cpp:func:`vRingbufferReturnItemFromISR`, in order for them to be removed from the ring buffer completely.
  24. The ring buffers are split into the three following types:
  25. **No-Split** buffers will guarantee that an item is stored in contiguous memory and will not
  26. attempt to split an item under any circumstances. Use no-split buffers when items must occupy
  27. contiguous memory. *Only this buffer type allows you getting the data item address and writting
  28. to the item by yourself.*
  29. **Allow-Split** buffers will allow an item to be split when wrapping around if doing so will allow
  30. the item to be stored. Allow-split buffers are more memory efficient than no-split buffers but
  31. can return an item in two parts when retrieving.
  32. **Byte buffers** do not store data as separate items. All data is stored as a sequence of bytes,
  33. and any number of bytes and be sent or retrieved each time. Use byte buffers when separate items
  34. do not need to be maintained (e.g. a byte stream).
  35. .. note::
  36. No-split/allow-split buffers will always store items at 32-bit aligned addresses. Therefore when
  37. retrieving an item, the item pointer is guaranteed to be 32-bit aligned. This is useful
  38. especially when you need to send some data to the DMA.
  39. .. note::
  40. Each item stored in no-split/allow-split buffers will **require an additional 8 bytes for a header**.
  41. Item sizes will also be rounded up to a 32-bit aligned size (multiple of 4 bytes), however the true
  42. item size is recorded within the header. The sizes of no-split/allow-split buffers will also
  43. be rounded up when created.
  44. Usage
  45. ^^^^^
  46. The following example demonstrates the usage of :cpp:func:`xRingbufferCreate`
  47. and :cpp:func:`xRingbufferSend` to create a ring buffer then send an item to it.
  48. .. code-block:: c
  49. #include "freertos/ringbuf.h"
  50. static char tx_item[] = "test_item";
  51. ...
  52. //Create ring buffer
  53. RingbufHandle_t buf_handle;
  54. buf_handle = xRingbufferCreate(1028, RINGBUF_TYPE_NOSPLIT);
  55. if (buf_handle == NULL) {
  56. printf("Failed to create ring buffer\n");
  57. }
  58. //Send an item
  59. UBaseType_t res = xRingbufferSend(buf_handle, tx_item, sizeof(tx_item), pdMS_TO_TICKS(1000));
  60. if (res != pdTRUE) {
  61. printf("Failed to send item\n");
  62. }
  63. The following example demonstrates the usage of :cpp:func:`xRingbufferSendAcquire` and
  64. :cpp:func:`xRingbufferSendComplete` instead of :cpp:func:`xRingbufferSend` to apply for the
  65. memory on the ring buffer (of type `RINGBUF_TYPE_NOSPLIT`) and then send an item to it. This way
  66. adds one more step, but allows getting the address of the memory to write to, and writing to the
  67. memory yourself.
  68. .. code-block:: c
  69. #include "freertos/ringbuf.h"
  70. #include "soc/lldesc.h"
  71. typedef struct {
  72. lldesc_t dma_desc;
  73. uint8_t buf[1];
  74. } dma_item_t;
  75. #define DMA_ITEM_SIZE(N) (sizeof(lldesc_t)+(((N)+3)&(~3)))
  76. ...
  77. //Retrieve space for DMA descriptor and corresponding data buffer
  78. //This has to be done with SendAcquire, or the address may be different when copy
  79. dma_item_t item;
  80. UBaseType_t res = xRingbufferSendAcquire(buf_handle,
  81. &item, DMA_ITEM_SIZE(buffer_size), pdMS_TO_TICKS(1000));
  82. if (res != pdTRUE) {
  83. printf("Failed to acquire memory for item\n");
  84. }
  85. item->dma_desc = (lldesc_t) {
  86. .size = buffer_size,
  87. .length = buffer_size,
  88. .eof = 0,
  89. .owner = 1,
  90. .buf = &item->buf,
  91. };
  92. //Actually send to the ring buffer for consumer to use
  93. res = xRingbufferSendComplete(buf_handle, &item);
  94. if (res != pdTRUE) {
  95. printf("Failed to send item\n");
  96. }
  97. The following example demonstrates retrieving and returning an item from a **no-split ring buffer**
  98. using :cpp:func:`xRingbufferReceive` and :cpp:func:`vRingbufferReturnItem`
  99. .. code-block:: c
  100. ...
  101. //Receive an item from no-split ring buffer
  102. size_t item_size;
  103. char *item = (char *)xRingbufferReceive(buf_handle, &item_size, pdMS_TO_TICKS(1000));
  104. //Check received item
  105. if (item != NULL) {
  106. //Print item
  107. for (int i = 0; i < item_size; i++) {
  108. printf("%c", item[i]);
  109. }
  110. printf("\n");
  111. //Return Item
  112. vRingbufferReturnItem(buf_handle, (void *)item);
  113. } else {
  114. //Failed to receive item
  115. printf("Failed to receive item\n");
  116. }
  117. The following example demonstrates retrieving and returning an item from an **allow-split ring buffer**
  118. using :cpp:func:`xRingbufferReceiveSplit` and :cpp:func:`vRingbufferReturnItem`
  119. .. code-block:: c
  120. ...
  121. //Receive an item from allow-split ring buffer
  122. size_t item_size1, item_size2;
  123. char *item1, *item2;
  124. BaseType_t ret = xRingbufferReceiveSplit(buf_handle, (void **)&item1, (void **)&item2, &item_size1, &item_size2, pdMS_TO_TICKS(1000));
  125. //Check received item
  126. if (ret == pdTRUE && item1 != NULL) {
  127. for (int i = 0; i < item_size1; i++) {
  128. printf("%c", item1[i]);
  129. }
  130. vRingbufferReturnItem(buf_handle, (void *)item1);
  131. //Check if item was split
  132. if (item2 != NULL) {
  133. for (int i = 0; i < item_size2; i++) {
  134. printf("%c", item2[i]);
  135. }
  136. vRingbufferReturnItem(buf_handle, (void *)item2);
  137. }
  138. printf("\n");
  139. } else {
  140. //Failed to receive item
  141. printf("Failed to receive item\n");
  142. }
  143. The following example demonstrates retrieving and returning an item from a **byte buffer**
  144. using :cpp:func:`xRingbufferReceiveUpTo` and :cpp:func:`vRingbufferReturnItem`
  145. .. code-block:: c
  146. ...
  147. //Receive data from byte buffer
  148. size_t item_size;
  149. char *item = (char *)xRingbufferReceiveUpTo(buf_handle, &item_size, pdMS_TO_TICKS(1000), sizeof(tx_item));
  150. //Check received data
  151. if (item != NULL) {
  152. //Print item
  153. for (int i = 0; i < item_size; i++) {
  154. printf("%c", item[i]);
  155. }
  156. printf("\n");
  157. //Return Item
  158. vRingbufferReturnItem(buf_handle, (void *)item);
  159. } else {
  160. //Failed to receive item
  161. printf("Failed to receive item\n");
  162. }
  163. For ISR safe versions of the functions used above, call :cpp:func:`xRingbufferSendFromISR`, :cpp:func:`xRingbufferReceiveFromISR`,
  164. :cpp:func:`xRingbufferReceiveSplitFromISR`, :cpp:func:`xRingbufferReceiveUpToFromISR`, and :cpp:func:`vRingbufferReturnItemFromISR`
  165. .. note::
  166. Two calls to RingbufferReceive[UpTo][FromISR]() are required if the bytes wraps around the end of the ring buffer.
  167. Sending to Ring Buffer
  168. ^^^^^^^^^^^^^^^^^^^^^^
  169. The following diagrams illustrate the differences between no-split/allow-split buffers
  170. and byte buffers with regards to sending items/data. The diagrams assume that three
  171. items of sizes **18, 3, and 27 bytes** are sent respectively to a **buffer of 128 bytes**.
  172. .. packetdiag:: ../../../_static/diagrams/ring-buffer/ring_buffer_send_non_byte_buf.diag
  173. :caption: Sending items to no-split/allow-split ring buffers
  174. :align: center
  175. For no-split/allow-split buffers, a header of 8 bytes precedes every data item. Furthermore, the space
  176. occupied by each item is **rounded up to the nearest 32-bit aligned size** in order to maintain overall
  177. 32-bit alignment. However the true size of the item is recorded inside the header which will be
  178. returned when the item is retrieved.
  179. Referring to the diagram above, the 18, 3, and 27 byte items are **rounded up to 20, 4, and 28 bytes**
  180. respectively. An 8 byte header is then added in front of each item.
  181. .. packetdiag:: ../../../_static/diagrams/ring-buffer/ring_buffer_send_byte_buf.diag
  182. :caption: Sending items to byte buffers
  183. :align: center
  184. Byte buffers treat data as a sequence of bytes and does not incur any overhead
  185. (no headers). As a result, all data sent to a byte buffer is merged into a single item.
  186. Referring to the diagram above, the 18, 3, and 27 byte items are sequentially written to the
  187. byte buffer and **merged into a single item of 48 bytes**.
  188. Using SendAcquire and SendComplete
  189. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  190. Items in no-split buffers are acquired (by SendAcquire) in strict FIFO order and must be sent to
  191. the buffer by SendComplete for the data to be accessible by the consumer. Multiple items can be
  192. sent or acquired without calling SendComplete, and the items do not necessarily need to be
  193. completed in the order they were acquired. However the receiving of data items must occur in FIFO
  194. order, therefore not calling SendComplete the earliest acquired item will prevent the subsequent
  195. items from being received.
  196. The following diagrams illustrate what will happen when SendAcquire/SendComplete don't happen in
  197. the same order. At the beginning, there is already an data item of 16 bytes sent to the ring
  198. buffer. Then SendAcquire is called to acquire space of 20, 8, 24 bytes on the ring buffer.
  199. .. packetdiag:: ../../../_static/diagrams/ring-buffer/ring_buffer_send_acquire_complete.diag
  200. :caption: SendAcquire/SendComplete items in no-split ring buffers
  201. :align: center
  202. After that, we fill (use) the buffers, and send them to the ring buffer by SendComplete in the
  203. order of 8, 24, 20. When 8 bytes and 24 bytes data are sent, the consumer still can only get the
  204. 16 bytes data item. Due to the usage if 20 bytes item is not complete, it's not available, nor
  205. the following data items.
  206. When the 20 bytes item is finally completed, all the 3 data items can be received now, in the
  207. order of 20, 8, 24 bytes, right after the 16 bytes item existing in the buffer at the beginning.
  208. Allow-split/byte buffers do not allow using SendAcquire/SendComplete since acquired buffers are
  209. required to be complete (not wrapped).
  210. Wrap around
  211. ^^^^^^^^^^^
  212. The following diagrams illustrate the differences between no-split, allow-split, and byte
  213. buffers when a sent item requires a wrap around. The diagrams assumes a buffer of **128 bytes**
  214. with **56 bytes of free space that wraps around** and a sent item of **28 bytes**.
  215. .. packetdiag:: ../../../_static/diagrams/ring-buffer/ring_buffer_wrap_no_split.diag
  216. :caption: Wrap around in no-split buffers
  217. :align: center
  218. No-split buffers will **only store an item in continuous free space and will not split
  219. an item under any circumstances**. When the free space at the tail of the buffer is insufficient
  220. to completely store the item and its header, the free space at the tail will be **marked as dummy data**.
  221. The buffer will then wrap around and store the item in the free space at the head of the buffer.
  222. Referring to the diagram above, the 16 bytes of free space at the tail of the buffer is
  223. insufficient to store the 28 byte item. Therefore the 16 bytes is marked as dummy data and
  224. the item is written to the free space at the head of the buffer instead.
  225. .. packetdiag:: ../../../_static/diagrams/ring-buffer/ring_buffer_wrap_allow_split.diag
  226. :caption: Wrap around in allow-split buffers
  227. :align: center
  228. Allow-split buffers will attempt to **split the item into two parts** when the free space at the tail
  229. of the buffer is insufficient to store the item data and its header. Both parts of the
  230. split item will have their own headers (therefore incurring an extra 8 bytes of overhead).
  231. Referring to the diagram above, the 16 bytes of free space at the tail of the buffer is insufficient
  232. to store the 28 byte item. Therefore the item is split into two parts (8 and 20 bytes) and written
  233. as two parts to the buffer.
  234. .. note::
  235. Allow-split buffers treats the both parts of the split item as two separate items, therefore call
  236. :cpp:func:`xRingbufferReceiveSplit` instead of :cpp:func:`xRingbufferReceive` to receive both
  237. parts of a split item in a thread safe manner.
  238. .. packetdiag:: ../../../_static/diagrams/ring-buffer/ring_buffer_wrap_byte_buf.diag
  239. :caption: Wrap around in byte buffers
  240. :align: center
  241. Byte buffers will **store as much data as possible into the free space at the tail of buffer**. The remaining
  242. data will then be stored in the free space at the head of the buffer. No overhead is incurred when wrapping
  243. around in byte buffers.
  244. Referring to the diagram above, the 16 bytes of free space at the tail of the buffer is insufficient to
  245. completely store the 28 bytes of data. Therefore the 16 bytes of free space is filled with data, and the
  246. remaining 12 bytes are written to the free space at the head of the buffer. The buffer now contains
  247. data in two separate continuous parts, and each part continuous will be treated as a separate item by the
  248. byte buffer.
  249. Retrieving/Returning
  250. ^^^^^^^^^^^^^^^^^^^^
  251. The following diagrams illustrates the differences between no-split/allow-split and
  252. byte buffers in retrieving and returning data.
  253. .. packetdiag:: ../../../_static/diagrams/ring-buffer/ring_buffer_read_ret_non_byte_buf.diag
  254. :caption: Retrieving/Returning items in no-split/allow-split ring buffers
  255. :align: center
  256. Items in no-split/allow-split buffers are **retrieved in strict FIFO order** and **must be returned**
  257. for the occupied space to be freed. Multiple items can be retrieved before returning, and the items
  258. do not necessarily need to be returned in the order they were retrieved. However the freeing of space
  259. must occur in FIFO order, therefore not returning the earliest retrieved item will prevent the space
  260. of subsequent items from being freed.
  261. Referring to the diagram above, the **16, 20, and 8 byte items are retrieved in FIFO order**. However the items
  262. are not returned in they were retrieved (20, 8, 16). As such, the space is not freed until the first item
  263. (16 byte) is returned.
  264. .. packetdiag:: ../../../_static/diagrams/ring-buffer/ring_buffer_read_ret_byte_buf.diag
  265. :caption: Retrieving/Returning data in byte buffers
  266. :align: center
  267. Byte buffers **do not allow multiple retrievals before returning** (every retrieval must be followed by a return
  268. before another retrieval is permitted). When using :cpp:func:`xRingbufferReceive` or
  269. :cpp:func:`xRingbufferReceiveFromISR`, all continuous stored data will be retrieved. :cpp:func:`xRingbufferReceiveUpTo`
  270. or :cpp:func:`xRingbufferReceiveUpToFromISR` can be used to restrict the maximum number of bytes retrieved. Since
  271. every retrieval must be followed by a return, the space will be freed as soon as the data is returned.
  272. Referring to the diagram above, the 38 bytes of continuous stored data at the tail of the buffer is retrieved,
  273. returned, and freed. The next call to :cpp:func:`xRingbufferReceive` or :cpp:func:`xRingbufferReceiveFromISR`
  274. then wraps around and does the same to the 30 bytes of continuous stored data at the head of the buffer.
  275. Ring Buffers with Queue Sets
  276. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  277. Ring buffers can be added to FreeRTOS queue sets using :cpp:func:`xRingbufferAddToQueueSetRead` such that every
  278. time a ring buffer receives an item or data, the queue set is notified. Once added to a queue set, every
  279. attempt to retrieve an item from a ring buffer should be preceded by a call to :cpp:func:`xQueueSelectFromSet`.
  280. To check whether the selected queue set member is the ring buffer, call :cpp:func:`xRingbufferCanRead`.
  281. The following example demonstrates queue set usage with ring buffers.
  282. .. code-block:: c
  283. #include "freertos/queue.h"
  284. #include "freertos/ringbuf.h"
  285. ...
  286. //Create ring buffer and queue set
  287. RingbufHandle_t buf_handle = xRingbufferCreate(1028, RINGBUF_TYPE_NOSPLIT);
  288. QueueSetHandle_t queue_set = xQueueCreateSet(3);
  289. //Add ring buffer to queue set
  290. if (xRingbufferAddToQueueSetRead(buf_handle, queue_set) != pdTRUE) {
  291. printf("Failed to add to queue set\n");
  292. }
  293. ...
  294. //Block on queue set
  295. xQueueSetMemberHandle member = xQueueSelectFromSet(queue_set, pdMS_TO_TICKS(1000));
  296. //Check if member is ring buffer
  297. if (member != NULL && xRingbufferCanRead(buf_handle, member) == pdTRUE) {
  298. //Member is ring buffer, receive item from ring buffer
  299. size_t item_size;
  300. char *item = (char *)xRingbufferReceive(buf_handle, &item_size, 0);
  301. //Handle item
  302. ...
  303. } else {
  304. ...
  305. }
  306. Ring Buffers with Static Allocation
  307. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  308. The :cpp:func:`xRingbufferCreateStatic` can be used to create ring buffers with specific memory requirements (such as a ring buffer being allocated in external RAM). All blocks of memory used by a ring buffer must be manually allocated beforehand then passed to the :cpp:func:`xRingbufferCreateStatic` to be initialized as a ring buffer. These blocks include the following:
  309. - The ring buffer's data structure of type :cpp:type:`StaticRingbuffer_t`
  310. - The ring buffer's storage area of size ``xBufferSize``. Note that ``xBufferSize`` must be 32-bit aligned for no-split/allow-split buffers.
  311. The manner in which these blocks are allocated will depend on the users requirements (e.g. all blocks being statically declared, or dynamically allocated with specific capabilities such as external RAM).
  312. .. note::
  313. When deleting a ring buffer created via :cpp:func:`xRingbufferCreateStatic`,
  314. the function :cpp:func:`vRingbufferDelete` will not free any of the memory blocks. This must be done manually by the user after :cpp:func:`vRingbufferDelete` is called.
  315. The code snippet below demonstrates a ring buffer being allocated entirely in external RAM.
  316. .. code-block:: c
  317. #include "freertos/ringbuf.h"
  318. #include "freertos/semphr.h"
  319. #include "esp_heap_caps.h"
  320. #define BUFFER_SIZE 400 //32-bit aligned size
  321. #define BUFFER_TYPE RINGBUF_TYPE_NOSPLIT
  322. ...
  323. //Allocate ring buffer data structure and storage area into external RAM
  324. StaticRingbuffer_t *buffer_struct = (StaticRingbuffer_t *)heap_caps_malloc(sizeof(StaticRingbuffer_t), MALLOC_CAP_SPIRAM);
  325. uint8_t *buffer_storage = (uint8_t *)heap_caps_malloc(sizeof(uint8_t)*BUFFER_SIZE, MALLOC_CAP_SPIRAM);
  326. //Create a ring buffer with manually allocated memory
  327. RingbufHandle_t handle = xRingbufferCreateStatic(BUFFER_SIZE, BUFFER_TYPE, buffer_storage, buffer_struct);
  328. ...
  329. //Delete the ring buffer after used
  330. vRingbufferDelete(handle);
  331. //Manually free all blocks of memory
  332. free(buffer_struct);
  333. free(buffer_storage);
  334. Ring Buffer API Reference
  335. -------------------------
  336. .. note::
  337. Ideally, ring buffers can be used with multiple tasks in an SMP fashion where the **highest
  338. priority task will always be serviced first.** However due to the usage of binary semaphores
  339. in the ring buffer's underlying implementation, priority inversion may occur under very
  340. specific circumstances.
  341. The ring buffer governs sending by a binary semaphore which is given whenever space is
  342. freed on the ring buffer. The highest priority task waiting to send will repeatedly take
  343. the semaphore until sufficient free space becomes available or until it times out. Ideally
  344. this should prevent any lower priority tasks from being serviced as the semaphore should
  345. always be given to the highest priority task.
  346. However in between iterations of acquiring the semaphore, there is a **gap in the critical
  347. section** which may permit another task (on the other core or with an even higher priority) to
  348. free some space on the ring buffer and as a result give the semaphore. Therefore the semaphore
  349. will be given before the highest priority task can re-acquire the semaphore. This will result
  350. in the **semaphore being acquired by the second highest priority task** waiting to send, hence
  351. causing priority inversion.
  352. This side effect will not affect ring buffer performance drastically given if the number
  353. of tasks using the ring buffer simultaneously is low, and the ring buffer is not operating
  354. near maximum capacity.
  355. .. include-build-file:: inc/ringbuf.inc
  356. .. _hooks:
  357. Hooks
  358. -----
  359. FreeRTOS consists of Idle Hooks and Tick Hooks which allow for application
  360. specific functionality to be added to the Idle Task and Tick Interrupt.
  361. ESP-IDF provides its own Idle and Tick Hook API in addition to the hooks
  362. provided by Vanilla FreeRTOS. ESP-IDF hooks have the added benefit of
  363. being run time configurable and asymmetrical.
  364. Vanilla FreeRTOS Hooks
  365. ^^^^^^^^^^^^^^^^^^^^^^
  366. Idle and Tick Hooks in vanilla FreeRTOS are implemented by the user
  367. defining the functions ``vApplicationIdleHook()`` and ``vApplicationTickHook()``
  368. respectively somewhere in the application. Vanilla FreeRTOS will run the user
  369. defined Idle Hook and Tick Hook on every iteration of the Idle Task and Tick
  370. Interrupt respectively.
  371. Vanilla FreeRTOS hooks are referred to as **Legacy Hooks** in ESP-IDF FreeRTOS.
  372. To enable legacy hooks, :ref:`CONFIG_FREERTOS_LEGACY_HOOKS` should be enabled
  373. in :doc:`project configuration menu </api-reference/kconfig>`.
  374. Due to vanilla FreeRTOS being designed for single core, ``vApplicationIdleHook()``
  375. and ``vApplicationTickHook()`` can only be defined once. However, the ESP32 is dual core
  376. in nature, therefore same Idle Hook and Tick Hook are used for both cores (in other words,
  377. the hooks are symmetrical for both cores).
  378. In a dual core system, ``vApplicationTickHook()`` must be located in IRAM (for example
  379. by adding the IRAM_ATTR attribute).
  380. ESP-IDF Idle and Tick Hooks
  381. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  382. Due to the the dual core nature of the ESP32, it may be necessary for some
  383. applications to have separate hooks for each core. Furthermore, it may
  384. be necessary for the Idle Tasks or Tick Interrupts to execute multiple hooks
  385. that are configurable at run time. Therefore the ESP-IDF provides it's own hooks
  386. API in addition to the legacy hooks provided by Vanilla FreeRTOS.
  387. The ESP-IDF tick/idle hooks are registered at run time, and each tick/idle hook
  388. must be registered to a specific CPU. When the idle task runs/tick Interrupt
  389. occurs on a particular CPU, the CPU will run each of its registered idle/tick hooks
  390. in turn.
  391. Hooks API Reference
  392. -------------------
  393. .. include-build-file:: inc/esp_freertos_hooks.inc
  394. .. _component-specific-properties:
  395. Component Specific Properties
  396. -----------------------------
  397. Besides standard component variables that could be gotten with basic cmake build properties FreeRTOS component also provides an arguments (only one so far) for simpler integration with other modules:
  398. - `ORIG_INCLUDE_PATH` - contains an absolute path to freertos root include folder. Thus instead of `#include "freertos/FreeRTOS.h"` you can refer to headers directly: `#include "FreeRTOS.h"`.