-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Lp_ticker problem #11373
Comments
It would be good to post here debug failure logs with the description what has happened. |
This is the data collected from
In row [0] at tick 44744 next interrupt is set to tick 45062 ✅ The timestamp got outdated while waiting for |
cc @ARMmbed/team-st-mcd |
hi - the description is clear and I acknowledge that the problem is probably there. |
@LMESTM I confirm. I'll test my solution on other targets and after that I will rise a PR |
The problem is when we have many tickers set to close values. In the test scenario, we have 16 tickers which are set in the loop to fire at time NOW + 100ms. The common ticker layer operates on us and low-level driver on lp ticker ticks (lp ticker operates at 32 kHz). To simplify the problem I will focus on lp ticker ticks.
Let's assume that 100 ticks have elapsed and Ticker 1 interrupt fired. The ticker common layer interrupt handler will go through the list and serve all expired events from the list. This means that the first two events are served and the next interrupt is scheduled to tick 101 (note that at this moment current tick is 100). |
Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-1690 |
Description
DISCO_L475VG_IOT01A failed mbed_drivers-lp_ticker on nightly CI so I have looked into its lp_ticker implementation.
mbed-os/targets/TARGET_STM/lp_ticker.c
Lines 204 to 319 in 8ef742a
It is not protected for the situation where
lp_cmpok
is set to false, so thelp_delayed_prog
is set and thetimestamp
saved inlp_delayed_counter
will be sent tolp_ticker_set_interrupt
function viaLPTIM1_IRQHandler
. Thistimestamp
could get out of date while waiting for CMPOK flag. (I mean the value oftimestamp
would be less than a value got bylp_ticker_read()
) In that situationlp_ticker_set_interrupt
function would see this timestamp as an event that has to be handled after turning the clock counter and will set next interrupt to 0xFFFF rather than handling the event right then, or setting an interrupt for afterLP_TIMER_SAFE_GUARD
time. This could lead to some critical errors.This implementation is also vulnerable to timestamps close to ticker roll over.
To reproduce I've changed the code of test_multi_ticker to this:
and changed
MULTI_TICKER_TIME_MS
to 10 to reduce testing time. It should fail like 1 in 1000 times.I'll probably raise a PR with a proposition of fix soon.
We should consider creating something like "golden stress tests" for crusial low level peripherals which would be run on targets from golden list over night or even manualy after changing implementation.
@maciejbocianski @mprse @fkjagodzinski @jamesbeyond @LMESTM
Issue request type
The text was updated successfully, but these errors were encountered: