-
Notifications
You must be signed in to change notification settings - Fork 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
add more locking for shared SPI devices #5595
Conversation
Looks good. I like to try that code with the T-Deck to see if it fixes the easily reproducible crash at second 35 after startup. |
It was not always easy to not lock twice. if we have a situation where the firmware freezes, i probably overlooked something. |
First try:
|
|
got worse :(
|
uh... pressed CTRL-C instead of CTRL-V to insert, so after copy again initSPI was there twice... now fixed it and it hangs here:
classical double-lock checkmate situation |
This sounds like it's caused by the initial NodeInfo transmit scheduled 30 seconds after booting. |
@mverch67 Just pushed a commit that might fix the shared SPI access issue when transmitting. Nevermind, also results in double-lock, but there should also be locking around |
spiBeginTransaction() and spiEndTransaction() are locked/released in our own Locking HAL Wrapper underneath radiolib. Top of RadioLibInterface.cpp |
Yes, indeed, and it looks like RadioLib is always calling |
aha. found it. rmDIr is locking itself, no need to wrap it at the start of loadFromDisk |
no change, still hangs at Init NodeDB |
Yes, that is the one I mean't. It hangs when touching the screen at the same time in 50% of the cases. While touch is I2C based the display redraw uses SPI. I already replaced the touch driver (not using lovyanGFX) a while ago and it got a lot better. The UI thread is completely locking SPI during execution of its entire loop, but still something corrupts the SPI bus so that radiolib reads garbage and asserts. |
Just added various missing |
Picked these changes to master, but still no luck. It hangs at |
In cases were there's only one lock in a method just use the C++ version of the locking because then C++ does the unlock automatically. |
The reason was that in Now it boots successfully (on master with a T-Beam), but please check my changes. |
Tested on a T114 and it seems happy. |
T-Deck still hangs:
|
It now works on T-Deck but does not solve the sporadic radioLib crash at second 34:
or later
|
The SPI transfers for RadioLib are within the lock, but it seems in I don’t have a T-Deck to test, but @mverch67 maybe you could try to add locking around this call also (think it would work by calling |
Great find! I think this is the spot that I was looking for all the time and which causes the trouble. Now I removed the spi locks from Not crashing anymore at second 34! |
Ah, yes, it should be locking around both the setting of the CS pin and the transfer. Great to hear it's fixed! |
When we update to the latest commit of RadioLib, it should solve the sporadic SPI errors when transmitting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, though for ContentHandler.cpp I'd rather use the C++ variant of the locking as it is much easier to use and to maintain (think of others adding features in this file).
* add more locking for shared SPI devices * call initSPI before the lock is used * remove old one * don't double lock * Add missing unlock * More missing unlocks * Add locks to SafeFile, remove from `readcb`, introduce some LockGuards * fix lock in setupSDCard() * pull radiolib trunk with SPI-CS fixes * change ContentHandler to Constructor type locks, where applicable --------- Co-authored-by: mverch67 <[email protected]> Co-authored-by: GUVWAF <[email protected]> Co-authored-by: Manuel <[email protected]>
* add more locking for shared SPI devices * call initSPI before the lock is used * remove old one * don't double lock * Add missing unlock * More missing unlocks * Add locks to SafeFile, remove from `readcb`, introduce some LockGuards * fix lock in setupSDCard() * pull radiolib trunk with SPI-CS fixes * change ContentHandler to Constructor type locks, where applicable --------- Co-authored-by: mverch67 <[email protected]> Co-authored-by: GUVWAF <[email protected]> Co-authored-by: Manuel <[email protected]>
* add more locking for shared SPI devices (#5595) * add more locking for shared SPI devices * call initSPI before the lock is used * remove old one * don't double lock * Add missing unlock * More missing unlocks * Add locks to SafeFile, remove from `readcb`, introduce some LockGuards * fix lock in setupSDCard() * pull radiolib trunk with SPI-CS fixes * change ContentHandler to Constructor type locks, where applicable --------- Co-authored-by: mverch67 <[email protected]> Co-authored-by: GUVWAF <[email protected]> Co-authored-by: Manuel <[email protected]> * mesh-tab: lower I2C touch frequency --------- Co-authored-by: Thomas Göttgens <[email protected]> Co-authored-by: mverch67 <[email protected]> Co-authored-by: GUVWAF <[email protected]> Co-authored-by: Manuel <[email protected]>
No description provided.