Skip to content

Conversation

@peterdmr
Copy link
Contributor

Summary

Fixes: Application update failure when binary contains Start-Of-Frame byte (0xA1)

Problem Description

The SUP frame parser (device side only) incorrectly resets the data reception state machine upon encountering any 0xA1 byte, even when it was part of the actual application data rather than an actual frame boundary.

Solution

Wait for SOF byte when parser is in the SUP_STATE_WAIT_SOF state only.

Notes

This fix addresses the immediate issue but removes the ability to reset broken frame transmissions using SOF bytes. In my opinion, frame reset/recovery should be handled through alternative mechanisms.

@m3y54m
Copy link
Owner

m3y54m commented Nov 11, 2025

@peterdmr Good catch. Thanks for reporting this bug.

As I am currently unable to test the fix myself, could you please confirm that your fix is tested and works correctly before I merge it?

@peterdmr
Copy link
Contributor Author

@m3y54m The fix has been tested and works correctly.

Due to availability, testing was performed on an ATmega328PB, which is the direct successor and software-compatible with the ATmega328P.

The following minor adaptations were required for the test environment:

  • Changed the target MCU from atmega328p to atmega328pb in CMakeLists.txt.

  • Updated the USART interrupt vector name from USART_RX_vect to USART0_RX_vect in the source files.

These changes are specific to the toolchain and register naming of the ATmega328PB and do not affect the core protocol logic of the fix.

@m3y54m m3y54m merged commit 480c534 into m3y54m:master Nov 12, 2025
2 checks passed
@peterdmr peterdmr deleted the wait_sof_fix branch November 14, 2025 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants