Commit graph

58 commits

Author SHA1 Message Date
Jeroen Domburg
95d0495506 Also use 32-bit stack lengths in prvTaskCheckFreeStackSpace and friends 2017-03-28 11:49:33 +08:00
Jeroen Domburg
9eb6e907e2 FreeRTOS: Make stack size in task create functions an uint32_t, so we can allocate more than 32K of stack if needed. 2017-03-28 11:49:33 +08: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
Ivan Grokhotkov
924fea7cc0 freertos: fix setting xCoreID for new task 2016-10-11 00:05:15 -06:00
Ivan Grokhotkov
8ee1a05914 Merge branch 'master' into feature/freertos_static_buffers
* master: (117 commits)
  build system: Add -fno-rtti when compiling C++ code
  FreeRTOS KConfig: Limit tick rate to 1000Hz
  bootloader: Fix accidental tabs introduced in !78
  build system: Print a WARNING if any submodule is out of date
  Fix stack overflow message format
  'make flash' targets: Print serial port when flashing
  lwip/esp32: support iperf
  Add data memory for RMT peripheral
  syscall write: Should return number of bytes written
  Also push relevant tags over
  esp32: add libsmartconfig.a to link libs
  esp32: not link wps
  esp32/lib: update wifi lib to a1e5f8b9
  esp32: remove esp_wps.h
  add smartconfig header files(merge this after updating libsmartconfig.a version v2.6.2)
  esp32/lib: update wifi lib to 3853d7ae
  Add Comments
  Modify spinlock error in periph_ctrl.c
  Define xcoreid offset, add warning in tcb struct wrt the need to also change that define when struct changes
  components/tcpip_adapter: add some comments
  ...

# Conflicts:
#	components/freertos/queue.c
#	components/freertos/tasks.c
2016-10-10 23:34:45 -06:00
Jeroen Domburg
df31bb8dfc Rename include, use spaces instead of tabs 2016-10-09 15:32:08 +08:00
Jeroen Domburg
0383bc8599 Merge branch 'workaround/pin_noaffinity_task_to_core_when_fpu_used' into 'master'
Workaround: Automatically pin no-cpu-affinity task to a core when FPU is used

FPU status at the moment does not migrate cleanly between cores, so tasks without affinity that happen to migrate across FPUs will run into problems. As a workaround, this modification will automatically pin the task to the current CPU when FPU activity is detected. If anything, it's better than getting all kinds of weird and wonderful FPU corruption issues...

See merge request !124
2016-09-29 11:16:41 +08:00
Jeroen Domburg
4daa768e3c Define xcoreid offset, add warning in tcb struct wrt the need to also change that define when struct changes 2016-09-29 11:07:18 +08:00
Jeroen Domburg
b3309a03a3 Automatically pin no-cpu-affinity task to a core when FPU is used 2016-09-28 17:02:44 +08:00
Jeroen Domburg
fc53bb6ed5 Add UNTESTED_FUNCTION() call to untested functions, make Kconfig option to enable that to map to assert() 2016-09-27 11:36:30 +08:00
Jeroen Domburg
b8bfa9fa35 Spinlocks already come initialized. Remove the code that would essentially re-initialize them at runtime 2016-09-23 17:46:16 +08:00
daniel
01d17dd5f9 Backport the static allocation feature from FreeRTOS V9.0.0
This feature allows to use static buffers (or from a pool of memory which is not
controlled by FreeRTOS).
In order to reduce the impact of the changes, the static feature has only been added
to the queus (and in consequence to the semaphores and the mutexes) and the tasks.
The Timer task is always dynamically allocated and also the idle task(s), which in the
case of the ESP-IDF is ok, since we always need to have dynamic allocation enabled.
2016-09-22 13:41:21 +08:00
Ivan Grokhotkov
e8ae38024d components/freertos: override per-task __cleanup handler to close stdin, stdout, stderr
Default _cleanup_r doesn't do that, which leaks these three file descriptors.
2016-09-19 19:28:36 +08:00
Jeroen Domburg
174a0e3f8b Fix bug where nesting vTaskEnterCritical calls would not re-enable interrupts after vTaskExitCritical sections. 2016-09-13 11:47:22 +08:00
Ivan Grokhotkov
1c6859573b freertos: protect calls to prvAddTaskToReadyList with xTaskQueueMutex 2016-09-09 17:59:37 +08:00
Jeroen Domburg
9664de6867 Add working portASSERT_IF_IN_ISR function, fix enter_critical thing even better. 2016-09-09 17:15:50 +08:00
Jeroen Domburg
128bb77c5a Fix prev code to not crash horribly when scheduler is not running yet 2016-09-09 17:15:49 +08:00