Skip to content

Bootloader#7

Merged
dacarson merged 2 commits intomainfrom
Bootloader
Mar 6, 2026
Merged

Bootloader#7
dacarson merged 2 commits intomainfrom
Bootloader

Conversation

@dacarson
Copy link
Copy Markdown
Owner

@dacarson dacarson commented Mar 6, 2026

Disassemble the boatload for REFERENCE ONLY.
Discovered that the settings can be persisted over OTA updates.

dacarson added 2 commits March 6, 2026 09:20
Disassembled the boot loader so that it can be understood. It is for reference only and not for compilation.
The bootloader stores flash settings in stride-2 format (one struct byte
per 16-bit halfword), but the application was writing packed bytes (two
bytes per halfword). This caused the bootloader's save/restore during OTA
to corrupt all odd-indexed struct bytes, breaking the magic number check
and invalidating all multi-byte fields on every firmware update.

Fixes:
- Flash_ProgramBuffer: write one byte per halfword (stride-2)
- Flash_Load / Flash_Save verify: read back using stride-2 loop
- FLASH_OTA_FLAG_OFFSET: corrected from 0x64 to 0x32 (struct byte offset,
  not flash byte offset; flash addr = base + offset * 2 = 0x08003C64)
- reserved_ota_padding: shrunk from 56 to 6 bytes to match corrected offset
- FLASH_STRUCTURE_VERSION: bumped 2 → 3 to invalidate old packed-byte records

Behavior spec updated with full bootloader details and
stride-2 flash format description (Section 8.1, Section 14).
@dacarson dacarson merged commit 00c81ec into main Mar 6, 2026
@dacarson dacarson deleted the Bootloader branch March 6, 2026 17:29
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.

1 participant