Skip to content

Sync next-10.1 into maintenance-11.x - #12266

Merged
github-actions[bot] merged 15 commits into
maintenance-11.xfrom
next-10.1
Nov 28, 2026
Merged

github-actions[bot] merged 15 commits into
maintenance-11.xfrom
next-10.1

Conversation

@github-actions

Copy link
Copy Markdown

Automatic sync of next-10.1 into maintenance-11.x could not be completed (merge conflict or push refused). Merge next-10.1 into maintenance-11.x locally, resolve conflicts, and push. Use a merge commit, not squash or rebase. Do not use GitHub's "Resolve conflicts" button.

MrScothh and others added 15 commits September 28, 2026 00:22
afatfs_getFreeBufferSpace() counted every unlocked sector that was
empty or in sync, but afatfs_allocateCacheSector() never evicts one
with a retain count: a contiguous file keeps its directory entry
retained for as long as it is open, and the blackbox log and the free
file are both contiguous. With a log open, two of the 8 sectors were
reported as space the blackbox could write into, and could not be.

Measured on a TBS Lucid H7 while the SD card held a write for 54 ms:
afatfs_fwrite() refused bytes while this function still reported
1024 bytes free.
An SD card can hold a write for tens of milliseconds (the standard
allows 250). The blackbox keeps writing into the other cache sectors
meanwhile, and once none is left it drops what it writes. With 8
sectors, and 3 of them never free while a log is open, the cache held
about 30 ms of a 1 kHz log.

Measured on a TBS Lucid H7 whose card holds a write for 54 ms every
768 KB once it runs out of prepared blocks, 120 s logs:

  sectors   1 kHz log (85 kB/s)     2 kHz log (170 kB/s)
            rows lost               rows lost
  8         379                     2178
  12        8                       1282
  16        0                       703
  24        0                       0
  32        0                       0 (also over a 20 minute log)

Now 32 sectors on H7 and 24 on F7, where RAM is plenty. On F4 with the
card on SPI the cache moves to CCM with 24 sectors: RAM is short there,
CCM mostly unused, and the CPU writes the card, so no DMA needs to
reach it. Elsewhere (F4 with SDIO, AT32) it stays at 8. A target can
set AFATFS_NUM_CACHE_SECTORS itself. Targets without an SD card do not
link the cache.

Walking the larger cache costs afatfs_poll() about 8 ns per sector on
the H7, in the scheduler's idle loop.
… full

While the SD card holds a write, afatfs keeps taking the log's bytes
into its cache, and once the cache is full afatfs_fwrite() drops what
does not fit, usually halfway through a frame. The decoder then misreads
frames until the next I frame.

Pause the log instead, as the BLACKBOX mode does: when what the log file
can still take (the free cache sectors and the rest of the sector being
written) is less than the most one iteration has written plus 64 bytes,
and never less than 256 bytes, skip iterations until it can take twice
that, and resume on an I frame with a LOGGING_RESUME event. The
iterations skipped are the ones that would have been lost anyway, but
the log no longer has corrupt frames in it. sd_info reports the pauses,
the iterations not logged and the largest iteration.

Measured on a TBS Lucid H7 with its 8 sector cache, three 120 s logs
each, rows missing per card stall and corrupt frames per log:

                       1 kHz log          2 kHz log
  without the pause    32.3, 4.7 corrupt  97.2, 15.7 corrupt
  with the pause       34.0, none         93.1, none
… switch, counts every skipped iteration and lends the card to terrain
…ume iteration is not counted

On the bench, sd_info counted one iteration too many for every pause the card
ended: the iteration that resumes is logged. When the switch takes over a pause
for the card and comes back on while the card is still behind, the resume wrote
its I frame into what is left below the threshold, 80 to 255 bytes: enough in
8 runs, not after a large iteration. Now it waits, and those iterations count
as lost to the card.
The getters only copied them for the CLI. Same size on F405, F722, KAKUTEF7 and H743 (LTO inlined them).
afatfs: count only the cache sectors that can take data, and size the cache per MCU family
blackbox: pause instead of dropping frames while the SD card is busy
@github-actions
github-actions Bot merged commit 1372652 into maintenance-11.x Nov 28, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown
Author

RAM / Flash usage vs. base commit 01a7aa3 — commit 1372652

Using the nearest available size baseline: this build contains base commit beffa67, which has no stored baseline yet, so the deltas also include what was merged to the base since 01a7aa3.

Target Flash Δ RAM Δ
MATEKF405 ⚠️ +2632 B (+0.36%) CCM: +12836 B (+39.42%)
RAM: -2148 B (-2.06%)
MATEKF722 ⚠️ -7424 B (-1.54%) ITCM_RAM: -928 B (-7.40%)
RAM: +8528 B (+9.83%)
TCM: +512 B (+2.02%)
MATEKF765 ⚠️ +4000 B (+0.53%) DTCM_RAM: +512 B (+1.79%)
SRAM1: +8576 B (+6.84%)
MATEKH743 ⚠️ +10324 B (+1.29%) D2_RAM: +256 B (+7.84%)
DTCM_RAM: +512 B (+3.95%)
ITCM_RAM: -920 B (-5.61%)
RAM: +14780 B (+10.38%)

See RAM/flash optimization guide for techniques to reduce usage.

@github-actions

Copy link
Copy Markdown
Author

Test firmware build ready — commit 1372652

Download firmware for PR #12266

252 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

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