Fix ETH RX HardFault and KSEM scale factor#6
Merged
flottokarotto merged 1 commit intomasterfrom Feb 20, 2026
Merged
Conversation
Remove SCB_InvalidateDCache_by_Addr call in HAL_ETH_RxLinkCallback —
D-Cache is not enabled in this project, and calling cache maintenance
operations with D-Cache disabled causes IMPRECISERR HardFault on
Cortex-M7. Also remove incorrect ACTLR.DISDEFWBUF write (M3/M4 bit
layout, not valid on Cortex-M7).
Fix KSEM power readings by handling arbitrary SunSpec scale factors
(10^SF) instead of only SF ∈ {-1, 0, 1}. The KSEM dynamically changes
W_SF (e.g. to -2) based on value magnitude, which previously caused
100× inflated readings.
Closes #5
There was a problem hiding this comment.
Pull request overview
This PR fixes two critical bugs in the NUCLEO-H753 KSEM test example: a HardFault crash in Ethernet RX processing and incorrect power readings from the KSEM energy meter due to improper scale factor handling.
Changes:
- Remove harmful D-Cache invalidation call in ETH RX callback that caused IMPRECISERR HardFault when D-Cache is disabled
- Remove incorrect ACTLR register manipulation using Cortex-M3/M4 bit patterns on Cortex-M7 hardware
- Replace hardcoded scale factor handling with full SunSpec 10^SF implementation to support arbitrary scale factors
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| examples/embedded/nucleo_h753_ksem_test/src/ksem_client.adb | Implements proper SunSpec scale factor handling using 10^SF formula with loops, replacing hardcoded support for only SF ∈ {-1, 0, 1} |
| examples/embedded/nucleo_h753_ksem_test/lwip_port/ethernetif.c | Removes SCB_InvalidateDCache_by_Addr call that caused HardFault when D-Cache disabled, and removes incorrect ACTLR.DISDEFWBUF write for Cortex-M7 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
SCB_InvalidateDCache_by_Addr()inHAL_ETH_RxLinkCallback— causes IMPRECISERR on Cortex-M7 when D-Cache is not enabled. Also remove incorrect ACTLR.DISDEFWBUF write (Cortex-M3/M4 bit layout, not valid on M7).Test plan
Closes #5
🤖 Generated with Claude Code