Commit graph

17 commits

Author SHA1 Message Date
Ivan Grokhotkov f9f2937694 spi_flash: raise priority of the task performing spi_flash operation
The fix is for the situation when cache disabling mechanism causes
a deadlock with user tasks. Situation is as follows:

1. spi_flash operation is started from low-priority task on CPU0
2. It uses IPC to wake up high-priority IPC1 task on CPU1, preventing
   all other tasks on CPU1 from running. This is needed to safely
   disable the cache.
3. While the task which started spi_flash operation is waiting for IPC1
   task to acknowledge that CPU1 is not using cache anymore, it is
   preempted by a higher priority application task ("app0").
4. Task app0 busy-waits for some operation on CPU1 to complete. But
   since application tasks are blocked out by IPC1 task, this never
   happens. Since app0 is busy-waiting, the task doing spi flash
   operation never runs.

The more or less logical soltion to the problem would be to also do
cache disabling on CPU0 and the SPI flash operation itself from IPC0
task. However IPC0 task stack would need to be increased to allow doing
SPI flash operation (and IPC1 stack as well). This would waste some
memory. An alternative approach adopted in this fix is to call FreeRTOS
functions to temporary increase the priority of SPI flash operation task
to the same level as the IPC task.

Fixes https://github.com/espressif/arduino-esp32/issues/740
Fixes https://github.com/espressif/esp-idf/issues/1157
2018-07-01 20:44:42 +08:00
Angus Gratton 7a924bd85a spi_flash: Expose an accessor the current SPI flash guard functions
Change places which uses g_flash_guard_default_ops to use this. Probably exact same data, but a bit
cleaner.
2017-11-20 15:54:31 +11:00
Angus Gratton e72e5a9706 spi_flash: Make spi_flash op_lock/op_unlock recursive
Allows chaining of multiple flash operations as an atomic operation.
2017-11-20 15:54:31 +11:00
Ivan Grokhotkov ee99bdfbad spi_flash_cache_enabled: report correct result in single core mode 2017-10-19 21:35:21 +08:00
Jeroen Domburg b24d2c4cf3 Make sure cache is disabled/enabled when *both* CPUs are running inside the iram guard code 2017-09-06 16:34:36 +08:00
Angus Gratton 99fe61716c startup: Add assertion checks around various initialisation sequences
These may fail if close to 192KB of static RAM is allocated (remaining early heap RAM is too small.)
2017-07-12 13:06:56 +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
Ivan Grokhotkov 92436021ab spi_flash: fix race condition in s_flash_op_complete access
Flash operation complete flag was cleared by the core initiating flash
operation. If the other core was running an ISR, then IPC task could
be late to enter the loop to check s_flash_op_complete by the time next
flash operation started. If the flag is cleared on the CPU waiting on
this flag, then the race condition can not happen.
2017-03-28 01:34:17 +08:00
Angus Gratton 3442d4d463 spi_flash: Add spi_flash_cache_enabled() test function 2017-03-03 15:33:23 +11:00
Ivan Grokhotkov e76c187efb spi_flash: protect esp_intr_noniram_{disable,enable} in 1-core config
MR !441 (7c155ab) has fixed issue with esp_intr_noniram_{disable,enable}
calls not being properly protected by spi_flash_op_{lock,unlock}.
Unit test was added, but the unit test environment tests only dual-core
config. Similar issue was present in the code path for the single-core
config, where esp_intr_noniram_{disable,enable} calls were unprotected.

This change fixes the protection issue and updates the unit test to
run properly in single core config as well.

The issue with running unit tests for single core config will be
addressed in a separate MR.
2017-02-21 21:57:53 +08:00
Ivan Grokhotkov 4676d159ad spi_flash: fix race condition when doing operations in unpinned tasks
spi_flash_enable_interrupts_caches_and_other_cpu function used to enable
non-IRAM interrupts after giving up flash operation lock, which would
cause problems if another task was waiting on the lock to start a flash
operation. In fact, non-IRAM interrupts should be re-enabled before the
task scheduler is resumed. Otherwise non-pinned task can be moved to the
other CPU due to preemption, causing esp_intr_noniram_enable to be
called on the other CPU, causing an abort to be triggered.

Fixes the issue reported in
https://github.com/espressif/esp-idf/pull/258
2017-01-18 15:07:27 +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 655fd2986a Add interrupt allocation scheme / interrupt sharing. Also modifies drivers and examples. Also allows interrupts
to be marked specifically as having a handler that's all in IRAM.
2016-12-08 12:39:33 +08:00
Ivan Grokhotkov aa0cd0ab47 spi_flash: add missing volatile qualifier for lock flags
http://esp32.com/viewtopic.php?f=14&t=419&p=1901
2016-11-08 20:17:08 +08:00
Ivan Grokhotkov 54ca573ce4 spi_flash: move cache operations into separate file 2016-10-27 17:57:29 +08:00
Renamed from components/spi_flash/esp_spi_flash.c (Browse further)