Skip to content

fix(trainer): potential crash when SBUS trainer is used - #7696

Open
3djc wants to merge 1 commit into
mainfrom
3djc/fix-serial-trainer
Open

fix(trainer): potential crash when SBUS trainer is used#7696
3djc wants to merge 1 commit into
mainfrom
3djc/fix-serial-trainer

Conversation

@3djc

@3djc 3djc commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

The SBUS trainer receive context is a single pair of globals in sbus.cpp, shared between the aux serial port and the external module trainer, but trainer_stop_module_sbus() never released it. modulePortDeInit() zeroes the underlying serial state, so the context was left dangling: the next IDLE IRQ on the aux port dereferenced a null sp, read a garbage USART pointer and faulted, ending in a watchdog reset (emergency mode).

This fixes it

Fixes #7644

…rainer

The SBUS trainer receive context is a single pair of globals in sbus.cpp,
shared between the aux serial port and the external module trainer, but
trainer_stop_module_sbus() never released it. modulePortDeInit() zeroes the
underlying serial state, so the context was left dangling: the next IDLE IRQ
on the aux port dereferenced a null sp, read a garbage USART pointer and
faulted, ending in a watchdog reset (emergency mode).

Reaching it only takes scrolling the trainer mode field to Master/Serial,
which passes through Master/SBUS module on the way.

Release the context when the module trainer stops, claim it back for the aux
port when entering Master/Serial, and reject a stale context in the STM32
serial driver entry points and IRQ handler.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CGM5RJHayqfqviwX5o7oKQ
@3djc 3djc added backport/2.12 To be backported to a 2.12 release also. bug/regression ↩️ A new version of EdgeTX broke something labels Aug 23, 2026
@pfeerick

Copy link
Copy Markdown
Member

Reaching it only takes scrolling the trainer mode field to Master/Serial, which passes through Master/SBUS module on the way.

Nice 🥳 ... I think this is something we have been playing wack-a-mole with in the past and may have been on on raphael's mile long todo list to fix but never happened

@wimalopaan

Copy link
Copy Markdown
Contributor

Very cool! Great job ;-)

Wasn't there also a problem with not setting up pull-up/pull-down properly?

@3djc

3djc commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

No, I checked all our radio and serial, they are handled the same way. It is very likely just the not so easy to identify process to trigger that was in fault, not the antenna wire

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.12 To be backported to a 2.12 release also. bug/regression ↩️ A new version of EdgeTX broke something

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RadioMaster Boxer crashes when selecting Trainer mode Master/Serial with an SBUS signal connected to AUX1

3 participants