Commit graph

216 commits

Author SHA1 Message Date
Angus Gratton
4486d4cb10 portmux: Add vPortCPUAcquireMutexTimeout() function
Refactor app_trace locking to use this function.
2017-09-04 19:11:51 +10:00
Angus Gratton
397c0bfb4b freertos scheduler test: Free timer group interrupt handle when test finishes 2017-09-04 19:11:51 +10:00
Angus Gratton
5c996a1b29 freertos: Inline vPortCPUAcquireMutex/vPortCPUReleaseMutex into implementations
Further improves performance:
No contention -> 134 cycles
Recursion -> 117 cycles
Contention -> 323 cycles
2017-09-04 19:11:51 +10:00
Angus Gratton
db58a2732b freertos: vPortCPUReleaseMutex() no longer returns a value
Unlocking a never-locked mutex is an assertion failure in debug mode.

In release mode, this further improves performance:
No-Contention ->  153 cycles
Recursion No-Contention -> 138 cycles
Contention -> 378 cycles
2017-09-04 19:11:51 +10:00
Angus Gratton
4d42b2d100 freertos spinlock/portmux: Reduce spinlocking overhead
Ref TW7117

Microbenchmarks in unit tests:

(All numbers in cycles per benchmarked operation):

Release mode
No lock contention lock/unlock -       301 -> 167 (-45%)
Recursive no contention lock/unlock -  289 -> 148 (-49%)
Lock contention two CPUs (lock/unlock) 699 -> 400 (-43%)

Debug mode
No lock contention lock/unlock -       355 -> 203 (-43%)
Recursive no contention lock/unlock -  345 -> 188 (-46%)
Lock contention two CPUs (lock/unlock) 761 -> 483 (-36%)
2017-09-04 19:11:51 +10:00
Angus Gratton
f2952de3a5 freertos spinlocks/portmux: Add combination unit tests & microbenchmarks 2017-09-04 19:11:51 +10:00
Ivan Grokhotkov
e57a664798 Merge branch 'feature/freertos_interrupt_backtrace_opt' into 'master'
freertos: introduce CONFIG_FREERTOS_INTERRUPT_BACKTRACE

See merge request !1167
2017-08-31 10:45:06 +08:00
Ivan Grokhotkov
9a764f3108 Merge branch 'bugfix/freertos_xportgetcoreid_iram' into 'master'
freertos: make sure xPortGetCoreID is placed into IRAM

See merge request !1165
2017-08-29 13:32:37 +08:00
Ivan Grokhotkov
99a4b6b2db freertos: introduce CONFIG_FREERTOS_INTERRUPT_BACKTRACE
The code in xtensa_vectors.S did not handle XT_DEBUG_BACKTRACE
consistently: #if was used in one case, and #ifdef in another. This makes
the checks consistent, and also introduces a Kconfig option to enable
backtrace.
2017-08-29 08:54:26 +08:00
Ivan Grokhotkov
eb1b4f971b freertos: make sure xPortGetCoreID is placed into IRAM
In some cases, xPortGetCoreID was not inlined, and ended up in flash.
Since this function is used in many situations when cache is disabled,
that caused exceptions. Adding IRAM attribute to fix that.
2017-08-29 08:31:36 +08:00
Jeroen Domburg
d0bf9e61da Fix an assert that erroneously triggered when popping a zero-byte payload from the end of the ringbuffer 2017-08-28 19:31:26 +08:00
Ivan Grokhotkov
fb43948413 Update several Kconfig files to make help texts compatible with ReST 2017-08-22 14:34:19 +08:00
Kedar Sovani
ba8cd58b08 kconfig: Remove Wi-Fi on/off as a menuconfig option
This is no longer required since the functions automatically get
pulled in based on the usage. A quick summary of footprint
comparisions before and after these set of patches is shown below:

Hello-World: (simplified for readability)
 old Total image size:~ 104902 bytes (.bin may be padded larger)
 old Total image size:~ 105254 bytes (.bin may be padded larger)
 Per-archive contributions to ELF file:
             Archive File DRAM .data & .bss   IRAM Flash code & rodata   Total
 old              libesp32.a       1973    177   4445       3939     2267   12801
 new              libesp32.a       1973    185   4473       3939     2267   12837

 new             libnvs_flash.a          0     92      0        274        8     374
 new             libstdc++.a          0      0      0         24        0      24

For some reason, nvs_flash.a (~400bytes) gets pulled in (particularly
the nvs_flash_init() function).

Power-Save: (simplified for readability)
 old Total image size:~ 421347 bytes (.bin may be padded larger)
 old Total image size:~ 421235 bytes (.bin may be padded larger)

 old      libtcpip_adapter.a          0     81      0       1947      115       2143
 new      libtcpip_adapter.a          0     69      0       1897      115       2081

The size actually shrinks a bit, since the AP interface function
doesn't get pulled in.
2017-08-16 15:55:28 +05:30
krzychb
1fb85b494c JTAG Debugging - revamping of Debugging documentation 2017-07-26 14:53:43 +08:00
Angus Gratton
d664e32394 build system: Use component.mk for all components, refactor bootloader build
For config-only components, component.mk should now contain "COMPONENT_CONFIG_ONLY := 1"

Also refactored some of the generation of linker paths, library list. This required cleaning up the way the bootloader
project works, it's now mostly independent from the parent.
2017-07-19 09:10:48 +10:00
Ivan Grokhotkov
0ae916d555 Merge branch 'feature/high_level_interrupts' into 'master'
Break out high-level interrupts so a component can override them

See merge request !675
2017-07-18 10:42:31 +08:00
Angus Gratton
d601bedb85 pvPortMalloc: Fix regression when changing to new heap implementation 2017-07-12 11:10:11 +08:00
Angus Gratton
7ae93f271c Merge branch 'feature/multi_heap' into 'master'
Separate the heap implementation from FreeRTOS

See merge request !731
2017-07-12 10:53:37 +08:00
Angus Gratton
3ad163e644 freertos: Bump idle stack size to 1KB, min stack to 768 bytes, make configurable
Reverts regression mentioned at
3fe0022efa (commitcomment-23013504)
2017-07-11 14:48:15 +08:00
Angus Gratton
71c70cb15c heap: Refactor heap regions/capabilities out of FreeRTOS
Remove tagged heap API, rename caps_xxx to heap_caps_xxx

Also includes additional heap_caps_xxx inspection functions.
2017-07-10 17:46:03 +08:00
Angus Gratton
5ee49fd311 heap: Add new multi_heap heap implementation to replace FreeRTOS-based tagged heaps 2017-07-10 17:46:03 +08:00
Jeroen Domburg
1d748db209 Break out high-level interrupts so a component can override them 2017-07-07 12:51:33 +08:00
Angus Gratton
3fe0022efa stack sizes: Revert stack size increases added in 8d43859
Set min stack size to 2048 if AppTrace support is enabled, 512 bytes otherwise.
2017-06-29 14:57:13 +10:00
Alexey Gerenkov
8d43859b6a esp32: SEGGER SystemView Tracing Support
Implements support for system level traces compatible with SEGGER
SystemView tool on top of ESP32 application tracing module.
That kind of traces can help to analyse program's behaviour.
SystemView can show timeline of tasks/ISRs execution, context switches,
statistics related to the CPUs' load distribution etc.

Also this commit adds useful feature to ESP32 application tracing module:
 - Trace data buffering is implemented to handle temporary peaks of events load
2017-06-27 20:52:43 +03:00
Ivan Grokhotkov
7ed8c66547 Merge branch 'bugfix/uxTaskGetSystemState_github_#12142' into 'master'
Bugfix for uxTaskGetSystemState

See merge request !883
2017-06-20 17:27:08 +08:00
Darian Leung
1c798b0eab BugFix: uxTaskGetSystemState test case update
Updated test case to include configASSERT cases (+1 squashed commits)

Squashed commits:

[871ec26f] Freertos:Bugfix uxTaskGetSystemState

Bug (github #12142) with uxTaskGetSystemState where
if called immediately after creating a bunch of tasks,
those tasks would be added twice into the TaskStatusArray.
Bug caused due to use old implementation using vTaskSuspendAll
which did not stop newly created task on other core from accessing the
read/waiting task lists whilst the list were being read by
uxTaskGetSystemState. Fixed bug by replacing vTaskSuspendAll
with taskENTER_CRITICAL and added test case for the bugfix
2017-06-16 16:00:54 +08:00
Jiang Jiang Jian
9a6b1c3b11 Merge branch 'bugfix/always_disable_ints_in_critical_region' into 'master'
Always disable interrupts in a critical region

See merge request !821
2017-06-16 11:36:27 +08:00
Angus Gratton
8bf675786a Merge branch 'feature/freertos_get_priority' into 'master'
freertos: Mark uxTaskPriorityGet() as tested, add SMP task priority unit tests

See merge request !794
2017-06-14 08:31:00 +08:00
Jeroen Domburg
d4b0f85eb4 Make portENTER_CRITICAL and portENTER_CRITICAL_ISR the same, plus some changes to fix an issue this causes 2017-06-05 15:57:42 +08:00
Angus Gratton
b9fc5ecf68 freertos: Fix crash when waking task on CPU1 with scheduler disabled
xPendingReadyList[1] was never initialised correctly, so if a task is added to this list (ie by xSemaphoreGiveFromISR()
or similar) while scheduler is disabled, then it causes a null pointer dereference.

Bug produces stack traces similar to:
0x40086e87: vListInsertEnd at /home/gus/esp/32/idf/components/freertos/./list.c:130
0x40084ba3: xTaskRemoveFromEventList at /home/gus/esp/32/idf/components/freertos/./tasks.c:3439
0x40083c54: xQueueGiveFromISR at /home/gus/esp/32/idf/components/freertos/./queue.c:2034
0x400f50a0: timer_group0_isr at /home/gus/esp/32/idf/components/freertos/test/./test_suspend_scheduler.c:27
0x40081d7d: _xt_lowint1 at xtensa_vectors.o:?
2017-06-05 16:12:20 +10:00
Angus Gratton
f40ae10a5d freertos: add test case for ISRs waking tasks when scheduler disabled 2017-06-05 16:12:20 +10:00
jack
fc130fba86 fix bug that files missing commit in MR 773 2017-05-31 19:37:39 +08:00
Angus Gratton
4947c953d3 freertos: Mark uxTaskPriorityGet() as tested
Also adds some SMP-aware dynamic task priority unit tests
2017-05-29 16:19:00 +10:00
Angus Gratton
1ddf40feb7 Merge branch 'bugfix/freertos_larger_stacksize' into 'master'
Make internal stack size variables in FreeRTOS 32-bit instead of 16-bit

Stock FreeRTOS uses an uint16 to store stack sizes, making it impossible to allocate a stack >64K. This changes this into an uint32, allowing for larger stacks.

See merge request !677
2017-05-17 10:23:39 +08:00
Angus Gratton
304f0a399a freertos tests: Use CCOMPARE1 always in xPortInIsrContext() test
Mismatched CCOMPARE meant test would only run once.
2017-05-10 17:26:25 +10:00
Angus Gratton
895e7423a3 freertos: Preempt other CPU when deleting a task running on it
Includes related fix to preemption unit tests (delete a queue after deleting the task blocked on it.)
2017-05-10 17:23:33 +10:00
Jiang Jiang Jian
c518325385 Merge branch 'bugfix/dualcore_dport' into 'master'
component/esp32 : fix dualcore bug

1. When dual core cpu run access DPORT register, must do protection.
2. If access DPORT register, must use DPORT_REG_READ/DPORT_REG_WRITE and DPORT_XXX register operation macro.

See merge request !742
2017-05-10 11:27:01 +08:00
Tian Hao
26a3cb93c7 component/soc : move dport access header files to soc
1. move dport access header files to soc
2. reduce dport register write protection. Only protect read operation
2017-05-09 18:06:00 +08:00
Tian Hao
f7e8856520 component/esp32 : fix dualcore bug
1. When dual core cpu run access DPORT register, must do protection.
2. If access DPORT register, must use DPORT_REG_READ/DPORT_REG_WRITE and DPORT_XXX register operation macro.
2017-05-08 21:53:43 +08:00
Angus Gratton
72c7941b5e Unit tests: Add FreeRTOS timer tests 2017-05-05 14:38:15 +10:00
Ivan Grokhotkov
e18f8da528 Merge branch 'bugfix/assert_on_pin_task_nonexistent_cpu' into 'master'
Assert when a new task is started on a nonexisting CPU

Previously, starting a task on a CPU ID higher than the amount of CPUs FreeRTOS is configured with would not start the task and possibly have unintended side effects due to some out-of-bounds array writes. Assert on this so the app aborts cleanly.

See merge request !701
2017-04-28 19:55:26 +08:00
Angus Gratton
66726ec166 freertos: Enable vTaskSuspend()/vTaskResume() API
Adds relevant unit tests.

TW11878
2017-04-26 12:50:20 +10:00
Jeroen Domburg
aaeb2bd110 Assert when a new task is started on a nonexisting CPU 2017-04-25 17:47:25 +08:00
Jeroen Domburg
b209c6dcbb Make internal stack size variables in FreeRTOS 32-bit instead of 16-bit 2017-04-19 10:47:19 +08:00
Alexey Gerenkov
55f1a63faf esp32: Adds functionality for application tracing over JTAG
- Implements application tracing module which allows to send arbitrary
   data to host over JTAG. This feature is useful for analyzing
   program modules behavior, dumping run-time application data etc.
 - Implements printf-like logging functions on top of apptrace module.
   This feature is a kind of semihosted printf functionality with lower
   overhead and impact on system behaviour as compared to standard printf.
2017-04-17 23:26:29 +03:00
Jeroen Domburg
0b79d07d34 add detection of invalid cache access
- fix level 4 interrupt vectors to produce correct backtrace
- initialize invalid cache access interrupt on startup
- handle invalid cache access in panic handler
2017-04-13 15:27:38 +08:00
Angus Gratton
0b57054ed3 freertos tests: Extend preemption test cases to cross-core wakeup 2017-04-04 10:10:08 +10:00
Angus Gratton
bdbeaf97d6 freertos tests: Fix accidental "0 delay" in event group tests
Was a slight race condition where tasks on other CPU may not have finished waking up on BIT_CALL when the unity task
polled the event group state.
2017-04-04 10:10:08 +10:00
Angus Gratton
45581dbaca freertos: Delay context switch from queue/task APIs until exiting critical section
Closes #374: https://github.com/espressif/esp-idf/issues/374
2017-04-04 10:10:08 +10:00
Jeroen Domburg
0e39b77d4e Fix finding location of ISR stack space for CPU1 2017-03-28 15:50:10 +08:00