Skip to content

Block not only uart interrupts #6587

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

saloid
Copy link
Contributor

@saloid saloid commented Oct 2, 2019

Fixes #6564

saloid added 4 commits October 2, 2019 22:24
Replaced by all interrupts blocking/unblocking
Replaced by all interrupts blocking/unblocking
Copy link
Collaborator

@devyte devyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plesde don't use the ets_intr_lock/unlock functions or macros directly, their usage is flawed and can cause stability issues.
Instead, use the InterruptLock object for scoped and correct protection, including possible nesting.

@saloid
Copy link
Contributor Author

saloid commented Oct 3, 2019

I should use it in this way?:

InterruptLock *lock=new InterruptLock;

// time critical section

delete lock;

@d-a-v
Copy link
Collaborator

d-a-v commented Oct 3, 2019

Easier than that:

// block to protect
{ 
    esp8266::InterruptLock lockAllInterruptsInThisScope;

    // code to protect
    ....
}
// no more protection here

check this example

@saloid
Copy link
Contributor Author

saloid commented Oct 3, 2019

In some places interrupts unlocks before scope ends. I think in this places better to use delete.

@d-a-v
Copy link
Collaborator

d-a-v commented Oct 3, 2019

new and delete are slow, increase heap fragmentation and useless in this case.
what places are you thinking of ?

@saloid
Copy link
Contributor Author

saloid commented Oct 3, 2019

I have tested more:
with ETS_INTR_LOCK, InterruptLock or even with AutoInterruptLock with different (tried all 15) levels i still getting exception 0 inside WiFi.begin while requesting SPI status (and no exception if no SPI transfer happens at this time). But if I use ETS_SPI_INTR_DISABLE - all works fine.
Maybe in this case (to cover another possible interrupts) I need to write similar class to InterruptLock, but instead interrupt level store bit mask (ets_isr_mask)?

@devyte
Copy link
Collaborator

devyte commented Oct 3, 2019

@saloid said:

In some places interrupts unlocks before scope ends

Please don't work on this over core v2.5.2. There are recent fixes related to lock/unlock that were merged recently and aren't released. What you said sounds like that.
Instead, please make absolutely sure you're testing and working on latest git.

@devyte devyte self-assigned this Oct 29, 2019
@saloid
Copy link
Contributor Author

saloid commented Oct 30, 2019

Still getting same exceptions with the latest git version.

Instead, please make absolutely sure you're testing and working on latest git.

@earlephilhower earlephilhower added the merge-conflict PR has a merge conflict that needs manual correction label Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-conflict PR has a merge conflict that needs manual correction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception (0) in SoftAP when SPIslave used
4 participants