Repository navigation
testing/ostest,system/dd: reduce the test image's flash footprint - #4040
Merged
Merged
Conversation
wdtest_delay() divided the 64-bit clock_t delay by 1000 and wdog_test_thread() computed "rand() % rand_ns" in 64 bits, so wdog.c held four __aeabi_ldivmod libcalls. Every delay in this test is below 2^32 ns (wdtest_once passes at most 1e6 ns, wdtest_recursive reaches times * delay_ns = 1e8, and rand_ns is the 12345 constant), so the narrowing casts are value-preserving and the divisions become native 32-bit operations instead of library calls. These were the last signed 64-bit division call sites in the b-g431b-esc1:nsh image; with them gone the __aeabi_ldivmod and __aeabi_ldiv0 members are no longer pulled in at all. Evidence (b-g431b-esc1:nsh, Make, arm-none-eabi-gcc 13.2.1, LTO_FULL): __aeabi_ldivmod call sites 4 -> 0 and the two symbols disappear from the map (162 B recovered); flash 127824 -> 127620 B, and nucleo-g431kb:nsh (CMake) 127880 -> 127680 B. The two unsigned call sites in dd and the spinlock test still hold __udivmoddi4. Assisted-By: mimo-v2.6-pro Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Fix-Point
force-pushed
the
g4-flash-ostest-dd
branch
from
November 12, 2026 12:23
934e4f7 to
0e35e35
Compare
xiaoxiang781216
previously approved these changes
Nov 12, 2026
Contributor
|
@Fix-Point please fix the style issue. |
cederom
previously approved these changes
Nov 12, 2026
Contributor
|
plz fix the issues reported by ci :-) |
Contributor
|
@Fix-Point please fix compiler warning |
The copy throughput in dd_main.c is computed in double, which pulls the whole soft-float cluster (__aeabi_dadd and friends, ~2 KiB) into the image. Compute it in integer arithmetic instead: the divisor is split so the division by 1024 becomes a shift, keeping one 64-bit division against the division library the image already contains. Measured on nucleo-g431kb:nsh (arm-none-eabi-gcc): the dd_main station drops from 2 KiB of soft-float calls to none, and together with the wdog narrowing the image shrinks by 2052 bytes (128536 -> 126484), enough to keep the 128 KiB G431 boards linkable again. Assisted-By: mimo-v2.6-pro Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Fix-Point
dismissed stale reviews from cederom and xiaoxiang781216
via
November 13, 2026 01:35
1cfa254
Fix-Point
force-pushed
the
g4-flash-ostest-dd
branch
from
November 13, 2026 01:35
0e35e35 to
1cfa254
Compare
This commit fixed the nxstyle. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Fix-Point
force-pushed
the
g4-flash-ostest-dd
branch
from
November 13, 2026 02:50
ab54d57 to
a3a263a
Compare
GUIDINGLI
approved these changes
Nov 13, 2026
xiaoxiang781216
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR shrinks the flash footprint of the
ostestandddtest utilities to keep the 128 KiB G431 boards linking alongside apache/nuttx#21491.This is entirely about flash size, not behaviour. The math32 changes in apache/nuttx#21491 replace constant-divisor 64-bit divisions with inline multiply-shift magic, which is a performance win but grows the image by ~256 bytes on 32-bit targets.
b-g431b-esc1andnucleo-g431kbalready have only 127/55 bytes of flash free on master, so #21491 pushes them over the edge (theLinux (arm-stm32l-u-g)CI job reportsregion 'flash' overflowed by 132 bytesandby 188 bytes). To make room without touching the boards' configuration, this PR frees flash in the test utilities:Narrow the wdog delay math to 32 bits (
testing/ostest/wdog.c): every delay in the test stays below 2^32 ns, so keeping the division and modulo 32-bit avoids pulling the 64-bit division library into the image.Compute the dd copy throughput with integer arithmetic (
system/dd/dd_main.c): the throughput was computed indouble, which pulls the whole soft-float cluster (__aeabi_daddand friends, ~2 KiB) into the image. Integer arithmetic --(total * USEC_PER_SEC / 1024) / elapsed, with the division by 1024 a shift -- keeps one 64-bit division against the division library the image already contains and drops the soft-float cluster.Measured on
nucleo-g431kb:nsh, the image shrinks by 2052 bytes (128536 -> 126484), leaving headroom over the 188-byte shortfall; the same two commits clearb-g431b-esc1:nsh(132 bytes).The 64-bit division library is still linked after this PR (the unpatched
gmtime/printfsites keep it); removing it entirely is a separate, larger change and is deliberately out of scope here.Impact
ddprints its KB/s line with integer rounding (off by at most ~1 KB/s versus the old double math) andostest's wdog timings are unchanged (the delays fit in 32 bits).CONFIG_*change, no build-system change, no new header.dd's output format is unchanged.Testing
arm-none-eabi-gcc10.3.1.b-g431b-esc1:nsh(Make),nucleo-g431kb:nsh(CMake).nucleo-g431kb:nsh, text+data): 128536 -> 126484, -2052 B.qemu-armv7aboots;ostestexits 0 (wdog, spinlock and POSIX timer cases pass);ddprints a KB/s line consistent with the integer formula. No real G431 hardware available -- the run is QEMU only.tools/checkpatch.sh: passes on both commits.