chore: remove dead STM32F1 code - #1368
Conversation
STM32F1 has zero current EmuFlight build targets: F1_TARGETS is referenced in three makefile sites but never assigned anywhere. Removes STM32F1-conditional code from the chip-detection chain in platform.h (the sole definition site of the STM32F1 macro), the already-stale build warning in version.c, flash-page-size and flash-clear-flag chains in config_streamer.c, CLI/MSP buffer-size selection, gyro_sync_denom clamping in fc/config.c and sensors/gyro.c, the UART1 DMA/MINIMAL_CLI defaults in common_fc_pre.h, I2C pin defaults in common_defaults_post.h, and the F1 arms in vcp/vcpf4 USB descriptor/init code (vcp/ is shared with STM32F3, deferred to a separate change; only F1-specific arms are touched here). Related to emuflight#1365 (STM32F1 half only; STM32F3 is deferred).
Removes STM32F1-conditional arms from ~30 shared driver files (adc, bus_i2c, bus_spi variants, camera_control, dma, exti, io, light_ws2811strip, pwm_output, rcc, rx_pwm, rangefinder_hcsr04, serial_* UART/softserial/escserial, timer/timer_def) while keeping the F3/F4/F7/H7/SITL code paths byte-equivalent to before. drivers/bus_i2c_stm32f10x.c is left untouched: despite its name it is a live F4 driver (referenced from make/mcu/STM32F4.mk) containing no STM32F1 macro. The TIM8 IRQ handler collapse in timer.c keeps the branch F4/F7/H7/ SITL already took (TIM8_UP_IRQHandler) and drops only the STM32F10X_XL-only alternative, avoiding a duplicate definition of TIM8_UP_TIM13_IRQHandler on F4 targets. Related to emuflight#1365 (STM32F1 half only; STM32F3 is deferred).
Deletes make/mcu/STM32F1.mk (reachable only via TARGET_MCU, which can no longer resolve to STM32F1). Removes the F1_TARGETS arm and its dead-code reference from make/targets.mk's STM-group validation, and the two-line !F1 guard in make/source.mk wrapping the F4/F7 SPEED_OPTIMISED_SRC block (F1_TARGETS was never assigned, so the guard always evaluated true; removing it changes no target's source list). Removes the unreachable STM32F10X_MD unit-test define from src/test/Makefile (verified: no file in either affected test's SRC list, nor the test-stub platform.h header closure, keys off it) and the stale startup_stm32f10x_md_gcc.s .gitignore entry. Related to emuflight#1365 (STM32F1 half only; STM32F3 is deferred).
Removes the F1-exclusive CMSIS/StdPeriph/HAL vendor tree
(lib/main/STM32F1/, 293 files, 44MB) and the files that referenced
it exclusively:
- src/main/drivers/{adc,serial_uart,system,timer}_stm32f10x.c
- src/main/startup/startup_stm32f10x_{md,hd}_gcc.S
- src/main/target/link/stm32_flash_f103_{64k,128k,128k_opbl,256k}.ld
- src/main/target/stm32f1xx_hal_conf.h (already an unreferenced
orphan before this change)
lib/main/STM32_USB-FS-Device_Driver/ is not touched: it is shared
with STM32F3/F4 and remains referenced from make/mcu/STM32F3.mk and
make/mcu/STM32F4.mk.
Residual grep for STM32F1/STM32F10X across src/, make/, Makefile,
and .github/ now returns only prose (comments, docs, a license
header) with zero build-system effect.
Related to emuflight#1365 (STM32F1 half only; STM32F3 is
deferred).
|
Important Review skippedToo many files! This PR contains 357 files, which is 207 over the limit of 150. To get a review, reduce the PR to 150 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (357)
You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review Dead-platform removal: STM32F1 has zero current build targets ( Areas most worth a second look:
Full 459-target fleet build passed (0 failed); unit tests 42/42. Hardware/flight verification has not been performed yet. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== PR metadata =='
gh pr view 1368 --json baseRefName,headRefName,changedFiles,files,url
echo '== Changed files outside deleted STM32F1 vendor library =='
git diff --name-status "@{upstream}...HEAD" 2>/dev/null || git diff --name-status HEAD~1...HEAD
echo '== Relevant changed diff hunks =='
git diff --unified=40 "@{upstream}...HEAD" -- \
src/main/drivers/timer.c \
src/main/vcp \
make/targets.mk \
make/source.mk \
src/test/Makefile \
src/main/build/version.c \
src/main/platform.h \
2>/dev/null || \
git diff --unified=40 HEAD~1...HEAD -- \
src/main/drivers/timer.c src/main/vcp make/targets.mk make/source.mk src/test/Makefile src/main/build/version.c src/main/platform.h
echo '== F1/F3 target assignments and references =='
rg -n -C 3 '(^|\W)(F1_TARGETS|F3_TARGETS|STM32F10X|STM32F1)(\W|$)' \
make src/main src/test .gitignore -g '!lib/main/STM32F1/**' || true
echo '== TIM8 IRQ handler declarations and definitions =='
rg -n -C 8 '\bTIM8_UP(?:_TIM13)?_IRQHandler\s*\(' src make || true
echo '== Changed preprocessor directives in retained files =='
git diff --unified=8 "@{upstream}...HEAD" -- src/main make src/test .gitignore 2>/dev/null | \
rg -n -C 3 '^[+-]\s*#\s*(if|ifdef|ifndef|elif|else|endif)\b|TIM8_UP' || trueLength of output: 40713 🏁 Script executed: #!/bin/bash
set -euo pipefail
base="$(git merge-base master HEAD)"
echo "== Comparison range =="
echo "$base...HEAD"
echo '== Retained changed files =='
git diff --name-status "$base...HEAD" -- . \
':(exclude)lib/main/STM32F1/**' |
tee /tmp/retained-changes.txt
echo '== Changed VCP files and full diffs =='
git diff --name-status "$base...HEAD" -- src/main/vcp
git diff --unified=30 "$base...HEAD" -- src/main/vcp
echo '== timer.c diff and current handler context =='
git diff --unified=50 "$base...HEAD" -- src/main/drivers/timer.c
rg -n -C 12 'TIM8_UP|TIM13_IRQHandler' src/main/drivers/timer.c src/main || true
echo '== All surviving STM32F1 macro references in retained source/build files =='
rg -n -C 2 '(STM32F10X|STM32F1|F1_TARGETS)' \
make src/main src/test .gitignore \
-g '!lib/main/STM32F1/**' || true
echo '== F1/F3 target variable assignments in base and head =='
for rev in "$base" HEAD; do
echo "-- $rev --"
git grep -nE '^[[:space:]]*(F1_TARGETS|F3_TARGETS)[[:space:]]*[:+?]?=' "$rev" -- make src/main src/test 2>/dev/null || true
done
echo '== All retained changed preprocessor directives, with file headers =='
git diff --unified=12 "$base...HEAD" -- src/main make src/test .gitignore \
| awk '
/^diff --git / { file=$4; sub("^b/", "", file); print "\n== " file " ==" }
/^[+-][[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif|else|endif)\b/ { print }
'
echo '== Diff statistics for retained files =='
git diff --stat "$base...HEAD" -- . ':(exclude)lib/main/STM32F1/**'Length of output: 1971 🏁 Script executed: #!/bin/bash
set -euo pipefail
base="035fff17b9f9f5336d5982689bb330faed72c7bb"
echo '== Retained changed files =='
git diff --name-status "$base...HEAD" -- . ':(exclude)lib/main/STM32F1/**'
echo '== Changed VCP files and full diffs =='
git diff --name-status "$base...HEAD" -- src/main/vcp
git diff --unified=30 "$base...HEAD" -- src/main/vcp
echo '== timer.c diff and current handler context =='
git diff --unified=50 "$base...HEAD" -- src/main/drivers/timer.c
rg -n -C 12 'TIM8_UP|TIM13_IRQHandler' src/main/drivers/timer.c src/main || true
echo '== All surviving STM32F1 macro references in retained source/build files =='
rg -n -C 2 '(STM32F10X|STM32F1|F1_TARGETS)' \
make src/main src/test .gitignore \
-g '!lib/main/STM32F1/**' || true
echo '== F1/F3 target variable assignments in base and head =='
for rev in "$base" HEAD; do
echo "-- $rev --"
git grep -nE '^[[:space:]]*(F1_TARGETS|F3_TARGETS)[[:space:]]*[:+?]?=' "$rev" -- make src/main src/test 2>/dev/null || true
done
echo '== All retained changed preprocessor directives, with file headers =='
git diff --unified=12 "$base...HEAD" -- src/main make src/test .gitignore \
| awk '
/^diff --git / { file=$4; sub("^b/", "", file); print "\n== " file " ==" }
/^[+-][[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif|else|endif)\b/ { print }
'
echo '== Diff statistics for retained files =='
git diff --stat "$base...HEAD" -- . ':(exclude)lib/main/STM32F1/**'Length of output: 130464 🏁 Script executed: #!/bin/bash
set -euo pipefail
base="035fff17b9f9f5336d5982689bb330faed72c7bb"
echo '== Changed preprocessor directives in retained source =='
git diff --unified=5 "$base...HEAD" -- src/main make src/test .gitignore \
| grep -E '^(diff --git|[+-][[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif|else|endif))' || true
echo '== Build-system diff =='
git diff --unified=25 "$base...HEAD" -- make/targets.mk make/source.mk make/mcu/STM32F1.mk src/test/Makefile .gitignore
echo '== Current references to removed STM32F1 files or directories =='
rg -n -C 2 'STM32F1/|stm32f1xx_hal_conf\.h|startup_stm32f10x|stm32_flash_f103|adc_stm32f10x|serial_uart_stm32f10x|system_stm32f10x|timer_stm32f10x' \
. -g '!lib/main/STM32F1/**' || true
echo '== Added or modified retained non-comment lines =='
git diff --unified=0 "$base...HEAD" -- src/main make src/test .gitignore \
| grep -E '^(diff --git|@@|[+][^+])' \
| grep -Ev '^[+][[:space:]]*(//|/\*|\*|\*/|$)' || true
echo '== STM32F3 VCP include/use paths =='
rg -n -C 3 '(hw_config\.h|platform_config\.h|usb_prop\.c|Virtual_Com_Port_init|STM32F303xC|STM32F37X)' \
src/main/vcp src/main -g '!src/main/vcp/hw_config.c' -g '!src/main/vcp/hw_config.h' -g '!src/main/vcp/platform_config.h' -g '!src/main/vcp/usb_prop.c' || trueLength of output: 55876
I verified the targeted areas:
I did not run builds or tests in this sandbox. Hardware verification remains the only stated pre-merge verification gap. You are interacting with an AI system. |
Five comment/doc sites still named the now-removed STM32F1/F103 platform after its code was purged from this branch. Reworded each to describe current (F3/F4/F7/H7) behavior accurately instead of contrasting against a platform with no remaining code path. Left src/main/drivers/serial_uart_stm32f30x.c's license-header attribution untouched (different category, not a technical description). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
AI Generated pull-request
Summary
STM32F1 has zero current EmuFlight build targets —
F1_TARGETSis referenced in threemakefile sites (
make/targets.mkx2,make/source.mk) but never assigned anywhere in thetree, and
src/main/build/version.calready carried#warning STM32F1 based targets are unsupported. Removes all STM32F1-conditional code, build machinery, and the F1-exclusivevendor library, resolving the STM32F1 half of #1365. STM32F3 is deferred to a separate
follow-up (confirmed equally dead —
F3_TARGETSis also never assigned — but out of scopehere).
4 commits:
src/maincore sources (platform.h, version.c, config_streamer.c, cli.c,msp_serial.h, fc/config.c, sensors/gyro.c, common_fc_pre.h, common_defaults_post.h,
vcp/vcpf4 F1 arms only —
vcp/itself is shared with STM32F3 and is not removed)src/main/drivers/surgical edits (~30 shared files, 65#if/#ifdefsites)make/mcu/STM32F1.mk; editmake/targets.mk,make/source.mk,src/test/Makefile,.gitignorelib/main/STM32F1/vendor library (44MB, 293 files), 4 F1-exclusivedrivers, 2 startup
.Sfiles, 4 linker scripts, 1 orphaned headerPlus a follow-up
docs:commit rewording 5 stale comment/doc sites that named the now-removedplatform, and a merge of
upstream/masterto stay current.Every
#if/#elif/#else/#endifchain touched was verified line-by-line to keep thesurviving F3/F4/F7/H7/SITL arms byte-equivalent. Notably:
drivers/bus_i2c_stm32f10x.cis untouched despite its name — it's a live F4 driver(
make/mcu/STM32F4.mk:170) with zero F1 macros inside it.timer.cTIM8 IRQ handler collapse keeps the branch F4/F7/H7/SITL already took(
TIM8_UP_IRQHandler) and drops only theSTM32F10X_XL-only alternative, avoiding aduplicate definition of
TIM8_UP_TIM13_IRQHandleron F4 targets.make/source.mktwo-line!F1guard removal is behaviorally inert:F1_TARGETSwasalways empty, so the guard always evaluated true; confirmed via byte-identical SITL
.elfsize before/after.
Test plan
make test— 42/42 unit test suites pass, identical toupstream/masterbaselinemake SITLand 13 representative bench/compile-only targets build clean locallyCCACHE_DISABLE=1rebuild — zero new warnings--dir make,--dir src) — 0 findings across all 59reviewable files
on 7 unsoldered F4/F7 boards: HELIOSPRING, FOXEERF405, FOXEERF722V4, PYRODRONEF7,
SKYSTARSF405AIO, TMOTORF7, TUNERCF405 — covers both
vcpf4/(F4) andvcp_hal/(F7)USB stacks plus IMU/sensor-init driver paths on real hardware.
unsoldered boards (USB + sensors-tab only, no motors/ESC/RX connected).
Follow-up: a pre-existing dead-code finding (
USE_UART1_RX_DMA/USE_UART1_TX_DMAconsumerblocks in
serial_uart_stm32f4xx.c/serial_uart_stm32f7xx.c/serial_uart_stm32f30x.c,already unreachable before this change) will be filed as a separate issue rather than folded
into this PR.