fix: prevent endless loop with SBUS trainer on model change (#2515)

* fix: prevent generic module de-init if protocol is NONE

Fixes #1898

De-initialising the external module while SBUS trainer is used on external module RX leads to the following sequence:
- `extmoduleStop()` is called, thus shutting down the timer DMA
- on certain targets, the timer DMA stream is the same as the external module RX DMA stream
- when this DMA stream is used by the SBUS trainer input, this leads to DMAFifo to return random bytes continuously
- thus driving `processSbusInput()` into an endless loop, which is run in the mixer task
- as the mixer task has the highest priority, it runs forever
- after some time the watchdog timer expires, and causes a reboot

* DMAFifo: check if the stream is enabled

This provides some hardening to avoid the conditions described in previous commit.
This commit is contained in:
Raphael Coeffic
2022-10-12 12:45:10 +10:00
committed by GitHub
parent 0d5ef0bf24
commit 655965d7a6
2 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ class DMAFifo
#if defined(SIMU)
return true;
#endif
return (ridx == N - stream->NDTR);
return !(stream->CR & DMA_SxCR_EN) || (ridx == N - stream->NDTR);
}
bool pop(uint8_t & element)