Skip to content

fix(flash): split writes that cross a flash page - #87

Merged
jamesarich merged 1 commit into
masterfrom
fix/flash-write-page-loop
Oct 26, 2026
Merged

jamesarich merged 1 commit into
masterfrom
fix/flash-write-page-loop

Conversation

@jamesarich

@jamesarich jamesarich commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Checklist

  • PR title specifically describes the change
  • tools/build_all.py (or CI's board matrix) passes

Description of Change

flash_nrf5x_write copied a write into its 4 KB page buffer without checking the page end, so a write crossing a page boundary ran past _fl_buf and its tail never reached flash. It now loops page by page, as Adafruit did in ca46deb. Hardening only: the UF2 path is the only caller and is_uf2_block() accepts just 256 B blocks at 256 B-aligned addresses, which never cross a page.

Tested on the RAK4631 (S140 6.1.1): misaligned blocks are dropped by is_uf2_block() on master and on this branch alike, and aligned app plus 64 KB pattern writes read back with 0 mismatches 3 of 3 times, app booting. A host harness built from the real flash_nrf5x.c writing 64 KB at a 128 B offset shows master losing the 128 B after each of 16 page boundaries (2040-2042 B wrong, overflow abort under fortify) and this branch 0 wrong on 3 seeds.

Summary by CodeRabbit

  • Bug Fixes
    • Flash writes that cross a 4 KB page boundary are now handled across the affected pages.
  • Documentation
    • Updated the OTAFIX 2.6 changelog to describe page-crossing write behavior and note that the current UF2 workflow uses aligned 256-byte writes that do not cross page boundaries.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d00289ec-3b1d-4fac-b96c-d524beaed970
Commits

Reviewing files that changed from the base of the PR and between d9a1fd5 and bae5725.

Files selected for processing: 2
  • changelog.md
  • src/flash_nrf5x.c

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

flash_nrf5x_write now splits writes across 4 KB page boundaries. The changelog describes this behavior and notes that current UF2 writes use 256-byte blocks at aligned addresses.

Changes: Flash write handling

Layer / File(s) Summary
Page-spanning write handling
src/flash_nrf5x.c, changelog.md
flash_nrf5x_write copies data in page-sized portions and flushes and loads the cache when the write moves to another page. The changelog documents this behavior and the current UF2 write pattern.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: hathach

Merge Risk: Minimal · up to bae57

The change safely handles cross-page writes without introducing a confirmed merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: splitting flash writes that cross a flash page boundary.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit taps the page with care,
Then carries bytes across from there.
The cache is flushed, the next page read,
Each block arrives where writes must lead.
The changelog marks the pathway clear.

Comment @coderabbitai help to get the list of available commands.

@jamesarich
jamesarich added this pull request to the merge queue Oct 26, 2026
Merged via the queue into master with commit 42a4d66 Oct 26, 2026
23 checks passed
@jamesarich
jamesarich deleted the fix/flash-write-page-loop branch October 26, 2026 13:07
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