Skip to content

Terrain - fix lock if SD card is full and with deleted LOG folder - #12211

Open
error414 wants to merge 2 commits into
iNavFlight:next-10.1from
error414:error414/fix/terrain-lock
Open

error414 wants to merge 2 commits into
iNavFlight:next-10.1from
error414:error414/fix/terrain-lock

Conversation

@error414

@error414 error414 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

The PR fixes lock for terrain if SD is full and user deletes LOG folder. The PR is related to #12208.

Correct fix is to release lock if BB will stops for any reasson. Releasing lock must check if SD card is in iddle,

@qodo-code-review

Copy link
Copy Markdown
Contributor

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@error414
error414 changed the base branch from maintenance-10.x to next-10.1 November 8, 2026 08:03
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix SD access and add log wraparound, gyro IRQ reads, and battery telemetry

🐞 Bug fix ✨ Enhancement 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Prevent terrain SD-card lockups and reclaim old logs when Blackbox fills the card.
• Add interrupt-driven gyro reads with SPI arbitration and polling fallback on supported hardware.
• Decode Spektrum Smart Battery data and expose fresh readings through CLI and CRSF.
Diagram

graph TD
  Terrain["Terrain"] --> Blackbox["Blackbox"] --> FAT["Async FAT"]
  IMU["IMU interrupt"] --> SPI["SPI arbiter"] --> Gyro["Gyro task"]
  ESC["Smart ESC"] --> CRSF["CRSF telemetry"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Separate the three feature areas into PRs
  • ➕ Allows independent review and hardware validation of SD recovery, gyro interrupts, and battery telemetry.
  • ➕ Reduces the scope of regression diagnosis and rollback.
  • ➖ Requires coordinating shared build and target changes across PRs.
2. Stop logging when the card fills
  • ➕ Avoids filesystem reclamation and power-loss ordering concerns.
  • ➖ Does not deliver the intended continuous SD logging.

Recommendation: Split the independent gyro and Smart Battery features from the SD-card fix for review and validation. For continuous logging, retaining the existing contiguous allocator and reclaiming at log boundaries is more appropriate than reverting to stop-on-full behavior, but its deletion and recovery sequence warrants dedicated hardware and power-loss testing.

Files changed (66) +2169 / -131

Enhancement (24) +1862 / -27
blackbox_io.cReclaim log space at SD-card wraparound +171/-3

Reclaim log space at SD-card wraparound

• Scans log directory entries by cluster position, deletes a selected log, and relocates the contiguous freefile. Treats a full card as terminal only after reclamation gives up.

src/main/blackbox/blackbox_io.c

blackbox_io.hExpose the log-split condition +3/-0

Expose the log-split condition

• Declares the SD-card query used to distinguish recoverable fullness from a terminal full device.

src/main/blackbox/blackbox_io.h

accgyro.cQueue interrupt-delivered gyro samples +33/-0

Queue interrupt-delivered gyro samples

• Adds bounded sample push and pop operations so the gyro task can consume interrupt-read samples in order.

src/main/drivers/accgyro/accgyro.c

accgyro.hDefine gyro data-ready state and sample queue +54/-0

Define gyro data-ready state and sample queue

• Extends gyro devices with opt-in data-ready configuration, driver state, and a sample queue. Provides queue and mode helpers.

src/main/drivers/accgyro/accgyro.h

accgyro_data_ready.cDrive gyro sampling from the data-ready interrupt +225/-0

Drive gyro sampling from the data-ready interrupt

• Starts asynchronous SPI reads from EXTI, queues decoded samples, and pauses a full queue. Falls back to register reads after missing samples and suspends reads for flash writes.

src/main/drivers/accgyro/accgyro_data_ready.c

accgyro_data_ready.hDefine the data-ready driver contract +53/-0

Define the data-ready driver contract

• Specifies read layouts, parsers, fallback reads, and accessors for recent accelerometer and temperature data.

src/main/drivers/accgyro/accgyro_data_ready.h

accgyro_icm42605.cSupport ICM-426xx data-ready reads +54/-0

Support ICM-426xx data-ready reads

• Adds combined or gyro-only register parsing and uses recent interrupt-read accelerometer and temperature values when available.

src/main/drivers/accgyro/accgyro_icm42605.c

bus_busdev_spi.cArbitrate SPI selection and speed changes +5/-0

Arbitrate SPI selection and speed changes

• Acquires the bus around device selection and speed changes, then releases it after deselection or reconfiguration.

src/main/drivers/bus_busdev_spi.c

bus_spi.hDeclare asynchronous data-ready SPI operations +20/-0

Declare asynchronous data-ready SPI operations

• Adds initialization, request, bus-hold, and pending-request interfaces, with no-op holds when disabled.

src/main/drivers/bus_spi.h

bus_spi_data_ready.cCoordinate IRQ reads with main-loop SPI transfers +188/-0

Coordinate IRQ reads with main-loop SPI transfers

• Tracks active reads, deferred requests, and nested main-loop holds per bus. Times out stalled reads and disables asynchronous access after repeated failures.

src/main/drivers/bus_spi_data_ready.c

bus_spi_data_ready_dma.cAllocate H7 DMA streams for long SPI reads +192/-0

Allocate H7 DMA streams for long SPI reads

• Selects unowned streams while excluding declared UART streams, then configures, starts, stops, and handles DMA completion.

src/main/drivers/bus_spi_data_ready_dma.c

bus_spi_data_ready_impl.hDefine the SPI hardware-backend interface +61/-0

Define the SPI hardware-backend interface

• Declares hardware read lifecycle operations and H7 DMA helpers used by the shared arbiter.

src/main/drivers/bus_spi_data_ready_impl.h

bus_spi_hal_ll.cImplement H7 asynchronous SPI read completion +169/-0

Implement H7 asynchronous SPI read completion

• Uses SPI FIFO and end-of-transfer interrupts for short reads, or DMA for longer reads. Adds stop and interrupt-handling paths.

src/main/drivers/bus_spi_hal_ll.c

cli.cAdd the smartbattery CLI command +49/-0

Add the smartbattery CLI command

• Displays per-ESC battery cells, temperature, validity, and optional raw page data.

src/main/fc/cli.c

fc_init.cStart gyro IRQ reads after other initialization +3/-0

Start gyro IRQ reads after other initialization

• Defers data-ready startup until other peripherals have claimed their DMA resources.

src/main/fc/fc_init.c

asyncfatfs.cAdd filesystem operations for contiguous log recovery +121/-3

Add filesystem operations for contiguous log recovery

• Serializes create-file directory walks, avoids truncating an unallocated cluster chain, and adds directory-entry deletion, write-status, and freefile relocation operations.

src/main/io/asyncfatfs/asyncfatfs.c

asyncfatfs.hExpose SD reclamation filesystem APIs +41/-0

Expose SD reclamation filesystem APIs

• Declares entry deletion, pending-write and freefile inspection, and freefile relocation contracts.

src/main/io/asyncfatfs/asyncfatfs.h

motor_srxl2.cReceive Smart Battery pages from Avian ESCs +34/-6

Receive Smart Battery pages from Avian ESCs

• Changes the master identity to receive addressed battery replies, retains per-ESC battery state, and invalidates stale data after link interruptions.

src/main/io/motor_srxl2.c

motor_srxl2.hExpose per-ESC Smart Battery readings +5/-0

Expose per-ESC Smart Battery readings

• Includes battery types and declares decoded and raw battery accessors.

src/main/io/motor_srxl2.h

srxl2_smart_battery.cDecode and validate Smart Battery pages +155/-0

Decode and validate Smart Battery pages

• Tracks pages by battery source and decodes cell voltages and temperature. Requires fresh capacity metadata and invalidates readings when the link or pages become stale.

src/main/io/srxl2_smart_battery.c

srxl2_smart_battery.hDefine Smart Battery state and telemetry types +70/-0

Define Smart Battery state and telemetry types

• Defines page caches, source limits, freshness policy, decoded readings, and decoder interfaces.

src/main/io/srxl2_smart_battery.h

crsf.hIdentify CRSF Voltage Group frames +1/-0

Identify CRSF Voltage Group frames

• Adds the Voltage Group frame type used to transmit battery cell voltages.

src/main/rx/crsf.h

gyro.cInitialize and consume interrupt-read gyro samples +76/-15

Initialize and consume interrupt-read gyro samples

• Applies the data-ready setting, starts eligible sensors after initialization, and processes queued samples through calibration and the first low-pass filter.

src/main/sensors/gyro.c

crsf.cSchedule Smart Battery CRSF frames +79/-0

Schedule Smart Battery CRSF frames

• Publishes fresh pack temperature and complete packs of up to eight cells using native CRSF frames. Skips unavailable or incomplete readings.

src/main/telemetry/crsf.c

Bug fix (6) +130 / -57
blackbox.cSafely grant terrain access and split full-card logs +103/-57

Safely grant terrain access and split full-card logs

• Grants terrain SD access only in safe Blackbox states when async FAT is idle, including when Blackbox updates stop. Adds shutdown-and-reopen behavior when a full card needs another log.

src/main/blackbox/blackbox.c

config_eeprom.cSuspend gyro IRQ reads before EEPROM writes +5/-0

Suspend gyro IRQ reads before EEPROM writes

• Stops data-ready reads before the potentially blocking configuration write.

src/main/config/config_eeprom.c

adc_stm32f4xx.cRegister F4 ADC DMA ownership +7/-0

Register F4 ADC DMA ownership

• Marks the ADC DMA stream as owned so runtime stream selection cannot claim it.

src/main/drivers/adc_stm32f4xx.c

adc_stm32f7xx.cRegister F7 ADC DMA ownership +6/-0

Register F7 ADC DMA ownership

• Marks the ADC DMA stream as owned so runtime stream selection cannot claim it.

src/main/drivers/adc_stm32f7xx.c

adc_stm32h7xx.cRegister H7 ADC DMA ownership +6/-0

Register H7 ADC DMA ownership

• Marks the ADC DMA stream as owned so runtime stream selection cannot claim it.

src/main/drivers/adc_stm32h7xx.c

sdcard_spi.cProtect SD-card startup clocks from IRQ reads +3/-0

Protect SD-card startup clocks from IRQ reads

• Acquires the SPI bus while sending initialization clocks with chip select inactive.

src/main/drivers/sdcard/sdcard_spi.c

Documentation (3) +68 / -2
Blackbox.mdDocument onboard SD logging and wraparound +12/-0

Document onboard SD logging and wraparound

• Explains log placement, oldest-log eviction, split flights, unused space, and power-loss behavior.

docs/Blackbox.md

Settings.mdDocument the gyro data-ready setting +12/-0

Document the gyro data-ready setting

• Describes AUTO, ON, and OFF behavior and the supported IMU and interrupt-pin requirements.

docs/Settings.md

Spektrum Smart ESC.mdDocument Smart Battery telemetry +44/-2

Document Smart Battery telemetry

• Covers ESC compatibility, CLI and CRSF output, freshness rules, radio requirements, and bench observations.

docs/Spektrum Smart ESC.md

Other (33) +109 / -45
CMakeLists.txtInclude new SPI, gyro, and battery modules +6/-0

Include new SPI, gyro, and battery modules

• Adds the asynchronous SPI and gyro sources and the SRXL2 Smart Battery decoder to the main build.

src/main/CMakeLists.txt

nvic.hAssign a gyro data-ready interrupt priority +2/-0

Assign a gyro data-ready interrupt priority

• Defines a shared priority for data-ready signaling and read completion.

src/main/drivers/nvic.h

settings.yamlAdd gyro_data_ready configuration +9/-0

Add gyro_data_ready configuration

• Defines the AUTO, ON, and OFF setting and exposes it when SPI data-ready support is compiled.

src/main/fc/settings.yaml

gyro.hAdd gyro data-ready configuration and startup API +12/-0

Add gyro data-ready configuration and startup API

• Appends the configured mode to gyro settings and declares the deferred startup function.

src/main/sensors/gyro.h

target.cConnect both IMU interrupt pins +2/-2

Connect both IMU interrupt pins

• Passes the defined primary and secondary ICM interrupt pins into their SPI bus registrations.

src/main/target/BROTHERHOBBYH743/target.c

target.hDefine both ICM interrupt pins +2/-0

Define both ICM interrupt pins

• Adds the primary and secondary IMU EXTI pin definitions.

src/main/target/BROTHERHOBBYH743/target.h

target.cRegister the primary IMU interrupt pin +5/-5

Register the primary IMU interrupt pin

• Supplies the primary IRQ pin to candidate IMU bus registrations.

src/main/target/DAKEFPVH743/target.c

target.hDefine the primary IMU IRQ pin +1/-0

Define the primary IMU IRQ pin

• Names PC4 as the primary IMU interrupt pin.

src/main/target/DAKEFPVH743/target.h

target.cRegister both IMU interrupt pins +10/-10

Register both IMU interrupt pins

• Supplies primary and secondary IRQ pins to candidate IMU bus registrations.

src/main/target/DAKEFPVH743PRO/target.c

target.hDefine primary and secondary IMU IRQ pins +2/-0

Define primary and secondary IMU IRQ pins

• Names PC4 and PB2 as the two IMU interrupt pins.

src/main/target/DAKEFPVH743PRO/target.h

target.cConnect both ICM-42688 interrupt pins +2/-2

Connect both ICM-42688 interrupt pins

• Passes the two EXTI pin definitions into their IMU bus registrations.

src/main/target/FLYWOOH743PRO/target.c

target.hDefine both ICM-42688 EXTI pins +2/-0

Define both ICM-42688 EXTI pins

• Adds PB2 and PE15 as the two IMU interrupt pins.

src/main/target/FLYWOOH743PRO/target.h

target.cRegister both IMU interrupt pins +4/-4

Register both IMU interrupt pins

• Supplies IRQ pins to the MPU and ICM candidates at both IMU positions.

src/main/target/GEPRC_TAKER_H743/target.c

target.hDefine both IMU EXTI pins +2/-0

Define both IMU EXTI pins

• Adds PD0 and PD8 interrupt pin definitions.

src/main/target/GEPRC_TAKER_H743/target.h

target.cConnect both ICM-42688 interrupts +2/-2

Connect both ICM-42688 interrupts

• Registers EXTI pins for the primary and secondary ICM devices.

src/main/target/HAKRCH743/target.c

target.hDefine both ICM-42688 EXTI pins +2/-0

Define both ICM-42688 EXTI pins

• Adds PB2 and PC14 interrupt pin definitions.

src/main/target/HAKRCH743/target.h

target.hDefine the Blitz H7 Pro ICM interrupt pin +3/-0

Define the Blitz H7 Pro ICM interrupt pin

• Defines PB2 as the ICM EXTI pin for the H7 Pro variant.

src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h

target.hDefine the Kakute H7 ICM interrupt pin +1/-0

Define the Kakute H7 ICM interrupt pin

• Defines PE1 as the ICM EXTI pin.

src/main/target/KAKUTEH7/target.h

target.cRegister the Mamba ICM interrupt pin +1/-1

Register the Mamba ICM interrupt pin

• Passes the configured EXTI pin into the ICM bus registration.

src/main/target/MAMBAH743/target.c

target.hDefine variant-specific Mamba ICM IRQ pins +2/-0

Define variant-specific Mamba ICM IRQ pins

• Defines PC4 or PE15 for the relevant ICM hardware variant.

src/main/target/MAMBAH743/target.h

target.cRegister Matek IMU interrupt pins +3/-3

Register Matek IMU interrupt pins

• Supplies EXTI pins to the primary MPU or ICM candidate and the additional ICM device.

src/main/target/MATEKH743/target.c

target.hDefine Matek IMU interrupt pins +2/-0

Define Matek IMU interrupt pins

• Adds PB2 and PE15 EXTI pin definitions.

src/main/target/MATEKH743/target.h

target.hDefine the Sequre ICM interrupt pin +1/-0

Define the Sequre ICM interrupt pin

• Defines PD0 as the ICM EXTI pin for the applicable variant.

src/main/target/SEQUREH7/target.h

target.cRegister the Simplifly ICM interrupt pin +1/-1

Register the Simplifly ICM interrupt pin

• Passes the EXTI pin into the ICM SPI bus registration.

src/main/target/SIMPLIFLYH7/target.c

target.hDefine the Simplifly ICM interrupt pin +1/-0

Define the Simplifly ICM interrupt pin

• Defines PC3 as the ICM EXTI pin.

src/main/target/SIMPLIFLYH7/target.h

target.cConnect both Spedix gyro interrupts +2/-2

Connect both Spedix gyro interrupts

• Registers EXTI pins for the two ICM-42688 devices.

src/main/target/SPEDIXH743/target.c

target.hDefine both Spedix gyro EXTI pins +2/-0

Define both Spedix gyro EXTI pins

• Adds PD7 and PE4 interrupt pin definitions.

src/main/target/SPEDIXH743/target.h

target.cRegister both Lucid H7 gyro interrupts +6/-6

Register both Lucid H7 gyro interrupts

• Supplies EXTI pins to candidate devices at both gyro positions.

src/main/target/TBS_LUCID_H7/target.c

target.hDefine Lucid H7 gyro EXTI pins +2/-0

Define Lucid H7 gyro EXTI pins

• Adds PB2 and PE15 interrupt pin definitions.

src/main/target/TBS_LUCID_H7/target.h

target.cRegister both Lucid H7 Wing gyro interrupts +6/-6

Register both Lucid H7 Wing gyro interrupts

• Supplies EXTI pins to candidate devices at both gyro positions.

src/main/target/TBS_LUCID_H7_WING/target.c

target.hDefine Lucid H7 Wing gyro EXTI pins +2/-0

Define Lucid H7 Wing gyro EXTI pins

• Adds PB2 and PE15 interrupt pin definitions.

src/main/target/TBS_LUCID_H7_WING/target.h

common.hEnable SPI data-ready support on H7 +5/-0

Enable SPI data-ready support on H7

• Defines the feature for STM32H7 targets.

src/main/target/common.h

common_hardware.cPass optional ICM EXTI pins to common registrations +4/-1

Pass optional ICM EXTI pins to common registrations

• Uses a target-defined ICM interrupt pin when available and otherwise retains the no-pin fallback.

src/main/target/common_hardware.c

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Wraparound can overwrite non-log files on the card 🐞 Bug ≡ Correctness
Description
The scan in BLACKBOX_SDCARD_SCAN_FOR_OLDEST_LOG sets the reclaimed range to `[evicted log first
cluster, next LOG*.TXT first cluster), and afatfs_freeFileRelocate()` moves the freefile onto that
range without checking the FAT. Any other file whose clusters fall in that range is handed to the
next log by afatfs_appendSupercluster, which overwrites its data and rewrites its FAT chain: files
in the root or other directories, non-LOG files in logs (e.g. terrain .DAT files), or files a PC
wrote into clusters freed by deleting logs.
Code

src/main/blackbox/blackbox_io.c[R609-613]

+                if (nextBoundaryCluster != UINT32_MAX) {
+                    // Reclaim up to the next log's start: it is supercluster-aligned, so the next lap's boundary search matches again.
+                    // Size is in bytes.
+                    blackboxSDCard.oldestLogFileSize =
+                        (nextBoundaryCluster - blackboxSDCard.oldestLogFirstCluster) * afatfs_freeFileClusterSize();
Evidence
Only LOG*.TXT entries (live or deleted) are used as boundaries. The delete leaves the FAT alone.
Relocate only rewrites the freefile's directory metadata. The append takes the freefile's first
cluster without checking it and rewrites FAT entries for the whole supercluster. Example: LOG00001
at cluster 100, LOG00002 at 200, and a user file at 150–160. The freefile becomes 100..199, and the
next log overwrites the user file.

src/main/blackbox/blackbox_io.c[560-614]
src/main/io/asyncfatfs/asyncfatfs.c[2860-2876]
src/main/io/asyncfatfs/asyncfatfs.c[2935-2952]
src/main/io/asyncfatfs/asyncfatfs.c[1690-1745]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The wraparound reclaim range is bounded only by other LOG*.TXT entries in the current directory. Other files whose clusters lie inside the range are overwritten when the freefile is relocated there.
## Fix Focus Areas
- src/main/blackbox/blackbox_io.c[609-631]
- src/main/io/asyncfatfs/asyncfatfs.c[2935-2952]
## Recommended Fix
Before `afatfs_freeFileRelocate`, check that every cluster in `[firstCluster, firstCluster + size)` is either free or part of the evicted log's own contiguous chain. One way is to walk the FAT from the evicted log's first cluster and cap the size at the end of that chain (rounded down to a supercluster). Another is to scan the FAT entries in the range and stop at the first cluster that belongs to another chain. Do not extend the range past the evicted log's own allocation based only on the next LOG entry's start.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Split logs start without a keyframe or GPS home 🐞 Bug ≡ Correctness
Description
blackboxUpdate() sends a split log from SHUTTING_DOWN to BLACKBOX_STATE_PREPARE_LOG_FILE without
the iteration-timer, predictor-history, and GPS-history resets performed by blackboxStart(). When
blackboxDeviceNeedsNewLog() triggers a split between keyframes, the next file starts with P-frames
that depend on the previous file and lacks a GPS Home frame until home changes or the periodic
refresh, leaving main data undecodable until the next I-frame and GPS coordinates undecodable for
many seconds in addition to the documented 65 ms gap.
Code

src/main/blackbox/blackbox.c[R2507-2509]

+            if (blackboxSplitting) {
+                blackboxSetState(BLACKBOX_STATE_PREPARE_LOG_FILE);
+            } else
Evidence
blackboxStart() resets the iteration timers and gpsHistory at lines 1714–1733, but the split
transition at lines 2503–2513 bypasses it. blackboxLogIteration() writes an I-frame only when
blackboxPFrameIndex is zero; otherwise, its predicted frame reads prior states from
blackboxHistory. It writes a GPS Home frame only when GPS_home differs from gpsHistory or the
periodic condition is met. The RUNNING comment says indices are reset on entry, but that is not true
after a split.

src/main/blackbox/blackbox.c[1697-1745]
src/main/blackbox/blackbox.c[2300-2373]
src/main/blackbox/blackbox.c[2480-2514]
src/main/blackbox/blackbox.c[1686-1694]
src/main/blackbox/blackbox.c[2503-2513]
src/main/blackbox/blackbox.c[2300-2358]
src/main/blackbox/blackbox.c[1223-1235]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A wraparound split transitions directly to a new log file without resetting per-log iteration, predictor, and GPS state. The new file can begin with P-frames whose references are in the preceding file and omit the GPS Home frame.
## Fix Focus Areas
- src/main/blackbox/blackbox.c[2503-2513]
- src/main/blackbox/blackbox.c[1686-1694]
- src/main/blackbox/blackbox.c[1714-1733]
## Recommended Fix
Move the per-log reset work from `blackboxStart()` into a shared helper and call it both there and when `blackboxSplitting` transitions to `BLACKBOX_STATE_PREPARE_LOG_FILE`. Include `blackboxResetIterationTimers()`, clearing `gpsHistory`, and resetting the history ring pointers and `vbatReference` as `blackboxStart()` does. Verify that the split file starts with a self-contained I-frame and an immediate GPS Home frame and can be decoded on its own.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@error414

error414 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Qodo review: qodo review hits repository states before I changed branch PR base to next-10.1

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

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

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

Target Flash Δ RAM Δ
MATEKF405 ⚠️ +3840 B (+0.53%) CCM: -4 B (-0.01%)
RAM: +1660 B (+1.59%)
MATEKF722 +1256 B (+0.26%) ITCM_RAM: -928 B (-7.40%)
RAM: +56 B (+0.06%)
TCM: ±0 B (±0.00%)
MATEKF765 +1368 B (+0.18%) DTCM_RAM: ±0 B (±0.00%)
SRAM1: +64 B (+0.05%)
MATEKH743 ⚠️ +7140 B (+0.89%) D2_RAM: +256 B (+7.84%)
DTCM_RAM: ±0 B (±0.00%)
ITCM_RAM: -888 B (-5.41%)
RAM: +1940 B (+1.36%)

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

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Test firmware build ready — commit dacbe7e

Download firmware for PR #12211

251 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.

@MartinovEm

MartinovEm commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Tested the CI build b222eb5 on the bench, IFLIGHT_BLITZ_H7_WING with SDIO card, X-Plane HITL, the same breaker setup as in #12208, worn 32 KB FREESPAC.E, two terrain tiles, no logs folder. Terrain stayed healthy for the whole flight, 23 grants, 7 complete block reads, zero failures, and the debug log has zero pending waits, the request now gets granted inline. So this fixes the starved case on next-10.1 nicely. For completeness, maintenance-10.x does not have this rework, the starvation there is what #12208 covers.

PR #12211 CI build b222eb5, worn freefile, no logs on the card: terrain healthy all flight
listening on COM14 for MSP_DEBUGMSG (terrain log)... Ctrl+C to stop
[  472.3s] [   482.466] Simulator enabled
[  472.5s] [   482.609] TERRAIN SD LOCK ACQUIRED
[  472.5s] [   482.609] TERRAIN IDLE -> CHANGE_DIR
[  472.5s] [   482.629] TERRAIN CHANGE_DIR, ALREADY ROOT -> OPEN_FILE
[  472.5s] [   482.649] TERRAIN OPEN_FILE N42E023.TER -> OPEN_FILE_PENDING
[  472.5s] [   482.649] TERRAIN OPEN CALLBACK, FILE OK -> SEEK
[  472.5s] [   482.649] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  472.5s] [   482.669] TERRAIN SD LOCK ACQUIRED
[  472.5s] [   482.669] TERRAIN SEEK TO POSITION 107,43
[  472.5s] [   482.669] TERRAIN SEEK OK -> READ
[  472.5s] [   482.689] TERRAIN READING DATA 0/1151
[  472.5s] [   482.709] TERRAIN READING DATA 512/1151
[  472.5s] [   482.709] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  472.5s] [   482.729] TERRAIN SD LOCK ACQUIRED
[  472.5s] [   482.729] TERRAIN READING DATA 1024/1151
[  472.5s] [   482.729] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  472.5s] [   482.741] Font metadata version Y: 3 (1024 chars)
[  472.5s] [   482.749] TERRAIN SD LOCK ACQUIRED
[  472.5s] [   482.749] TERRAIN READING DATA 1151/1151
[  472.5s] [   482.749] TERRAIN READ FINISHED -> IDLE (file kept open)
[  472.5s] [   482.749] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  474.3s] [   484.467] Barometer calibration complete (53305)
[  474.3s] [   484.467] Gravity calibration complete (981)
[  488.8s] [   498.914] TERRAIN SD LOCK ACQUIRED
[  488.8s] [   498.914] TERRAIN IDLE, FILE ALREADY OPEN -> SEEK
[  488.8s] [   498.934] TERRAIN SEEK TO POSITION 107,42
[  488.8s] [   498.934] TERRAIN SEEK OK -> READ
[  488.8s] [   498.954] TERRAIN READING DATA 0/1151
[  488.8s] [   498.974] TERRAIN READING DATA 512/1151
[  488.8s] [   498.974] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  488.8s] [   498.994] TERRAIN SD LOCK ACQUIRED
[  488.8s] [   498.994] TERRAIN READING DATA 1024/1151
[  488.8s] [   498.994] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  488.8s] [   499.014] TERRAIN SD LOCK ACQUIRED
[  488.8s] [   499.014] TERRAIN READING DATA 1151/1151
[  488.8s] [   499.014] TERRAIN READ FINISHED -> IDLE (file kept open)
[  488.8s] [   499.014] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  510.4s] [   520.642] TERRAIN SD LOCK ACQUIRED
[  510.4s] [   520.642] TERRAIN IDLE, FILE ALREADY OPEN -> SEEK
[  510.4s] [   520.662] TERRAIN SEEK TO POSITION 107,41
[  510.4s] [   520.662] TERRAIN SEEK OK -> READ
[  510.4s] [   520.682] TERRAIN READING DATA 0/1151
[  510.6s] [   520.702] TERRAIN READING DATA 512/1151
[  510.6s] [   520.702] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  510.6s] [   520.722] TERRAIN SD LOCK ACQUIRED
[  510.6s] [   520.722] TERRAIN READING DATA 1024/1151
[  510.6s] [   520.722] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  510.6s] [   520.742] TERRAIN SD LOCK ACQUIRED
[  510.6s] [   520.742] TERRAIN READING DATA 1151/1151
[  510.6s] [   520.742] TERRAIN READ FINISHED -> IDLE (file kept open)
[  510.6s] [   520.742] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  528.7s] [   538.869] TERRAIN SD LOCK ACQUIRED
[  528.7s] [   538.869] TERRAIN IDLE, FILE ALREADY OPEN -> SEEK
[  528.7s] [   538.889] TERRAIN SEEK TO POSITION 107,40
[  528.7s] [   538.889] TERRAIN SEEK OK -> READ
[  528.7s] [   538.909] TERRAIN READING DATA 0/1151
[  528.7s] [   538.929] TERRAIN READING DATA 512/1151
[  528.7s] [   538.929] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  528.7s] [   538.949] TERRAIN SD LOCK ACQUIRED
[  528.7s] [   538.949] TERRAIN READING DATA 1024/1151
[  528.7s] [   538.949] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  528.7s] [   538.969] TERRAIN SD LOCK ACQUIRED
[  528.7s] [   538.969] TERRAIN READING DATA 1151/1151
[  528.7s] [   538.970] TERRAIN READ FINISHED -> IDLE (file kept open)
[  528.7s] [   538.970] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  547.0s] [   557.157] TERRAIN SD LOCK ACQUIRED
[  547.0s] [   557.157] TERRAIN IDLE, FILE ALREADY OPEN -> SEEK
[  547.0s] [   557.177] TERRAIN SEEK TO POSITION 107,39
[  547.0s] [   557.177] TERRAIN SEEK OK -> READ
[  547.0s] [   557.197] TERRAIN READING DATA 0/1151
[  547.0s] [   557.217] TERRAIN READING DATA 512/1151
[  547.0s] [   557.217] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  547.0s] [   557.237] TERRAIN SD LOCK ACQUIRED
[  547.0s] [   557.237] TERRAIN READING DATA 1024/1151
[  547.0s] [   557.237] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  547.0s] [   557.257] TERRAIN SD LOCK ACQUIRED
[  547.0s] [   557.257] TERRAIN READING DATA 1151/1151
[  547.0s] [   557.257] TERRAIN READ FINISHED -> IDLE (file kept open)
[  547.0s] [   557.257] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  565.3s] [   575.486] TERRAIN SD LOCK ACQUIRED
[  565.3s] [   575.486] TERRAIN IDLE, FILE ALREADY OPEN -> SEEK
[  565.3s] [   575.506] TERRAIN SEEK TO POSITION 107,38
[  565.3s] [   575.506] TERRAIN SEEK OK -> READ
[  565.3s] [   575.526] TERRAIN READING DATA 0/1151
[  565.3s] [   575.546] TERRAIN READING DATA 512/1151
[  565.3s] [   575.546] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  565.3s] [   575.566] TERRAIN SD LOCK ACQUIRED
[  565.3s] [   575.566] TERRAIN READING DATA 1024/1151
[  565.3s] [   575.566] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  565.3s] [   575.586] TERRAIN SD LOCK ACQUIRED
[  565.3s] [   575.586] TERRAIN READING DATA 1151/1151
[  565.3s] [   575.587] TERRAIN READ FINISHED -> IDLE (file kept open)
[  565.3s] [   575.587] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  625.3s] [   635.588] TERRAIN IDLE TIMEOUT -> CLOSE
[  625.3s] [   635.608] TERRAIN CLOSE -> CLOSE_PENDING
[  625.3s] [   635.608] TERRAIN CLOSE CALLBACK, FILE CLOSED
[  625.3s] [   635.608] TERRAIN RESET STATE -> IDLE
[  678.9s] [   689.189] TERRAIN SD LOCK ACQUIRED
[  678.9s] [   689.189] TERRAIN IDLE -> CHANGE_DIR
[  678.9s] [   689.209] TERRAIN CHANGE_DIR, CHANGING TO ROOT
[  678.9s] [   689.209] TERRAIN CHANGE_DIR OK -> OPEN_FILE
[  679.1s] [   689.229] TERRAIN OPEN_FILE N42E023.TER -> OPEN_FILE_PENDING
[  679.1s] [   689.230] TERRAIN OPEN CALLBACK, FILE OK -> SEEK
[  679.1s] [   689.230] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  679.1s] [   689.250] TERRAIN SD LOCK ACQUIRED
[  679.1s] [   689.250] TERRAIN SEEK TO POSITION 107,44
[  679.1s] [   689.250] TERRAIN SEEK OK -> READ
[  679.1s] [   689.270] TERRAIN READING DATA 0/1151
[  679.1s] [   689.290] TERRAIN READING DATA 512/1151
[  679.1s] [   689.290] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  679.1s] [   689.310] TERRAIN SD LOCK ACQUIRED
[  679.1s] [   689.310] TERRAIN READING DATA 1024/1151
[  679.1s] [   689.310] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  679.1s] [   689.330] TERRAIN SD LOCK ACQUIRED
[  679.1s] [   689.330] TERRAIN READING DATA 1151/1151
[  679.1s] [   689.330] TERRAIN READ FINISHED -> IDLE (file kept open)
[  679.1s] [   689.330] TERRAIN SD LOCK RELEASED (held=1 requested=0)
[  739.2s] [   749.348] TERRAIN IDLE TIMEOUT -> CLOSE
[  739.2s] [   749.368] TERRAIN CLOSE -> CLOSE_PENDING
[  739.2s] [   749.368] TERRAIN CLOSE CALLBACK, FILE CLOSED
[  739.2s] [   749.368] TERRAIN RESET STATE -> IDLE

@error414

error414 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

I have to adjust memory ussage. The change takes too much memory

@error414

error414 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

RAM / Flash usage vs. base commit 01a7aa3 — commit dacbe7e is not correct, the PR adds anly few bytes

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