-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow task pin to core, helper for spi_flash_* operations in task without set core affinity #258
Allow task pin to core, helper for spi_flash_* operations in task without set core affinity #258
Conversation
…fic processor core
spi_flash routines suspend the scheduler for the duration of the flash operation, so they can be used in non-pinned tasks. |
Sorry, I just realized I did not add the docs to this component. Please comment if that is anywhere close to esp-idf team interest, and I'll be happy to update the submission. |
Hi igrr, This is my code that uses flash (esp-idf-compatibile vfs over spi_flash_* functions) - https://github.com/nathanjel/ffs If I disable the commited module, which basically empties the macros, i will get my project to do this boo-boo (just tested)
|
I have a fix for the underlying issue, this fix doesn't require pinning the task during flash operations. It will land in master branch once code review is finished. |
Could You share the draft? I'm tight on timelines. |
Thank You very much. This helps. It seems I can drop my pull request now. |
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 #258
fixes for issues observed when using spi_flash This MR fixes three unrelated issues: - Race condition in spi_flash_enable_interrupts_caches_and_other_cpu when operations on unpinned tasks are performed. The issue is reported in #258 - esp_intr_noniram_disable doesn’t disable interrupts when compiled in release mode. This issue manifested itself with an illegal instruction exception when task WDT ISR was called at the time when flash was disabled. Fixes #263. - Tick hooks on CPU1 were not called if CPU0 scheduler was disabled for significant amount of time (which could happen when doing flash erase). The issue manifested itself as “INT WDT timeout on core 1” error. Fixes #219. See merge request !441
As I was experimenting with esp-idf in mutlicore mode, I have noticed that certain issues are more/less likely to occur when the task affinity is being set to a specific core, rather to be allowing task run on any core. As I did not want my application tasks to be permanently tied to specific core, due to huge workload on the system, I have created this small component that allows to pin a running task to specific core, and macros to enter/exit a block during which task is guaranteed to be pinned to specific core.
This adds a menuconfig option to enable/disable these functions.
This was a must to be able to run the spi_flash functions frequently in a task with no core affinity, as these functions are likely to fail otherwise (they have a check that aborts if they started and stopped on different cores). I got such issues prior to implementing this.
Example: