mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-01 10:06:49 -04:00
Workaround for Capture startup hang (#1285)
* Attempt to fix Capture startup hang * Pump baseband_queue on M4 startup * Synchronization experiment * Moved SpectrumCapture member, better hang detection for M0 * Prevent execute from working on members until class has been initialized. * Formatting * Remove workaround. * Rebase on next
This commit is contained in:
parent
3b5890d0aa
commit
47e95c0c47
14 changed files with 102 additions and 67 deletions
|
@ -31,6 +31,16 @@
|
|||
|
||||
#include "core_control.hpp"
|
||||
|
||||
/* Set true to enable additional checks to ensure
|
||||
* M4 and M0 are synchronized before passing messages. */
|
||||
static constexpr bool enforce_core_sync = true;
|
||||
|
||||
/* Set true to enable check for baseband messages getting stuck.
|
||||
* This implies the baseband thread is not dequeuing and has probably stalled.
|
||||
* NB: This check adds a small amout of overhead to the message sending code
|
||||
* and may impact application perf if it is sending a lot of messages. */
|
||||
static constexpr bool check_for_message_hang = true;
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
namespace baseband {
|
||||
|
@ -40,8 +50,18 @@ static void send_message(const Message* const message) {
|
|||
// another message is present before setting new message.
|
||||
shared_memory.baseband_message = message;
|
||||
creg::m0apptxevent::assert_event();
|
||||
while (shared_memory.baseband_message)
|
||||
;
|
||||
|
||||
if constexpr (check_for_message_hang) {
|
||||
auto count = UINT32_MAX;
|
||||
while (shared_memory.baseband_message && --count)
|
||||
/* spin */;
|
||||
|
||||
if (count == 0)
|
||||
chDbgPanic("Baseband Send Fail");
|
||||
} else {
|
||||
while (shared_memory.baseband_message)
|
||||
/* spin */;
|
||||
}
|
||||
}
|
||||
|
||||
void AMConfig::apply() const {
|
||||
|
@ -276,17 +296,28 @@ void set_spectrum_painter_config(const uint16_t width, const uint16_t height, bo
|
|||
|
||||
static bool baseband_image_running = false;
|
||||
|
||||
void run_image(const portapack::spi_flash::image_tag_t image_tag) {
|
||||
void run_image(const spi_flash::image_tag_t image_tag) {
|
||||
if (baseband_image_running) {
|
||||
chDbgPanic("BBRunning");
|
||||
}
|
||||
|
||||
creg::m4txevent::clear();
|
||||
shared_memory.clear_baseband_ready();
|
||||
|
||||
m4_init(image_tag, portapack::memory::map::m4_code, false);
|
||||
m4_init(image_tag, memory::map::m4_code, false);
|
||||
baseband_image_running = true;
|
||||
|
||||
creg::m4txevent::enable();
|
||||
|
||||
if constexpr (enforce_core_sync) {
|
||||
// Wait up to 3 seconds for baseband to start handling events.
|
||||
auto count = 3'000u;
|
||||
while (!shared_memory.baseband_ready && --count)
|
||||
chThdSleepMilliseconds(1);
|
||||
|
||||
if (count == 0)
|
||||
chDbgPanic("Baseband Sync Fail");
|
||||
}
|
||||
}
|
||||
|
||||
void shutdown() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue