Commit Graph

579 Commits

Author SHA1 Message Date
Renz Bagaporo
d1c800fbbb components: fix ldgen check errors 2021-01-19 11:17:18 +08:00
Alexey Gerenkov
ae1cc5f49b freertos: Adds snapshot API to walk over tasks lists 2021-01-15 06:37:12 +00:00
Jakob Hasse
b51889dccb system: stack watchpoint support on C3
Closes IDF-2307
2021-01-14 17:46:44 +08:00
morris
753a929525 global: fix sign-compare warnings 2021-01-12 14:05:08 +08:00
Marius Vikhammer
9c8e4fd4c5 C3: build and run unit tests
Enable building and running of unit tests in CI for C3 as well as fix
related compile errors

Also enables building of C3 test apps
2021-01-11 11:34:37 +08:00
morris
9e7d2c0065 esp32c3: format and clean up interrupt and os port code 2021-01-05 15:39:46 +08:00
Felipe Neves
544a3f7df5 interrupt-allocator: reject vector allocation if its marked as not-implemented. and search to next available 2021-01-05 15:39:46 +08:00
Felipe Neves
ec5acf91ee esp_shared_stack: enable shared stack function for riscv and reenable the unit test 2021-01-05 15:39:46 +08:00
Felipe Neves
f4781d3b1d freertos: riscv port now uses interrupt allocator and crosscore interrupt 2021-01-05 15:39:46 +08:00
Felipe Neves
810be86f21 freertos/riscv: move freertos aware interrupt code from vectors to the freertos riscv port.
The riscv vectors.S in riscv component contains the trap vector, which is responsible to
defer interrupts and examine if a task context switch is needed, this change cleans up
this code by hiding all freertos details behind on two functions rtos_it_enter/exit and
their implementations are placed in freertos riscv port files.
2021-01-05 15:39:46 +08:00
Ivan Grokhotkov
7f3b16a99d freertos: always enable static allocation
to use it for newlib locks
2020-12-29 16:18:04 +01:00
Angus Gratton
8a52f20a79 Merge branch 'feature/freertos_add_xQueueGenericReceive' into 'master'
freertos: add `xQueueGenericReceive` for backward compatibility

See merge request espressif/esp-idf!11169
2020-12-24 12:20:03 +08:00
Mahavir Jain
953418dbb4 Merge branch 'bugfix/missing_coreinfo_in_vtasklist' into 'master'
freertos: Fix missing affinity info in vTaskList

Closes IDFGH-4239 and IDFGH-4241

See merge request espressif/esp-idf!11606
2020-12-21 19:43:40 +08:00
Axel Lin
29b6b0ce0d freertos: Fix missing affinity info in vTaskList
Show affinity info if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is set.

Closes https://github.com/espressif/esp-idf/pull/6099
Closes https://github.com/espressif/esp-idf/issues/6097

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2020-12-14 16:50:07 +05:30
Ivan Grokhotkov
8bf1c2565f freertos: clarify statement on task function not returning
Mentioned in https://www.esp32.com/viewtopic.php?f=2&t=18220.
2020-12-02 11:58:56 +01:00
Angus Gratton
5228d9f9ce esp32c3: Apply one-liner/small changes for ESP32-C3 2020-12-01 10:58:50 +11:00
Mahavir Jain
c62a9e5f2c freertos: add xQueueGenericReceive for backward compatibility
Add `xQueueGenericReceive` as that has been removed in FreeRTOS10.
This in turn breaks pre-builts libraries with earlier IDF releases
relying on this API.

Closes https://github.com/espressif/esp-wolfssl/issues/6
2020-11-27 19:08:42 +05:30
Angus Gratton
87e13baaf1 freertos: Add RISC-V port
Changes come from internal branch commit a6723fc
2020-11-13 07:49:11 +11:00
Angus Gratton
66fb5a29bb Whitespace: Automated whitespace fixes (large commit)
Apply the pre-commit hook whitespace fixes to all files in the repo.

(Line endings, blank lines at end of file, trailing whitespace)
2020-11-11 07:36:35 +00:00
Mahavir Jain
199b2cb79d freertos: add parameter validation checks in xTaskCreateStaticPinnedToCore
Regression from commit-id a3c90bf59a
2020-10-21 14:05:01 +11:00
Angus Gratton
c87fe77ef9 freertos: Restore the check that mutex is given by owner
Even without this check, if the owner doesn't match then FreeRTOS will still
fail an assertion - but it's not as clear what the root cause is.
2020-10-21 14:04:01 +11:00
Angus Gratton
8a70b1cdc9 ci freertos: Add test configs for some of the optional FreeRTOS 10 configurations
Also unit tests for the legacy hook functions.
2020-10-21 14:04:01 +11:00
Angus Gratton
bb74334830 freertos: Fix regression when xCoreID included in task status TCB
Regression when adding FreeRTOS 10 support.

As reported at https://github.com/espressif/esp-idf/issues/1453#issuecomment-709663537
2020-10-20 14:06:28 +11:00
Angus Gratton
1224ae9a42 freertos: Use configured idle task stack size not minimum task stack size for idle tasks 2020-10-14 16:11:49 +11:00
Angus Gratton
30b5aab77a freertos: Fix some edge cases around un-pinned tasks migrating cores 2020-10-14 16:11:49 +11:00
Felipe Neves
dfa2d547a7 freertos: pin timer task in core 0 plus fixed in SMP race conditions
freertos: replace the freertos regular malloc to the specific malloc from xtensa port for tcb and stack allocations

freertos: avoid the cpu1 to unwind pended ticks when xTaskResumeAll is called insed of an ISR

freertos: protected the xPortGetCoreID functions with missing critical sections

tests: re-eanble the ignored tests that was failling before race-condition fixes
2020-10-14 16:11:49 +11:00
Felipe Neves
3057b76a7e tests: re-add all disabled tests and all disabled configurations 2020-10-14 16:11:49 +11:00
Felipe Neves
206540909e freertos: readd task checking for stack overflow macros 2020-10-14 16:11:49 +11:00
Felipe Neves
656b706ea4 freertos: added core-ID member to task status structure aloowing its tracing.
Closes https://github.com/espressif/esp-idf/issues/5763
2020-10-14 16:11:39 +11:00
Felipe Neves
f3783ba258 app_trace/sysview: fixed freertos tracing calling plus sync apptrace component with the master branch version
docs: remove reference to backported features in freertos 10 api-reference.
2020-10-13 23:52:03 +00:00
Felipe Neves
d8ed9be1d4 freertos/timer: fix the static timer creation
Removes the not used spinlock field inside timer object which was causing assertion fail
2020-10-13 23:52:03 +00:00
Felipe Neves
a3c90bf59a freertos: merged freertos 10 kernel files into IDF
freertos/port: update the port files and split into xtensa and riscv ports

freertos: separated cpu files from rest of the kernel sources

freertos/port_xtensa: separated private include files into a folder

freertos/tasks: added task create pinned to core function do not break current IDF API

freertos/tasks: mimiced task create pinned function into tasks.c to do not break the IDF API.

freertos: freertos component now compiling

freertos: freertos component now building

freertos: moved critical sections outside from FR kernel section to portable section

portmacro_xtensa: add void indentifier on functions that take no arguments

freertos: fix critical sections implementation to match with their function prototype

freertos: add cmake changes of freertos into make

freertos: remove portDONT_DISCARD attribute from switch context function, it was breaking the docs building.

freertos: fix conflicitng types of vApplicationSleep function

license: update the license of freertos

freertos: Doxygen comments refactored to render them correctly on docs

freertos: added new functions of freertos into the documentation

freertos: added message buffers and stream buffers to documentation

sysview: update freertos system view to the compatible with version 10

freertos: fixed event group  documentation rendering

freertos:  update static task structure to match the actual tcb size

freertos: removed backported test functions

freertos/smp: brought SMP code to  FreeRTOS 10 port

freertos/portmacro: added missing crosscore interrupt for yielding tasks

freertos: replaced soft-critical sections with hard-critical sections used by SMP

freertos: placed muxes inside of kernel objects

freertos: replaced original FR critical sections with SMP enabled spinlocks critical sections

freertos: moved xtensa port files to a separated folder

freertos: added multiple instance of global variables required to SMP

freertos: added SMP modifications on specific tasks module functions

freertos: added TLS deletion function to task module

freertos/tls: initialize TLS deletion callback to avoid crashing when calling task delete

freertos: modified vTaskDelete to do not erase current task that runs on other core

freertos: reverted taskhandle and timerhandle as void* type

freertos: fixed de-referencing void pointer to get run time counter

freertos: fix system view trace enter macro arguments

freertos: Replaced soft critical sections with spinlocks on event_groups

freertos: fixed tick function to avoid calling tick hooks twice

freertos: Nofity give checking per CPU if schedule is suspended

freertos: added mpu release on TCB deletion

freertos: Added SMP changes when deleting a TCB on idle task

freertos/license: update freertos license in COPYRIGHT.rst

freertos: unicore configurations can use task create pinned to core, it will be always pinned to core 0

freertos/portmacro: added cpu_hal_get_core_id() function instead of inline assembly

freertos/xtensa:  update xtensa specific files used in master branch

newlib/locks: revert the preemption checking in lock acquisition and release

ref_clock: fix initial state of ref_clock interrupt handler

freertos: added missing critical sections and yielding checkings

freertos: remove magic numbers in vTaskDelete

freertos: added missing critical section in prvIsQueueEmpty
2020-10-13 23:52:03 +00:00
Ivan Grokhotkov
654124adf0 freertos: don't create timer task if timer APIs are not used
Saves 2496 bytes of heap for the hello-world app on the ESP32,
and 4080 bytes of heap on the ESP32-S2 (due to IRAM savings).
2020-10-02 17:58:36 +02:00
Mahavir Jain
20af94ff53 Coredump config option rename throughout IDF 2020-09-30 20:22:27 +05:30
Felipe Neves
2e826b7a8f intr_alloc: split interrupt allocator into common-code and platform-code
esp_system: removed repeated interrupt allocator code and moved common code to esp_system

xtens: moved xtensa specific code from freertos to the xtensa component

hal/interrupt_controller: added interrupt controller hal and ll files

docs: update the doxyfile with new location of esp_itr_alloc.h file

xtensa: fixed dangerous relocation problem after moving xtensa interrupt files out of freertos

docs: removed Xtensa reference from intr_allocator api-reference

xtensa: pushed the interrupt function that manages non iram interrupts to the xtensa layer

esp_system/test: fixed platform dependent setting for intr_allocator tests

hal: rename the functions used to manage non iram interrupt mask.
2020-09-30 07:44:12 +08:00
morris
61f89b97c6 bringup esp32-s3 on FPGA 2020-09-22 15:15:03 +08:00
chenjianqiang
f19cabb7e4 psram: support psram for esp32s3 2020-09-22 15:15:03 +08:00
Felipe Neves
e67162a7ea startup: namespaced start_app and start_app_other_core to avoid user code collision 2020-09-15 16:05:19 -03:00
Felipe Neves
a1e5dd58b2 startup: moved init core functions out of iram memory 2020-09-15 16:02:12 -03:00
Felipe Neves
d59e8b50d2 freertos: move startup code out of iram memory 2020-09-15 16:02:12 -03:00
Ivan Grokhotkov
8bc19ba893 Merge branch 'feature/free_components_iram' into 'master'
freertos: free IRAM space moving task functions into flash memory

See merge request espressif/esp-idf!5648
2020-09-15 23:14:31 +08:00
Alex Lisitsyn
eaa892bebf freertos: optionally place selected freertos functions into flash memory instead of IRAM
correct generation.py script to be silent when file: function is not in the object list (just ignore placement)
correct linker.lf to place task functions into flash if CONFIG_FREERTOS_TASK_FUNCTIONS_INTO_FLASH is active otherwise into IRAM
update kconfig option to place functions into IRAM
update linker file after tests
fix spi_device_polling_end crash when xTaskGetTickCount() in flash
disable "yield from lower priority task, other CPU" test case when placing rtos functions into flash
upadate ut app config freertos_flash
combine spi_flash driver and freertos ut configs into one file
remove TEST_EXCLUDE_COMPONENTS
ci: fix ut job
remove functions that are called from ISR funcs
add port module functions to place into Flash
place snapshot funcs into Flash when ESP_PANIC_HANDLER_IRAM is not set
ci: add job with tags UT_T1_GPIO,ESP32_IDF
2020-09-15 23:14:31 +08:00
Felipe Neves
c471cce26c freertos/tests: added isr latency test with no parameter and parameter based yield from ISR 2020-09-14 16:12:38 +00:00
Felipe Neves
36b2737bb1 freertos/xtensa: make vportYIELD_FROM_ISR compatible with version that both takes argument or not 2020-09-14 16:12:38 +00:00
Ivan Grokhotkov
b6467257b9 Merge branch 'feature/cmock_component' into 'master'
cmock as component replacing unity

See merge request espressif/esp-idf!9859
2020-09-10 16:06:20 +08:00
Ivan Grokhotkov
04b95f3567 freertos: don't clobber a4 while spilling register windows
Commit 891eb3b0 was fixing an issue with PS and EPC1 not being
preserved after the window spill procedure. It did so by saving PS in
a2 and EPC1 in a4. However the a4 register may be a live register of
another window in the call stack, and if it is overwritten and then
spilled to the stack, then the corresponding register value will end
up being corrupted. In practice the problem would show up as an
IllegalInstruction exception, when trying to return from a function
when a0 value was 0x40020.
Fix by using a0 register instead of a4 as scratch. Also fix a comment
about xthal_save_extra_nw, as this function in fact doesn't clobber
a4 or a5 because XCHAL_NCP_NUM_ATMPS is defined as 1.

Closes https://github.com/espressif/esp-idf/issues/5758
2020-09-02 15:40:41 +02:00
Jakob Hasse
20c068ef3b cmock: added cmock as component
* changing dependencies from unity->cmock
* added component.mk and Makefile.projbuild
* ignore test dir in gen_esp_err_to_name.py
* added some brief introduction of CMock in IDF
2020-09-02 16:38:37 +08:00
Ivan Grokhotkov
7acda7b8eb Merge branch 'bugfix/panic_instr_fetch_prohibited' into 'master'
panic: don't interrupt the backtrace for InstrFetchProhibited exceptions

See merge request espressif/esp-idf!9851
2020-08-07 21:43:35 +08:00
Ivan Grokhotkov
600665a563 Merge branch 'bugfix/esp32s2_o2_op' into 'master'
freertos: fix build error at -O2 optimization level

Closes IDFGH-3581

See merge request espressif/esp-idf!9444
2020-08-05 22:03:00 +08:00
Ivan Grokhotkov
4e7e8598f3 freertos: ensure the interrupt stack is aligned
CONFIG_FREERTOS_ISR_STACKSIZE was set to 2100 when ELF core dump was
enabled, which resulted in a non-16-byte-aligned interrupt stack
offset. This triggered "is SP corrupted" check in the backtrace,
terminating the backtrace early.

Fix the default value, and make sure that the stack is always aligned,
regardless of the value of CONFIG_FREERTOS_ISR_STACKSIZE.
2020-08-05 12:51:41 +02:00
Angus Gratton
75402afcae Merge branch 'feature/esp32s3_clk_memory_layout' into 'master'
esp32s3: memory layout

See merge request espressif/esp-idf!9753
2020-07-29 13:48:25 +08:00
morris
2917651478 esp_rom: extract common ets apis into esp_rom_sys.h 2020-07-27 15:27:01 +08:00
morris
19761e3113 esp32s3: clk, memory layout 2020-07-27 13:05:22 +08:00
Ivan Grokhotkov
39bdbd7e33 freertos: fix compilation warning at -O2 level
Closes https://github.com/espressif/esp-idf/issues/5525
2020-07-15 12:50:51 +00:00
Ivan Grokhotkov
8e6d450a8c Revert "Merge branch 'feature/gdb_stub_task_state' into 'master'"
This reverts commit c41a0c1907, reversing
changes made to 5c1d317766.
2020-07-09 17:16:47 +02:00
Ivan Grokhotkov
4cdc5edb4e Revert "freertos, soc: don't lower INTLEVEL when entering critical sections"
This reverts commit 614a580bbb.
2020-07-09 17:15:54 +02:00
Renz Bagaporo
98dc1b0188 esp_system: introduce intermediary function to call after system init
This MR uses an intermediary function `start_app` to call after system
initialization instead of `app_main`.

In RTOS builds, freertos provides `start_app` and calls `app_main`.
In non-RTOS builds, user provides `start_app` directly.
2020-06-19 18:40:10 +10:00
Renz Bagaporo
08cbfa6187 esp_system: fix various review issues 2020-06-19 18:40:10 +10:00
Renz Bagaporo
5e59b4a812 freertos: mark port_xSchedulerRunning as volatile 2020-06-19 18:40:10 +10:00
Renz Christian Bagaporo
67983d5c1c esp_system: restore order of some init functions 2020-06-19 18:40:10 +10:00
Renz Christian Bagaporo
ef2a44d251 esp_system: introduce single core mode proxy config 2020-06-19 18:40:10 +10:00
Renz Christian Bagaporo
c53ad56515 esp_system: startup flow modifications
Changes the startup flow to the ff:

hardware -> core libraries init  -> other libraries init -> os
init (optional) -> app_main

- hardware init resides in the port layer, and is the entry point

- core libraries init executes init functions of core components

- other libraries init executes init functions of other components (weak
references)

- after other lib is init, the app_main function is called, however,

 an OS can wrap the real call to app_main to init its own stuff, and
 *then* call the real app_main
2020-06-19 18:40:09 +10:00
Renz Bagaporo
bb5535ca5d esp32, esp32s2: move startup code into esp_system 2020-06-19 18:40:09 +10:00
Ivan Grokhotkov
f4ea9d4cea freertos: increase configMINIMAL_STACK_SIZE when building with -O0
FreeRTOS scheduler uses additional stack space, as in some functions
variables are placed onto the stack instead of registers.

This issue resulted in occasional stack overflows in dport task, when
compiling at -O0 optimization level.

- Increase the configMINIMAL_STACK_SIZE to 1kB.
- Enable the watchpoint at the end of stack in CI startup test for
  this optimization level.
2020-06-02 18:51:16 +02:00
Ivan Grokhotkov
614a580bbb freertos, soc: don't lower INTLEVEL when entering critical sections
This fixes the issue where XTOS_SET_INTLEVEL would lower INTLEVEL from
4 to 3, when eTaskGetState is invoked during the core dump, triggered
from the interrupt watchdog.
2020-06-02 15:42:24 +02:00
Darian Leung
11d96b39d0 esp_ipc: Move to new component
This commit moves esp_ipc into a separate component.
2020-05-18 16:51:45 +08:00
Dmytro
ecbfe0f406 Fix usage example in xSemaphoreCreateBinaryStatic 2020-05-14 18:57:48 +08:00
Alexey Gerenkov
c91ed2b917 coredump: Increases FreeRTOS ISR stack for ELF data format 2020-05-06 20:07:30 +03:00
Angus Gratton
c41a0c1907 Merge branch 'feature/gdb_stub_task_state' into 'master'
feature/gdb_stub: make task state available on info thread command when in gdb stub.

Closes IDF-720

See merge request espressif/esp-idf!8371
2020-04-29 13:21:31 +08:00
Felipe Neves
c296d01737 gdbstub: added cpu id of running tasks to the output 2020-04-27 14:41:55 +00:00
Felipe Neves
5279e68146 gdbstub: improve format of info thread command output
gdbstub: simplify the state handling on extra thread info
2020-04-27 14:41:55 +00:00
Felipe Neves
140c5e0677 freertos: added task state field inside of TaskSnapshot_t to capture it. 2020-04-27 14:41:55 +00:00
Felipe Neves
5847e0afd2 freertos/test: fix overflow on accumulator used on scheduling time test 2020-04-27 14:20:13 +00:00
Michael (XIAO Xufeng)
9d98111652 Merge branch 'bugfix/spi_bus_lock_missing_semphrstatic' into 'master'
spi: fix config break and reduce overhead of the bus lock on SPI1

Closes IDFGH-3017

See merge request espressif/esp-idf!8221
2020-04-27 12:57:19 +08:00
morris
91e62f4e37 timer_group: update hal api && fix intr_enable
timer group interrupt enable is controled by level_int_ena instead of int_ena

Closes https://github.com/espressif/esp-idf/issues/5103
2020-04-23 19:29:15 +08:00
michael
1ca25688a8 freertos: place xQueueGenericCreateStatic into flash
`xQueueGenericCreateStatic` is placed into flash by the linker script to
reduce IRAM usage.  This will also cause the `xRingbufferCreate` not
not callable when cache is disabled.
2020-04-22 16:06:13 +08:00
michael
fdf983e0c4 spi: fix config break and reduce overhead of the bus lock on SPI1
The SPI bus lock on SPI1 introduces two side effects:

1. The device lock for the main flash requires the
`CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION` to be selected, however this
option is disabled by default in earlier IDF versions. Some developers
may find their project cannot be built by their old sdkconfig files.

2. Usually we don't need the lock on the SPI1 bus, due to it's
restrictions. However the overhead still exists in this case, the IRAM
cost for static version of semaphore functions, and the time cost when
getting and releasing the lock.

This commit:

1. Add a CONFIG_SPI_FLASH_BYPASS_MAIN_LOCK option, which will forbid the
space cost, as well as the initialization of the main bus lock.

2. When the option is not selected, the bus lock is used, the
`CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION` will be selected explicitly.

3. Revert default value of `CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION`
to `n`.

introduced in 49a48644e4.

Closes https://github.com/espressif/esp-idf/issues/5046
2020-04-22 16:06:13 +08:00
David Cermak
2e28ab29c7 freertos: silence the static analysis warning referencing the workitem 2020-03-27 18:46:39 +01:00
Michael (XIAO Xufeng)
49a48644e4 spi: allow using esp_flash and spi_master driver on the same bus 2020-03-26 22:08:26 +08:00
Renz Bagaporo
3d0967a58a test: declare requirements and include dirs private 2020-03-23 10:58:50 +08:00
Renz Christian Bagaporo
2b100789b7 esp32, esp32s2: move panic handling code to new component 2020-03-10 19:56:24 +08:00
Renz Christian Bagaporo
db608736fb freertos: implement get core id with cpu abstraction 2020-02-27 07:14:21 +05:00
Sachin Parekh
301dacfb33 Exception handlers for LoadStoreError and LoadStoreAlignmentError
Configurable option to use IRAM as byte accessible memory (in single core mode) using
load-store (non-word aligned and non-word size IRAM access specific) exception handlers.
This allows to use IRAM for use-cases where certain performance penalty
(upto 170 cpu cycles per load or store operation) is acceptable. Additional configuration
option has been provided to redirect mbedTLS specific in-out content length buffers to
IRAM (in single core mode), allows to save 20KB per TLS connection.
2020-02-26 20:21:59 +08:00
Felipe Neves
9c8289b0d9 shared_stack: using watchpoint 1 to monitor the shared_stack instead of watchpoint 0 2020-02-10 12:03:30 -03:00
Konstantin Kondrashov
739eb05bb9 esp32: add implementation of esp_timer based on TG0 LAC timer
Closes: IDF-979
2020-02-06 14:00:18 +08:00
Angus Gratton
86034ad049 Merge branch 'feature/freertos_fpu_isr' into 'master'
feature/fpu: Enable usage of FPU inside of a ISR

Closes IDF-100

See merge request espressif/esp-idf!7348
2020-01-30 13:38:37 +08:00
Felipe Neves
429712c6eb freertos: moved all xtensa specific files into a separated folder 2020-01-27 16:05:30 -03:00
Felipe Neves
5cbb3f05c0 freertos: Added experimental, optional FPU usage on level 1 ISR 2020-01-27 10:55:03 -03:00
Felipe Neves
670ea56df2 freertos: added fpu in isr test case 2020-01-27 10:55:03 -03:00
Ivan Grokhotkov
cbb84e8f5e esp32s2: fix THREADPTR calculation, re-enable FreeRTOS TLS tests
1. Clarify THREADPTR calculation in FreeRTOS code, explaining where
the constant 0x10 offset comes from.

2. On the ESP32-S2, .flash.rodata section had different default
alignment (8 bytes instead of 16), which resulted in different offset
of the TLS sections. Unfortunately I haven’t found a way to query
section alignment from C code, or to use a constant value to define
section alignment in the linker script. The linker scripts are
modified to force a fixed 16 byte alignment for .flash.rodata on the
ESP32 and ESP32-S2beta. Note that the base address of .flash.rodata
was already 16 byte aligned, so this has not changed the actual
memory layout of the application.

Full explanation of the calculation below.

Assume we have the TLS template section base address
(tls_section_vma), the address of a TLS variable in the template
(address), and the final relocation value (offset). The linker
calculates:
offset = address - tls_section_vma + align_up(TCB_SIZE, alignment).

At run time, the TLS section gets copied from _thread_local_start
(in .rodata) to task_thread_local_start. Let’s assume that an address
of a variable in the runtime TLS section is runtime_address.
Access to this address will happen by calculating THREADPTR + offset.
So, by a series of substitutions:

THREADPTR + offset = runtime_address THREADPTR = runtime_address - offset
THREADPTR = runtime_address - (address - tls_section_vma + align_up(TCB_SIZE, alignment)) THREADPTR = (runtime_address - address) + tls_section_vma - align_up(TCB_SIZE, alignment)

The difference between runtime_address and address is same as the
difference between task_thread_local_start and _thread_local_start.
And tls_section_vma is the address of .rodata section, i.e.
_rodata_start. So we arrive to

THREADPTR = task_thread_local_start - _thread_local_start + _rodata_start - align_up(TCB_SIZE, alignment).

The idea with TCB_SIZE being added to the THREADPTR when computing
the relocation was to let the OS save TCB pointer in the TREADPTR
register. The location of the run-time TLS section was assumed to be
immediately after the TCB, aligned to whatever the section alignment
was. However in our case the problem is that the run-time TLS section
is stored not next to the TCB, but at the top of the stack. Plus,
even if it was stored next to the TCB, the size of a FreeRTOS TCB is
not equal to 8 bytes (TCB_SIZE hardcoded in the linker). So we have
to calculate THREADPTR in a slightly obscure way, to compensate for
these differences.

Closes IDF-1239
2020-01-23 11:29:22 +01:00
morris
e30cd361a8 global: rename esp32s2beta to esp32s2 2020-01-22 12:14:38 +08:00
Felipe Neves
73592d9bc4 spin_lock: added new spinlock interface and decoupled it from RTOS
spin_lock: cleaned-up port files and removed portmux files

components/soc: decoupled compare and set operations from FreeRTOS

soc/spinlock: filled initial implementation of spinlock refactor

It will decouple the spinlocks into separated components with not depencences of freertos
an similar interface was provided focusing the readabillity and maintenance, also
naming to spinlocks were adopted. On FreeRTOS side the legacy portMUX macros
gained a form of wrapper functions that calls the spinlocks component thus
minimizing the impact on RTOS side.

This feature aims to close IDF-967

soc/spinlock: spinlocks passed on unit test, missing test corner cases

components/compare_set: added better function namings plus minor performance optimization on spinlocks

soc/spinlock: code reordering to remove ISC C90 mix error

freertos/portmacro: gor rid of critical sections multiline macros, placed inline functions instead

soc/spinlock: improved spinlock performance from internal RAM

For cases where the spinlock is executed from IRAM, there is no
need to check where the spinlock object is placed on memory,
removing this checks caused a great improvement on performance.
2020-01-22 06:20:34 +08:00
Felipe Neves
5d7564a039 freertos/Kconfig: make optimized task selection dependent on FREERTOS_UNICORE option
freertos: fix decrement loop of high priority task selection
2020-01-14 09:58:14 -03:00
Felipe Neves
2c612ec1dc components/freertos: using the optimized task selection on esp32s2beta
components/freertos: cleaned up multicore option scheduler.

components/freertos:  more cleanup and test optimization to present realistic results

components/freertos: remove unused macros of optimized task selection when multicore is used
2020-01-14 09:58:14 -03:00
Felipe Neves
77bf1ff1c0 freertos/tests: added test to evaluate scheduling time
freertos/Kconfig: fix trailing space on optimized scheduler option

freertos/tests: moved test context variables inside of test task.

The public variables used on scheduling time test now were packed into a structure allocated on  test case task stack and passed to tasks as arguments saving RAM comsumption.
2020-01-14 09:58:14 -03:00
Felipe Neves
d4c82606fb components/freertos: added and enabled the optimized task selection
FreeRTOS  have an platform dependent configuration to enable selection task in a optimized way.

Provided the platform dependent functions in order to allow the scheduler to use the optimized algorithms by telling to the port layer where to found bitscan instruction i.e. NSAU.

This closes IDF-1116

components/freertos: added option to disable the optimized scheduler
2020-01-14 09:58:14 -03:00
Angus Gratton
bdf6c00154 Merge branch 'feature/likely_unlikely' into 'master'
Adding likely unlikely macros to hot code paths

Closes IDF-284

See merge request espressif/esp-idf!6368
2020-01-10 14:05:07 +08:00
Angus Gratton
6ab9f846c9 Merge branch 'bugfix/compare_and_setextram' into 'master'
bugfix/pthread: fix pthread_once() race condiion possibility adding critical section in compare and set function

Closes IDFGH-2448

See merge request espressif/esp-idf!7236
2020-01-10 12:29:54 +08:00
Krzysztof Bociurko
c7dfb435f8 Fixed error in return type of xTaskCreateStatic*
Signed-off-by: Darian <darian@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/2651
2020-01-09 14:01:20 +08:00
Felipe Neves
9800750f15 freertos/port: Put critical sections around uxPortCompareSetExtram() to prevent preemption during its execution.
Closes: https://github.com/espressif/esp-idf/issues/4561
2020-01-07 10:53:30 -03:00