Repository navigation
Conversation
taskRunRealtimeCallbacks() calls afatfs_poll() from scheduler(), which is FAST_CODE, and LTO inlines the file system's state machine into it. On targets with an SD card that puts 800 to 980 bytes of afatfs code in ITCM, depending on the target, where KAKUTEF7 and KAKUTEF7HDV are at 99%. The poll does a little work at most once per scheduler loop, so it runs from flash like the rest of afatfs.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoKeep async FAT polling out of the ITCM scheduler
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can route each severity your way: inline, summary, both, or drop |
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #12118 251 targets built. Find your board's
|
|
I rememeber that make afatfs_poll inline was first proposal from claude when I wanted to reduce size of code in ITCM RAM for F7 CPU. The question is if whole taskRunRealtimeCallbacks should not be NOINLINE and pasted in ordinary RAM. Scheculer was moved to ITCM by commit 7faeb47 (Second iteration of makinf F7 fast) |
|
@error414 I measured both on a Flywoo F722 (DSHOT300, 2 kHz PID loop,
Taking the whole function out frees another 1.5 KB, but the PID task gets about 3 us slower in every reading. pwmCompleteMotorUpdate() is only called from the callbacks, so this comes from how LTO lays out the rest once the function leaves ITCM; I have not tracked down exactly what moved. This PR frees the ~800 B #12063 needs without touching the motor path, so I'd keep it as is and move the rest only when ITCM runs out again. If you'd rather have the larger margin now, it's a one-line change on top. |
|
ook, and do wee need to move afatfs_poll for H743 which has much bigger ITCM memory 16kB vs 64kB? on H743 could be activated terrain feature which reads from SD card and can be affected |
The H7's ITCM is 64 KB and about a quarter used, so the poll can stay inlined in the scheduler there, as on maintenance-10.x. F7 builds are identical to the previous commit; H7, F4 and AT32 builds are identical to maintenance-10.x.
|
@error414 Good point: the H743 doesn't need it. Its ITCM is about a quarter full (TBS_LUCID_H7_WING 16 KB of 64 KB), so I've limited the change to F7 in c8ecb50: F7 builds are identical to before, and H7, F4 and AT32 builds are identical to maintenance-10.x, so on H7 Before changing it I checked whether it mattered, on an H743 (TBS Lucid H7 Wing) with an SD card and terrain on, with a real tile file (N46E011), a HITL flight from Trento to the top of the Bondone and the blackbox logging at 2 kHz to the same card:
No difference either way, but there's no reason to move it where the room isn't needed. |
|
I have same experience, I tested "NOINLINE" on matekh743 and I didn't see any issue. Unfortunately I don't have F7 with SD card slot. |
|
@error414 Thanks for trying it on the MATEKH743. I haven't got an F7 with an SD slot on the bench either; only F7 targets with SD change here (the others build the same as before), so a log from one of those is still the missing piece. |
#12120 and #12121 (throttle boost, thrust linearization) and #12132 (CRSF and SBUS receivers on DMA) build on this one, for the ITCM it frees on KAKUTEF7 and KAKUTEF7HDV. It can go in on its own.
taskRunRealtimeCallbacks()callsafatfs_poll()fromscheduler(), which isFAST_CODE, and LTO inlines thewhole poll into it. On targets with an SD card that puts 800 to 980 bytes of the file system's state machine in ITCM,
depending on the target. KAKUTEF7 and KAKUTEF7HDV are at 99 % ITCM on
maintenance-10.x, so they stop linking assoon as anything else on the fast path grows a little. It already happens:
maintenance-10.x; with this PR ontop it links at 15 432 B (94.19 %). Even with the fix prepared for it, it sits at exactly 16 384 of 16 384 B, and
together with cli: show each task's average rate in tasks, not the one of its latest interval #12117 it overflows again.
With this PR on top the three together use 15 328 / 15 456 B.
On F7, whose ITCM is 16 KB,
NOINLINEonafatfs_poll()keeps it in flash with the rest of afatfs; H7 has theroom and keeps it in ITCM. The poll only starts the next SD operation
when one is pending, at most once per scheduler loop, and SD writes are bound by the card, not by where this code
runs. The DShot completion called from the same place stays inlined in the scheduler, in ITCM (checked in the map).
Size,
maintenance-10.x3f9fde4 -> this branchTesting
On F7 this change only moves code:
afatfs_poll()and its callers are the same, and the unit tests pass. On H7,F4 and AT32 the builds are identical to
maintenance-10.x. None of my F7 boards has an SD card, so a blackbox logwritten to SD and decoded from an F7 board would be welcome.