Commit graph

72 commits

Author SHA1 Message Date
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
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 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
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
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
Daniel Campora 01ad387ac8 freertos: Add config parameters to customize FreeRTOS behaviour.
The options are:
    - SUPPORT_STATIC_ALLOCATION
    - ENABLE_STATIC_TASK_CLEAN_UP_HOOK
    - TIMER_TASK_PRIORITY
    - TIMER_TASK_STACK_DEPTH
    - TIMER_QUEUE_LENGTH

Merges #444 https://github.com/espressif/esp-idf/pull/444
2017-03-22 15:21:38 +08:00
Angus Gratton 8de26e434c freertos: Schedule tasks immediately when they are created on opposite core 2017-02-28 15:47:15 +11:00
Jeroen Domburg ce7d0a7015 Fixed a small bug where a task could initially be scheduled on a wrong CPU, and a much bigger bug where a yield was performed with a held mux. 2017-02-22 17:04:51 +08:00
Liu Zhi Fu 0017e75bda freertos: fix protection issue in freertos queue event list
When functions in queue.c calls listLIST_IS_EMPTY() to check queue event list, the queue list is
protected by queue mutex, on the other hand, when xTaskIncrementTick() modify the queue list, the
 queue list is protected by xTaskQueueMutex, this may cause xTaskRemoveFromEventList operate on
the empty queue list and cause problem. This commit is to fix this bug.

may cause
2017-02-10 10:30:17 +08:00
Jeroen Domburg d07a149e2c Fix interrupting task on other CPU that has lower prio than current task on current CPU 2017-02-06 17:53:07 +08:00
Ivan Grokhotkov 31ec0a7c44 freertos: call tick hooks on CPU1 even if CPU0 scheduler is suspended
The block which dispatches ticks on CPU1 was a copy of the code block
for the normal path (CPU0). It used to check uxPendedTicks, with the
logic that uxPendedTicks can be 0 iff the scheduler is not suspended.

On CPU1 however, uxPendedTicks is not related to the state of the
scheduler (as uxPendedTicks is updated on CPU0). Due to this, if CPU0
scheduler was suspended, and uxPendedTicks happened to be nonzero,
tick hooks on CPU1 didn’t run, even though CPU1 scheduler was working.

This change removes the check for uxPendedTicks in CPU1 code path,
so that the tick hooks on CPU1 always get called (as for the CPU0 code
path).
2017-01-18 23:19:05 +08:00
Alexey Gerenkov 39ddc7b836 esp32: Fixes several issues in core dump feature
1) PS is fixed up to allow GDB backtrace to work properly
2) MR!341 discussion: in core dump module: esp_panicPutXXX was replaced by ets_printf.
3) MR!341 discussion: core dump flash magic number was changed.
4) MR!341 discussion: SPI flash access API was redesigned to allow flexible critical section management.
5) test app for core dump feature was added
6) fixed base64 file reading issues on Windows platform
7) now raw bin core file is deleted upon core loader failure by epscoredump.py
2017-01-11 20:51:28 +03:00
Alexey Gerenkov 4a3e160888 esp32: Add core dump saving to flash feature
Complimentary changes:
1) Partition table definitions files with core dump partition
2) Special sub-type for core dump partition
3) Special version of spi_flash_xxx
4) espcoredump.py is script to get core dump from flash and print useful info
5) FreeRTOS API was extended to get tasks snapshots
2017-01-11 20:51:28 +03:00
Jeroen Domburg 881157e1ed Add documentation to panic handler functions, move watchpoint stuff from tasks.c to port.c, account for non-32-bytes-aligned stacks when setting watchpoint, add debug reason explanation to panic handler 2017-01-10 13:05:19 +08:00
Jeroen Domburg ca57a86f20 Add option to automatically set a watchpoint at the end of the swapped-in task 2017-01-09 16:42:45 +08:00
Liu Zhi Fu d049fd3929 freertos: rework code based on review 2016-12-27 12:11:07 +08:00
Liu Zhi Fu d2e58193d2 add more protection for per-core data 2016-12-26 19:04:41 +08:00
Liu Zhi Fu 3a2fbda35c freertos: minor change according to review comments 2016-12-22 10:51:40 +08:00
Liu Zhi Fu 2cffaf9cc8 freertos: fix dual core issue
This commit fixes:
1. xTaskGetCurrentTaskHandle may return wrong TCB when current task switch to a different core
2. Idle task may have problem when it terminate the task in both core
2016-12-22 10:17:39 +08:00
Angus Gratton 180f4d0929 FreeRTOS: Use C11 _Static_assert to verify static "dummy" structs at compile time
Includes a tweak to make Static_task_t equal size to TCB_t when using
MPU_WRAPPERS . Matches tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE macro
in tasks.c. This isn't actually a bug (if static task allocation is off,
there is no use for Static_task_t), but it allows us to make consistent
compile-time checks that Static_task_t == TCB_t.
2016-11-23 10:22:19 +11:00
Angus Gratton 60f29236f6 Build system: Raise warning level
Default esp-idf builds now show -Wextra warnings (except for a few:
signed/unsigned comparison, unused parameters, old-style C declarations.)

CI building of examples runs with that level raised to -Werror, to catch
those changes going into the main repo.
2016-11-16 15:57:34 +11:00
Jeroen Domburg 57009aaa7f Add a more scalable mechanism for the FreeRTOS tick- and idle hooks; idle handler now uses WAITI to reduce power 2016-11-11 19:20:54 +08:00
Jeroen Domburg ffeffcd315 Merge branch 'feature/crosscore_int' into 'master'
Add cross-core int to accelerate task being awoken from another CPU.

This adds a per-CPU interrupt that can be used to poke the CPU to go do something. In this case all that is implemented is a request to yield the current task, used in case a CPU unblocks a task that runs on another CPU. This gets rid of the limitation that inter-CPU communication using queues, muxes etc can take up to a FreeRTOS tick to happen.

Specs!
Sending an in in a queue of length 1 (essentially a semaphore) as quickly as possible (just a small delay in the sender, to make sure the receiver task gets swapped out) for 10 seconds. Number indicates the amount of ints transferred

Old code:

CPU0->CPU0: 42986

CPU0->CPU1,: 2999

New code:

CPU0->CPU0: 42868

CPU0->CPU1: 62073

See merge request !155
2016-10-31 11:04:28 +08:00
Jeroen Domburg 3cd86d6bce Also call tick hook on app cpu when scheduler is suspended 2016-10-28 14:37:36 +08:00
Ivan Grokhotkov a038a2b533 freertos: fix calling first task hook 2016-10-28 13:41:07 +08:00
Ivan Grokhotkov 6f1d3ce4a7 vfs: code review fixes
- fix typo in readme
- remove unneeded extern declaration
- fix header guard macro
- tabs->spaces in syscalls.c
- spaces->tabs in tasks.c
2016-10-27 17:25:38 +08:00
Ivan Grokhotkov 0c130ecf19 vfs: code review fixes
- fix typo in readme
- remove unneeded extern declaration
- fix header guard macro
- tabs->spaces in syscalls.c (+1 squashed commit)
- fix minor typos
2016-10-27 17:21:17 +08:00
Ivan Grokhotkov 38c6256db9 Merge branch 'feature/wdts' into 'master'
Feature/wdts

This adds two watchdogs to  esp-idf:

- An interrupt watchdog. Kicks in if the FreeRTOS timer interupt on either the PRO_CPU or (when configured) the APP CPU isn't called for a configurable time. Panics, displaying which CPU caused the problem and the registers that may lead to the offending code.
- A task watchdog. A task has to feed it every once in a while. If not, it will print the name of the offending tasks, as well as the tasks currently running on both CPUs, and optionally panic.

Also adds a panic reason to the panic call, as well as fixes the panic code a bit.

See merge request !148
2016-10-27 17:09:35 +08:00
Jeroen Domburg b14faabfda Merge latest master in 2016-10-27 16:18:55 +08:00
Jeroen Domburg 3371083c16 Add checks for tasks woken up on other CPUs where needed, make xYieldPending and xPendingReadyList per-processor, add configurable ISR stack size to Kconfig, in general fix the entire wake-up-task-on-other-cpu-by-interrupt implementation 2016-10-27 16:07:47 +08:00
Ivan Grokhotkov 50bd28353d Merge branch 'master' into feature/freertos_static_buffers 2016-10-27 12:38:35 +08:00
Jeroen Domburg d3d9a8bc28 Most code written. Interrupts still do not fire yet. 2016-10-26 21:09:55 +08:00
Jeroen Domburg 6f96b23989 Merge in master updates 2016-10-26 11:04:42 +08:00
Jeroen Domburg 89f7752cdd Make CPU1 int wdt / idle task wdt configurable, panic now properly disables other cpu, tick handler now also is called on cpu1, task wdt prints currently running tasks. 2016-10-25 18:08:55 +08:00
Jeroen Domburg 75a11589a1 Disable brown-out WDT, fix thread WDT, add panic reason indication to _xt_panic() 2016-10-25 17:05:13 +08:00
Ivan Grokhotkov 8f82a83c2c Merge branch 'master' into feature/freertos_static_buffers 2016-10-17 16:02:09 +08:00
Jeroen Domburg 0aab006bb7 Add Trax-support to esp-idf 2016-10-17 12:18:17 +08:00
Ivan Grokhotkov 72712c00a7 freertos: forward task affinity argument to prvInitializeNewTask 2016-10-14 21:24:58 +08:00
Jeroen Domburg 89097d5f11 Add xCoreID arg to prvInitialiseNewTask code; initialize pvThreadLocalStoragePointersDelCallback array to NULL 2016-10-12 17:46:15 +08:00