Repository navigation
Conversation
Restrict fast ADCv2 and software knock starts to ADC_READY and ADC_ERROR, matching the vendored ChibiOS HAL contract. Use adcIsBufferComplete in ADCv2/ADCv4 callbacks and expose starts, completions, skipped requests and HAL errors through adc_stats. Add production-caller/HAL regression tests for ADCv2 and ADCv4 to CI. Validation: 36 ADCv2 and 21 ADCv4 tests under ASan/UBSan, 720 general tests, and Core8 F4 / Proteus F7 / Proteus H7 builds. Core8 USB sampling smoke completed with original firmware and configuration restored afterward. Refs FOME-Tech#586 and rusefi/rusefi#7710.
| working-directory: ./unit_tests/ | ||
| run: make -j4 COVERAGE=yes | ||
|
|
||
| - name: Run ADC lifecycle tests |
There was a problem hiding this comment.
shouldn't this run as part of the next step; Run Tests?
There was a problem hiding this comment.
Agreed. Updated in fbbc52d: the default build now produces all three test binaries, and Run Tests calls the common make test target, which runs fome_test, ADCv2 and ADCv4 in sequence and propagates any failure. The HAL-specific binaries remain separate. Removed the dedicated ADC CI step.
Validated with a clean coverage build and the common target: 720 engine + 36 ADCv2 + 21 ADCv4 tests pass.
Build all three host test binaries by default and run them through make test from the existing CI Run Tests step. Keep the ADC-only target available and update the local test instructions. Validation: clean coverage build; 720 engine, 36 ADCv2 and 21 ADCv4 tests pass.
Apply the H7 .ram4 section attribute only in production builds and mark the host fixture explicitly as non-production. Keep the 8192-byte buffer alignment on both targets. This fixes the ADCv4 build on macOS, where Mach-O requires segment,section syntax.
|
+1000 is too big. If we want this change, there will need to be some sort of break down. That said, is this a real issue? I've never seen it happen in real life. I'm not actually sure ADC conversions can fail unless your DMA controller or ADC is broken. |
| ## Unreleased | ||
|
|
||
| ### Added | ||
| - Add `adc_stats` console diagnostics for fast ADC and software knock: conversion starts, completed buffers, skipped starts by reason, and ADC errors. |
There was a problem hiding this comment.
this is not user facing, it doesn't belong here
|
My concern is a timing window in the HAL’s completion handling: a conversion can succeed, but starting another while the driver is still in ADC_COMPLETE violates adcStartConversionI()’s contract and can trigger a panic. This does not require faulty ADC or DMA hardware. FOME #586 describes the issue, and rusEFI #7710 applies the corresponding guard correction. I have not established its frequency on current FOME hardware. Even if uncommon, a firmware panic can interrupt engine control, so I think this warrants a proportionate fix. The knock scheduler can preempt ADC completion; the fast ADC guard is defensive with the current IRQ priorities. I have prepared a simpler revision that removes adc_stats, its console interface, and counters updated during normal acquisition. It retains only minimal anomaly events, reported through existing warnings outside interrupt context. That said, the revised PR still adds around 970 lines, so I recognise that simplifying the diagnostics does not fully address your concern about its size. Most of those lines support the test harness and regression tests. I would like to retain that coverage in CI to catch future regressions, while separating the infrastructure, guard correction, and warning reporting into independently reviewable commits. Would that approach address your concerns? I’m happy to push the revised version here if you agree. |
|
I've read through this, which part actually fixes the supposed bug? There isn't an obvious behavior change that I can see. |
Fixes #586.
The fast ADCv2 timer and software knock paths accept
ADC_COMPLETEbefore callingadcStartConversionI(), but the vendored ChibiOS HAL only permitsADC_READYorADC_ERROR. A start request during the completion callback can therefore hit the HAL’snot readyassertion, as reported in FOME #586.Restrict both guards to the permitted states and use
adcIsBufferComplete()in the ADCv2/ADCv4 completion callbacks. These changes follow rusEFI PR #7710, also referenced from the upstream panic report rusEFI #7662.Add
adc_statscounters for starts, completed buffers, skipped requests by reason, HAL errors and processed knock buffers. Counter updates use existing serialization; console output copies a snapshot under lock and formats it after unlocking. F4/F7 report individual conversion starts; H7 reports circular-stream starts.Validation
ADC_ACTIVEskips over approximately 168 seconds. Original firmware and configuration restored and verified afterward.The changes cover STM32 F4/F7 fast ADC and F4/F7/H7 software knock. Validation includes ADCv2/ADCv4 host tests and firmware builds for all three MCU families. On-device testing was performed on Core8. Physical testing of software knock and F7/H7 boards, plus prolonged load testing, remains pending.