Skip to content

I2C asyn calling -- OLED - #12238

Open
error414 wants to merge 29 commits into
iNavFlight:next-10.1from
error414:error414/feature/ic_async/OLED
Open

error414 wants to merge 29 commits into
iNavFlight:next-10.1from
error414:error414/feature/ic_async/OLED

Conversation

@error414

@error414 error414 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

This PR is based on I2C asyn calling -- CORE

OLED display makes lot of I2C calls, and it can create huge gaps in dshot frames, one OLED cycle can take up to few ms (not us). After this patch one OLED cycle takes few us (not ms).

I2C sync

Task list         rate/hz  max/us  avg/us maxload avgload     total/ms
 0 -       SYSTEM       9      13       1    0.5%    0.5%      2294
 1 -          PID     999      60      36    6.4%    4.0%       367
 2 -         GYRO    3968       9       1    4.0%    0.8%        40
 3 -           RX      49      15      12    0.5%    0.5%         7
 4 -       SERIAL      99   127097       1 1258.7%    0.5%       801
 5 -      BATTERY      49       8       6    0.5%    0.5%         3
 6 -  TEMPERATURE      99      15       1    0.6%    0.5%         0
 7 -       BEEPER      99       4       2    0.5%    0.5%         2
 8 -          GPS      49      11       2    0.5%    0.5%         1
11 -         ADSB       1       1       0    0.5%    0.5%         0
14 -    DASHBOARD       9   119648   21973  108.1%   20.2%      2792 <<<----------
15 -    TELEMETRY     500      13       1    1.1%    0.5%        19
18 -          OSD     250     716       7   18.4%    0.6%        20
19 -          CMS      49       3       1    0.5%    0.5%         0
22 -      VTXCTRL       4       1       0    0.5%    0.5%         0
23 -  PROGRAMMING       9      11       4    0.5%    0.5%         0
25 -          AUX      99       4       1    0.5%    0.5%         1
26 - SPORT MASTER     500       2       0    0.6%    0.5%         1
27 -  CRSF SENSOR      99       1       0    0.5%    0.5%         0
29 -       GIMBAL      49       2       0    0.5%    0.5%         0
30 -  HEADTRACKER      49       2       0    0.5%    0.5%         0
33 -      TERRAIN       5       1       0    0.5%    0.5%         0
34 -   TERRAIN_IO      49       4       0    0.5%    0.5%         0
35 -     DRONECAN     492       6       1    0.7%    0.5%         3
Task check function             3       1                         0
Total (excluding SERIAL)                   147.4%   35.1%

I2C Async

Task list         rate/hz  max/us  avg/us maxload avgload     total/ms
 0 -       SYSTEM       9      14       1    0.5%    0.5%      9489
 1 -          PID     998      96      67   10.0%    7.1%      2291
 2 -         GYRO    3952      15       1    6.4%    0.8%       197
 3 -           RX      49      30      20    0.6%    0.5%        41
 4 -       SERIAL      99   153186       2 1517.0%    0.5%      1984
 5 -      BATTERY      49      13       8    0.5%    0.5%        14
 6 -  TEMPERATURE      99       7       1    0.5%    0.5%         2
 7 -       BEEPER      99       9       2    0.5%    0.5%         8
 8 -          GPS      49      15       2    0.5%    0.5%         4
11 -         ADSB       1       1       0    0.5%    0.5%         0
14 -    DASHBOARD     998      98      20   10.2%    2.4%        14   <<<----------
15 -    TELEMETRY     499      24       1    1.6%    0.5%       183
18 -          OSD     249     746      11   19.0%    0.7%        89
19 -          CMS      49       5       0    0.5%    0.5%         1
22 -      VTXCTRL       4       1       0    0.5%    0.5%         0
23 -  PROGRAMMING       9      20       8    0.5%    0.5%         4
25 -          AUX      99       5       2    0.5%    0.5%         7
26 - SPORT MASTER     499       4       0    0.6%    0.5%         5
27 -  CRSF SENSOR      99       3       0    0.5%    0.5%         0
29 -       GIMBAL      49       3       0    0.5%    0.5%         0
30 -  HEADTRACKER      49       3       0    0.5%    0.5%         0
33 -      TERRAIN       4       1       0    0.5%    0.5%         0
34 -   TERRAIN_IO      49       6       1    0.5%    0.5%         2
35 -     DRONECAN     493      12       2    1.0%    0.5%        20
Task check function             4       1                         1
Total (excluding SERIAL)                    56.9%   20.5%

Tested on HW
image

Raphael Hunziker and others added 23 commits September 10, 2026 20:14
SBUS servo output is resolved with findSerialPortConfig(), which returns
the first port that carries FUNCTION_SERVO_SERIAL. Assigning the function
to a second port was accepted and reported back by the serial command,
but that port was never opened.

Reject such an assignment in the CLI instead of ignoring it silently.

Fixes iNavFlight#11430
The mixer switch carry over loop ended at the first
INPUT_MIXER_SWITCH_HELPER rule. Switching a mixer profile back before
the carry over of the previous switch had decayed therefore dropped its
remaining filter state, the newly loaded rule restarted from zero and
the servo jumped towards its mid position.

Only the carry capacity ends the loop now, helper rules are carried over
like any other speed limited rule.

Fixes iNavFlight#11503
The constraints list already covers the analogous telemetry rule. Adds
the SERVO_SERIAL case, including that the second assignment used to be
accepted silently without the port ever being opened.
Rename serialDuplicatedSinglePortFunctions() to
serialGetDuplicatedSinglePortFunctions() so the helper has a verb name
like the other serialGet*/serialFind* functions (Development.md iNavFlight#5).

Cut the three-line comment above SERIAL_SINGLE_PORT_FUNCTIONS to one line
that states why the list exists.

docs/Serial.md: drop the "previously it was accepted" history from the
constraint and say what happens to a saved configuration that already
has SBUS output on several ports: only the first port in the serial list
is used, the configuration is not reset.

No functional change.
Development.md asks for comments that explain why, not what. No
functional change.
…cond-uart

Refuse assigning SBUS output to a second serial port
…ed-carryover

Keep the servo speed carry over when switching mixer profiles back
@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

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

Copy link
Copy Markdown

PR Summary by Qodo

Add non-blocking I2C transfers for OLED and selected sensors

✨ Enhancement 🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Add non-blocking I2C transfers to reduce OLED-induced gaps in motor output.
Diagram

graph TD
  Scheduler["Scheduled tasks"] --> OLED["OLED shadow frame"] --> Bus["Bus start API"] --> Platform["Platform I2C drivers"] --> Devices["I2C devices"]
  Scheduler --> States["Sensor state machines"] --> Sensors["Sensor drivers"] --> Bus
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Queue and DMA-based I2C
  • ➕ Could reduce interrupt and caller polling overhead.
  • ➕ Could arbitrate competing clients centrally.
  • ➖ Adds substantial cross-platform complexity and memory use.
  • ➖ Exceeds the needs of the current low-rate sensor and display clients.
2. Only batch blocking OLED writes
  • ➕ Much smaller platform and sensor change.
  • ➕ Reduces display transaction overhead.
  • ➖ Still blocks the flight loop for each batch.
  • ➖ Does not address blocking barometer and compass reads.

Recommendation: The start-and-poll API is a reasonable fit for existing scheduled tasks and preserves blocking callers. Review platform interrupt completion, shared-bus error ownership, and recovery particularly closely; those are the main costs of this approach.

Files changed (42) +3341 / -703

Enhancement (28) +2686 / -693
debug.hDeclare the I2C debug mode +1/-0

Declare the I2C debug mode

• Adds DEBUG_I2C to the debug mode enum for transfer diagnostics.

src/main/build/debug.h

barometer.hDefine staged barometer read hooks +12/-0

Define staged barometer read hooks

• Adds optional read-start hooks and a combined-read flag to the barometer device contract.

src/main/drivers/barometer/barometer.h

barometer_bmp280.cStage BMP280 forced-mode measurements +20/-36

Stage BMP280 forced-mode measurements

• Starts the measurement write and combined pressure-temperature read without blocking, then parses a persistent buffer. Marks the device as using one combined read.

src/main/drivers/barometer/barometer_bmp280.c

barometer_dps310.cStage DPS310 status and sample reads +37/-16

Stage DPS310 status and sample reads

• Starts separate status and measurement reads into persistent buffers. Adjusts the temperature and pressure phases to poll for ready data.

src/main/drivers/barometer/barometer_dps310.c

barometer_spl06.cStage SPL06 temperature and pressure transfers +42/-24

Stage SPL06 temperature and pressure transfers

• Separates measurement triggers, non-blocking reads, and parsing. Reads the coefficient-source register when configuring the temperature sensor, with a fallback if unavailable.

src/main/drivers/barometer/barometer_spl06.c

barometer_spl06.hName the SPL06 coefficient-source register +1/-0

Name the SPL06 coefficient-source register

• Defines the register used to select the temperature sensor matching the calibration coefficients.

src/main/drivers/barometer/barometer_spl06.h

bus.cExpose non-blocking transfers through the common bus +89/-2

Expose non-blocking transfers through the common bus

• Adds read and write start calls that dispatch to I2C or complete synchronously on SPI. Extends busIsBusy to return transfer errors.

src/main/drivers/bus.c

bus.hDefine bus start and staged-read contracts +20/-1

Define bus start and staged-read contracts

• Declares non-blocking bus operations, error-aware busy polling, and result states for multi-transfer sensor reads.

src/main/drivers/bus.h

bus_busdev_i2c.cBridge bus devices to I2C start calls +21/-7

Bridge bus devices to I2C start calls

• Adds I2C bus-device start wrappers and passes the slave address through busy and error polling.

src/main/drivers/bus_busdev_i2c.c

bus_i2c.hStandardize asynchronous I2C results +30/-2

Standardize asynchronous I2C results

• Declares start and per-address busy APIs plus a per-bus bitmap for each slave's last outcome. Adds interrupt metadata for STM32F4.

src/main/drivers/bus_i2c.h

bus_i2c_at32f43x.cAdd interrupt-driven AT32 I2C transfers +350/-32

Add interrupt-driven AT32 I2C transfers

• Moves the register phase into an event interrupt wrapper, adds start and completion polling, and tracks stuck or held buses and per-address failures. Blocking calls wait for outstanding asynchronous work.

src/main/drivers/bus_i2c_at32f43x.c

bus_i2c_hal.cAdd HAL-backed asynchronous I2C transfers +325/-9

Add HAL-backed asynchronous I2C transfers

• Uses HAL interrupt transfers and completion callbacks, with per-address results and recovery for stalled transfers or refused starts. Existing blocking operations wait for an in-flight transfer.

src/main/drivers/bus_i2c_hal.c

bus_i2c_rp2350.cProvide synchronous RP2350 start fallbacks +42/-4

Provide synchronous RP2350 start fallbacks

• Implements the new start API using existing blocking transfers and retains their outcomes per slave address.

src/main/drivers/bus_i2c_rp2350.c

bus_i2c_soft.cProvide synchronous software-I2C start fallbacks +35/-0

Provide synchronous software-I2C start fallbacks

• Wraps blocking software-I2C transfers with the new start and per-address result API.

src/main/drivers/bus_i2c_soft.c

bus_i2c_stm32f40x.cReplace STM32F4 polling with an interrupt engine +516/-416

Replace STM32F4 polling with an interrupt engine

• Replaces the task-driven transaction state machine with event and error interrupts shared by blocking and non-blocking calls. Adds progress timeouts, task-context recovery, per-address outcomes, and diagnostics.

src/main/drivers/bus_i2c_stm32f40x.c

bus_i2c_stm32f7xx.cAdd register-level STM32F7 I2C engine +664/-0

Add register-level STM32F7 I2C engine

• Introduces an interrupt-driven peripheral implementation for blocking and non-blocking transfers without the HAL I2C module. Handles read restarts, completion, per-address failures, timeouts, and bus recovery.

src/main/drivers/bus_i2c_stm32f7xx.c

compass.hDefine optional staged compass reads +5/-1

Define optional staged compass reads

• Adds a readStart hook for drivers that perform one or more transfers before parsing a sample.

src/main/drivers/compass/compass.h

compass_qmc5883l.cStage QMC5883L status and data reads +40/-15

Stage QMC5883L status and data reads

• Starts a status read, conditionally starts a data read when ready, and parses the persistent result buffer.

src/main/drivers/compass/compass_qmc5883l.c

compass_qmc5883p.cStage QMC5883P status and data reads +38/-12

Stage QMC5883P status and data reads

• Separates readiness and sample transfers across scheduler calls, then parses a persistent data buffer.

src/main/drivers/compass/compass_qmc5883p.c

display_ug2864hsweg01.cStream dirty OLED columns from a shadow frame +199/-72

Stream dirty OLED columns from a shadow frame

• Moves drawing into a shadow frame and pumps changed columns as bounded non-blocking I2C chunks. Adds retry and error backoff while keeping initialization and its initial clear blocking.

src/main/drivers/display_ug2864hsweg01.c

display_ug2864hsweg01.hExpose OLED pump and pending-work status +6/-1

Expose OLED pump and pending-work status

• Declares the display pump, busy query, and suggested retry interval.

src/main/drivers/display_ug2864hsweg01.h

i2c_application.hDeclare the AT32 transfer-start primitive +1/-0

Declare the AT32 transfer-start primitive

• Exposes the low-level start operation used by the new AT32 register-phase interrupt wrapper.

src/main/drivers/i2c_application.h

fc_tasks.cReschedule pending OLED and sensor work +15/-4

Reschedule pending OLED and sensor work

• Revisits incomplete display and sensor transfers promptly, restores regular task periods afterward, and publishes barometer data only when a new sample is ready.

src/main/fc/fc_tasks.c

displayport_oled.cReport outstanding OLED transfers to the display port +1/-1

Report outstanding OLED transfers to the display port

• Uses the OLED driver's busy status for the display port's transfer-in-progress query.

src/main/io/displayport_oled.c

barometer.cDrive barometer measurements in staged phases +121/-30

Drive barometer measurements in staged phases

• Replaces the two-state update loop with trigger, read, and sample phases that retry busy or failed transfers. Reports when a fresh sample is produced.

src/main/sensors/barometer.c

barometer.hExpose barometer sample readiness +1/-1

Expose barometer sample readiness

• Changes baroUpdate to return new-sample status alongside its next scheduling delay.

src/main/sensors/barometer.h

compass.cSchedule staged compass reads +49/-6

Schedule staged compass reads

• Tracks multi-transfer reads, polls for completion and errors, and requests short retries until a sample can be parsed.

src/main/sensors/compass.c

compass.hDefine compass cadence and update result +5/-1

Define compass cadence and update result

• Names the regular compass update period and changes compassUpdate to return its next scheduling delay.

src/main/sensors/compass.h

Bug fix (4) +28 / -3
cli.cReject duplicate SBUS output assignments and name I2C debug mode +8/-1

Reject duplicate SBUS output assignments and name I2C debug mode

• Checks a proposed serial configuration before saving it and reports duplicate single-port functions. Adds I2C to CLI debug mode names.

src/main/fc/cli.c

servos.cPreserve speed-limit carry-over through helper rules +2/-2

Preserve speed-limit carry-over through helper rules

• Stops ending the carry-over scan at the first mixer-switch helper, retaining decaying filter state when switching profiles back.

src/main/flight/servos.c

serial.cDetect functions assigned to multiple serial ports +17/-0

Detect functions assigned to multiple serial ports

• Adds a helper that detects when SBUS servo output is assigned to another configured port.

src/main/io/serial.c

serial.hDeclare the duplicate serial-function check +1/-0

Declare the duplicate serial-function check

• Exposes the single-port-function check for CLI configuration validation.

src/main/io/serial.h

Refactor (1) +2 / -2
sdcard_spi.cAdapt SD-card busy checks to the bus API +2/-2

Adapt SD-card busy checks to the bus API

• Passes a null error pointer at both SPI bus wait sites after the busIsBusy signature change.

src/main/drivers/sdcard/sdcard_spi.c

Tests (2) +376 / -0
CMakeLists.txtRegister OLED driver unit tests +3/-0

Register OLED driver unit tests

• Links the OLED driver into a new unit-test target with its required feature definitions.

src/test/unit/CMakeLists.txt

display_ug2864hsweg01_unittest.ccTest OLED chunking, retries, and initialization +373/-0

Test OLED chunking, retries, and initialization

• Uses a fake bus to verify dirty-column transfers, chunk bounds, busy handling, error backoff, full clears, controller offsets, and cursor wrapping.

src/test/unit/display_ug2864hsweg01_unittest.cc

Documentation (4) +246 / -0
AGENTS.mdIndex the non-blocking I2C guide +1/-0

Index the non-blocking I2C guide

• Adds the new development guide to the repository documentation index.

AGENTS.md

Serial.mdDocument the single-port SBUS output constraint +1/-0

Document the single-port SBUS output constraint

• Explains that only one serial port can carry SBUS servo output and how existing duplicate configurations behave.

docs/Serial.md

Settings.mdList I2C as a debug mode +1/-0

List I2C as a debug mode

• Adds the I2C mode to the documented debug settings.

docs/Settings.md

non-blocking-i2c.mdDocument non-blocking I2C behavior and migration +243/-0

Document non-blocking I2C behavior and migration

• Describes platform implementations, the bus API, timeout recovery, converted sensors, OLED pumping, debugging, and limitations.

docs/development/non-blocking-i2c.md

Other (3) +3 / -5
stm32f7.cmakeBuild the STM32F7 register-level I2C driver +1/-3

Build the STM32F7 register-level I2C driver

• Replaces the HAL I2C driver source and removes HAL I2C implementation sources from the F7 build.

cmake/stm32f7.cmake

settings.yamlExpose I2C in generated debug settings +1/-1

Expose I2C in generated debug settings

• Adds I2C to the debug mode values used by settings generation.

src/main/fc/settings.yaml

stm32f7xx_hal_conf.hDisable the STM32F7 HAL I2C module +1/-1

Disable the STM32F7 HAL I2C module

• Turns off the HAL I2C module configuration to match the register-level driver.

src/main/target/stm32f7xx_hal_conf.h

@error414 error414 changed the title Error414/feature/ic async/oled I2C asyn calling -- OLED Nov 16, 2026
@error414 error414 mentioned this pull request Nov 16, 2026
9 tasks done
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 16, 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. Delayed interrupts truncate I²C writes ✓ Resolved

Resolving commit: 3febf78

Resolution reason
In the EV8_2 (BTF) handler, when a write has bytes still pending (index < bytes), the driver now
queues the next byte via a new i2cSendNextByte() helper rather than sending STOP, so a delayed BTF
no longer truncates the write or reports false success.
Description
The STM32F4 event handler treats any write-side BTF event as completion, even when index shows
that payload bytes have not yet been queued. If an interrupt is delayed long enough for BTF to
become set after the register byte but before the next TXE handler runs, it sends STOP without the
remaining data; a single-byte write can then be reported as successful.

2. OLED display freezes after ~36 minutes uptime ✓ Resolved

Resolving commit: 3febf78

Resolution reason
Adds a static oledBackoffActive flag set alongside oledRetryAtUs when a chunk is lost, cleared in
oledResetState() and after the backoff expires. The pump only performs the cmpTimeUs deadline check
while the flag is set, so a stale oledRetryAtUs no longer causes a permanent backoff. This follows
the suggested fix prompt exactly.
Description
i2c_OLED_pump() gates every new chunk on cmpTimeUs(micros(), oledRetryAtUs) < 0. oledRetryAtUs
is long-lived: it is 0 from reset, or a value set once after a bus error. cmpTimeUs truncates the
difference to a 32-bit signed timeDelta_t, so once more than 2^31 µs (~35.8 min) has passed since
oledRetryAtUs, the result goes negative and the pump reports 'backing off'. The dashboard and the
CMS-on-OLED then stop refreshing for ~35.8 minutes, recover, and freeze again in a repeating cycle,
often in flight.


Remediation recommended

3. OLED initialization can leave stale pixels ✓ Resolved

Resolving commit: 3febf78

Resolution reason
i2c_OLED_clear_display() now returns bool and checks i2c_OLED_isBusy() after the pump loop; if the
pump stopped during backoff (work still pending), it returns false without switching the panel on.
It only sends the display-on command when the clear actually completed. ug2864hsweg01InitI2C() now
checks the result, logs an error, resets OLED state, and returns false instead of reporting success
with uncleared pixels. Also the backoff flag fix (oledBackoffActive) makes cmpTimeUs usage correct,
supporting the backoff path. The fix distinguishes backoff from completion and fails initialization
rather than waiting through retries, which is a different implementation from the suggested
bounded-retry approach.
Description
i2c_OLED_clear_display() exits its pump loop when i2c_OLED_pump() returns false during error
backoff, even though clear chunks remain dirty. If an initialization chunk fails, the function sends
the display-on command and ug2864hsweg01InitI2C() returns true before the panel has been cleared.

4. Software I²C reports some NACKs as success ✓ Resolved

Resolving commit: 3febf78

Resolution reason
Every address, register, and data-byte phase of the software I²C write path now checks its ACK and
returns false on NACK (with bus stop and error count), and the read path checks its address/register
ACKs, so the async wrapper's recorded result reflects NACKs.
Description
The new software-I²C start wrappers record the blocking operation's boolean result as the outcome
later returned by i2cBusy(), but those blocking operations discard ACK results for some register
and data bytes. When a device NACKs one of those bytes, an asynchronous caller polling busIsBusy()
receives error == false and can proceed as though its transfer completed successfully.

5. MPU9250 compass drops from 40 Hz to 10 Hz ✓ Resolved

Resolving commit: 3febf78

Resolution reason
The fcTasksInit 40 Hz override block (USE_MAG_MPU9250 rescheduleTask) was removed from fc_tasks.c,
and compass.h now defines COMPASS_UPDATE_RATE_HZ as 40 under USE_MAG_MPU9250 and 10 otherwise. Since
compassUpdate() returns COMPASS_UPDATE_PERIOD_US after each sample, the regular period on MPU9250
builds is now 40 Hz, so the overwrite no longer drops the rate to 10 Hz. This is a different
implementation from the suggested fix (compassUpdate still returns the fixed period rather than 0),
but it resolves the premise of the finding.
Description
taskUpdateCompass now passes every non-zero return of compassUpdate() to
rescheduleTask(TASK_SELF, ...), and compassUpdate() returns the fixed COMPASS_UPDATE_PERIOD_US
(100 ms) on every completed path. On builds with USE_MAG_MPU9250, the 40 Hz period that
fcTasksInit sets for the AK8963-via-MPU9250 workaround is overwritten after the first update, so
those boards sample the compass at 10 Hz.

View medium (1)
6. Single-byte async write can send 0x00 after a bus error 🐞 Bug ☼ Reliability
Description
i2cWriteStart() copies the byte into busState[device].txByte and then calls
i2cStartTransfer(). That function first runs i2cServiceReset(), and when needsReset is pending
this calls i2cInit(), which memsets the whole state, txByte included, before the transfer
points writeBuf at it. If a BERR/ARLO (F7) or held-bus abort (F4) is still waiting for its reset
when the next single-byte write starts, a zero goes out instead of the requested value, e.g. the
BMP280 CTRL_MEAS or SPL06 mode command, which puts the sensor into sleep/standby for that cycle.
Code

src/main/drivers/bus_i2c_stm32f7xx.c[R498-505]

+bool i2cWriteStart(I2CDevice device, uint8_t addr_, uint8_t reg_, uint8_t data, bool allowRawAccess)
+{
+    if (!i2cIsValidDevice(device) || busState[device].busy) {
+        return false;   // don't touch txByte while it may still be going out
+    }
+
+    busState[device].txByte = data;
+    return i2cStartTransfer(device, addr_, reg_, allowRawAccess, false, 1, NULL, &busState[device].txByte);
Evidence
The F7 interrupt handler sets needsReset on bus errors and completes the transfer, so busy becomes
false. i2cWriteStart passes its busy check, writes txByte, then i2cStartTransfer calls
i2cServiceReset -> i2cInit -> memset(state, 0), and afterwards sets writeBuf = &txByte (now 0). The
reset is only serviced from task context (i2cBusy or a start call). A blocking transfer that failed
this way returns from i2cWaitForIdle without servicing it, so the next start can be an
i2cWriteStart. The F4 driver has the same order (txByte set at line 476, i2cServiceReset at 359,
memset at 312, needsReset set at 542). busWriteStart is used by the BMP280 and SPL06 drivers.

src/main/drivers/bus_i2c_stm32f7xx.c[222-228]
src/main/drivers/bus_i2c_stm32f7xx.c[333-334]
src/main/drivers/bus_i2c_stm32f7xx.c[372-384]
src/main/drivers/bus_i2c_stm32f7xx.c[569-579]
src/main/drivers/bus_i2c_stm32f40x.c[355-362]
src/main/drivers/barometer/barometer_bmp280.c[64-64]
src/main/drivers/barometer/barometer_spl06.c[98-98]

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

## Issue description
In the F7 and F4 I2C drivers, `i2cWriteStart()` writes `txByte` and then calls `i2cStartTransfer()`. That function may run `i2cServiceReset()` -> `i2cInit()`, which zeroes the state including `txByte`, so the transfer sends 0x00 instead of the requested byte.
## Fix Focus Areas
- src/main/drivers/bus_i2c_stm32f7xx.c[498-505]
- src/main/drivers/bus_i2c_stm32f7xx.c[372-384]
- src/main/drivers/bus_i2c_stm32f40x.c[470-477]
- src/main/drivers/bus_i2c_stm32f40x.c[350-362]
## Recommended Fix
In `i2cWriteStart()`, call `i2cServiceReset(device)` before the busy check and before assigning `busState[device].txByte = data`. Alternatively, pass the data value into `i2cStartTransfer()` and assign `txByte` after the reset and busy checks, then point `writeBuf` at it. Apply the same change to both drivers.

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



Informational

7. Serial CLI error shows a raw function bitmask 🐞 Bug ⚙ Maintainability
Description
cliSerial prints serialGetDuplicatedSinglePortFunctions() with %d, so a duplicate SBUS output
assignment is reported as e.g. 'Function 262144 is already assigned to another port'. The user has
to decode the bitmask to see that SBUS/servo-serial output is the conflict, and the number will not
match any function name shown by the CLI or Configurator.
Code

src/main/fc/cli.c[R948-951]

+    const uint32_t duplicatedFunctions = serialGetDuplicatedSinglePortFunctions(&portConfig);
+    if (duplicatedFunctions) {
+        cliPrintErrorLinef("Function %d is already assigned to another port", (int)duplicatedFunctions);
+        return;
Evidence
serialGetDuplicatedSinglePortFunctions returns the masked functionMask bits (FUNCTION_SERVO_SERIAL),
not an index or a name, and the CLI prints that value directly.

src/main/io/serial.c[316-331]
src/main/fc/cli.c[948-952]

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 CLI error for a duplicated single-port serial function prints the raw function bitmask, which users cannot interpret.
## Fix Focus Areas
- src/main/fc/cli.c[948-952]
## Recommended Fix
Map the returned mask to a name (e.g. `if (duplicatedFunctions & FUNCTION_SERVO_SERIAL) name = "SBUS output"`) and print `cliPrintErrorLinef("%s is already assigned to another port", name)`. Alternatively, print the mask in hex together with the existing function naming.

ⓘ 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 enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

RAM / Flash usage vs. base commit 01a7aa3 — commit 3febf78

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

Target Flash Δ RAM Δ
MATEKF405 ⚠️ +6536 B (+0.90%) CCM: -4 B (-0.01%)
RAM: +2916 B (+2.80%)
MATEKF722 ⚠️ +212 B (+0.04%) ITCM_RAM: -928 B (-7.40%)
RAM: +1108 B (+1.28%)
TCM: ±0 B (±0.00%)
MATEKF765 ⚠️ +304 B (+0.04%) DTCM_RAM: ±0 B (±0.00%)
SRAM1: +1136 B (+0.91%)
MATEKH743 ⚠️ +12700 B (+1.59%) D2_RAM: +256 B (+7.84%)
DTCM_RAM: ±0 B (±0.00%)
ITCM_RAM: -888 B (-5.41%)
RAM: +3228 B (+2.27%)

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

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Test firmware build ready — commit 3febf78

Download firmware for PR #12238

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.

@b14ckyy

b14ckyy commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Yayyy no servo stutter anymore with OLED Enabled? :D
But still off in flight right? Because thats pointless and too risky imho

nice one!

@error414

Copy link
Copy Markdown
Contributor Author

I hope so :D. You are right, still off after ARM.

@sensei-hacker sensei-hacker added this to the 10.1 milestone Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants