Skip to content

chore: issue 57 remove duplicated components - #58

Merged
gabrielfrasantos merged 11 commits into
mainfrom
feat/issue-57-remove-duplicated-components
Aug 28, 2026
Merged

chore: issue 57 remove duplicated components#58
gabrielfrasantos merged 11 commits into
mainfrom
feat/issue-57-remove-duplicated-components

Conversation

@gabrielfrasantos

Copy link
Copy Markdown
Contributor

No description provided.

gabrielfrasantos and others added 9 commits August 25, 2026 14:02
Bump the emil pin to 321a369d (embedded-pro/embedded-infra-lib#95, "generic
Cortex-M layer") and link hal.cortex_m instead of hal_st's own copy of
InterruptCortex.hpp/cpp, across all 32 drivers that use InterruptHandler/
InterruptTable/DispatchedInterruptHandler/ImmediateInterruptHandler/
InterruptPriority/ActiveInterrupt (now hal::cortex::*).

hal.cortex_m also brings FaultTracer, whose weak HardFault_Handler etc.
collide with the vendor startup files' ".thumb_set HardFault_Handler,
Default_Handler" alias. halst_target_bringup() now forces the link order
of hal.cortex_m, hal_st.bringup, and hal.cortex_m.runtime explicitly so
FaultTracer wins deterministically instead of by linker luck, and reuses
emil's abort()/_sbrk instead of hal-st's own (removing another duplicate;
_sbrk needs the `end` linker symbol, added to sections.ld).

hal_st/cortex and hal_st/default_init are gone. What's left of the latter
(Default_Handler_Forwarded, HAL_InitTick, __assert_func, assert_failed) has
no emil equivalent -- it's ST HAL bring-up glue, not portable -- so it moves
to hal_st/bringup/, named after emil's own term for this category of code.
DataWatchpointAndTrace, the other tenant of the old cortex/ folder, moves to
its own hal_st/dwt/ since nothing else needs it.

Verified by direct arm-none-eabi-g++/ld compilation and linking against the
real emil source (the full stm32g431 CMake preset needs a packaged host
build this environment can't produce in reasonable time): all edited
drivers compile clean, and `-Wl,-y` traces confirm HardFault_Handler,
abort, _init, _sbrk, and assert_failed each resolve to exactly the intended
definition with no multiple-definition conflicts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…settings.json)

Ignore .claude/scheduled_tasks.lock, which is session-local runtime state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
hal.cortex_m.runtime (Atomic/DefaultInit/SysCallStubs) contains ARM-only
inline assembly (mrs/cpsid/msr, bkpt). Forcing EMIL_BUILD_CORTEX_M on
unconditionally pulled it into the host x86_64 build too, since
TARGET_MCU_VENDOR is only "st" for the stm32* cross-compile presets and
unset for "host" -- CI failed assembling those instructions for the host
toolchain. Gate the flag on TARGET_MCU_VENDOR so it's only forced on when
actually cross-compiling for ST.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
DataWatchPointAndTrace has been contributed upstream to
embedded-infra-lib (emil); hal_st no longer needs its own copy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
.claude was added for Claude Code project config but fails the
snake_case .dir rule.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…Tick/TracingReset/TimeKeeperGeneric

Prerequisite for #57: the previously pinned EMIL commit doesn't yet
have hal/cortex_m/SystemTick(TimerService), services/tracer/TracingReset,
or hal/generic/TimeKeeperGeneric.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- TracingResetStm: pure wrapper around services::TracingReset(hal::ResetStm&,
  Tracer&), which already exists identically in EMIL. Per the issue, the
  application should construct it directly instead.
- SystemTickStm: unused internally; superseded by hal::cortex::SystemTick.
- TimeKeeperStm (TimeKeeperSt): a pass-through to SystemTickTimerService::Now()
  with no ST-specific behavior; superseded by hal::TimeKeeperGeneric, which
  resolves via the same default systemTimerServiceId.
- SystemTickTimerService: kept (load-bearing for StmEventInfrastructure,
  and still holds the ST-specific HAL_GetTick() bridge and sub-tick-precision
  Now() that EMIL's cortex_m version doesn't provide), but its raw SysTick
  register programming is now delegated to hal::cortex::SystemTick instead
  of duplicating it inline.

Verified with a full stm32g431 cross-build (hal_st.stm32fxxx,
hal_st.synchronous_stm32fxxx, hal_st.instantiations) against the newly
fetched EMIL commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Identical behavior (NVIC_SystemReset() vs. hal::cortex::Reset writing
the same AIRCR reset key/bit directly) with no STM32-specific logic.
Already orphaned: its only caller, TracingResetStm, was removed
earlier in this branch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 28, 2026 09:01
…duplicated-components

# Conflicts:
#	CMakeLists.txt
#	hal_st/stm32fxxx/SystemTickStm.hpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes duplicated Cortex-M interrupt/startup/reset utilities from hal_st and switches the STM32 drivers/examples to use the hal.cortex_m implementation from embedded-infra-lib, introducing a hal_st.bringup helper target to provide startup glue and deterministic weak-handler ordering.

Changes:

  • Replace hal_st.cortex usage with hal.cortex_m across STM32 drivers, instantiations, examples, and integration tests.
  • Remove duplicated components (InterruptCortex, SystemTickStm, ResetStm, TimeKeeperStm, default_init) and add hal_st/bringup to link required runtime/startup objects.
  • Update standalone dependency pin for embedded-infra-lib and enable Cortex-M build only for ST cross-compiles; add end symbol in linker script for compatibility.

Reviewed changes

Copilot reviewed 63 out of 64 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
st/ldscripts/sections.ld Expose additional linker symbol (end) at end of .noinit.
integration_test/tester/CMakeLists.txt Switch tester target from default init to bringup.
integration_test/tested/CMakeLists.txt Switch tested target from default init to bringup.
hal_st/synchronous_stm32fxxx/TimeKeeperStm.hpp Remove duplicated TimeKeeper implementation.
hal_st/synchronous_stm32fxxx/TimeKeeperStm.cpp Remove duplicated TimeKeeper implementation.
hal_st/synchronous_stm32fxxx/SynchronousUartStm.hpp Update interrupt handler include/namespace.
hal_st/synchronous_stm32fxxx/CMakeLists.txt Drop removed TimeKeeper sources from target.
hal_st/stm32fxxx/WatchDogStm.hpp Switch to hal.cortex_m interrupt types.
hal_st/stm32fxxx/UsbHostLinkLayerStm.hpp Switch to hal.cortex_m interrupt types/priority enum.
hal_st/stm32fxxx/UartStmDuplexDma.hpp Adjust comment/type references for new interrupt namespace.
hal_st/stm32fxxx/UartStm.hpp Switch to hal.cortex_m interrupt types/priority enum.
hal_st/stm32fxxx/TimerStm.hpp Switch to hal.cortex_m interrupt types.
hal_st/stm32fxxx/TamperStm.hpp Switch to hal.cortex_m interrupt types.
hal_st/stm32fxxx/SystemTickTimerService.hpp Switch to hal.cortex_m interrupt base class.
hal_st/stm32fxxx/SystemTickTimerService.cpp Replace direct SysTick register writes with cortex::SystemTick.
hal_st/stm32fxxx/SystemTickStm.hpp Remove duplicated SysTick wrapper.
hal_st/stm32fxxx/SystemTickStm.cpp Remove duplicated SysTick wrapper.
hal_st/stm32fxxx/SpiMasterStm.hpp Switch to hal.cortex_m interrupt types.
hal_st/stm32fxxx/ResetStm.hpp Remove duplicated Reset implementation.
hal_st/stm32fxxx/ResetStm.cpp Remove duplicated Reset implementation.
hal_st/stm32fxxx/RandomDataGeneratorStm.hpp Switch to hal.cortex_m interrupt base class.
hal_st/stm32fxxx/QuadSpiStmDma.hpp Switch to hal.cortex_m dispatched interrupt handler.
hal_st/stm32fxxx/PkaStm.hpp Switch base interrupt handler to hal.cortex_m.
hal_st/stm32fxxx/PkaStm.cpp Update base-class constructor qualification for new namespace.
hal_st/stm32fxxx/LpTimerStm.hpp Switch to hal.cortex_m interrupt types.
hal_st/stm32fxxx/I2cStm.hpp Switch to hal.cortex_m interrupt types.
hal_st/stm32fxxx/GpioStm.hpp Switch to hal.cortex_m interrupt types (multiple handlers).
hal_st/stm32fxxx/GpioStm.cpp Update include to hal.cortex_m.
hal_st/stm32fxxx/FlashInternalStmBle.hpp Switch to hal.cortex_m interrupt types.
hal_st/stm32fxxx/FlashInternalHighCycleAreaStm.hpp Switch to hal.cortex_m interrupt types.
hal_st/stm32fxxx/EthernetMacStm.hpp Switch to hal.cortex_m dispatched interrupt handler.
hal_st/stm32fxxx/DmaStm.hpp Switch variants/handles to hal.cortex_m interrupt types.
hal_st/stm32fxxx/DmaStm.cpp Update in-place variant/std::get types for new namespace.
hal_st/stm32fxxx/CMakeLists.txt Link STM32 driver lib against hal.cortex_m; drop removed sources.
hal_st/stm32fxxx/CanStm.hpp Switch to hal.cortex_m dispatched interrupt handlers.
hal_st/stm32fxxx/AnalogToDigitalPinStm.hpp Switch to hal.cortex_m dispatched interrupt handler.
hal_st/stm32fxxx/AnalogToDigitalPinStm.cpp Update include to hal.cortex_m.
hal_st/instantiations/TracingResetStm.hpp Remove instantiation that depended on removed ResetStm.
hal_st/instantiations/TracingResetStm.cpp Remove instantiation that depended on removed ResetStm.
hal_st/instantiations/StmEventInfrastructure.hpp Update interrupt table type to hal::cortex::InterruptTable.
hal_st/instantiations/CMakeLists.txt Drop removed TracingReset sources from target.
hal_st/default_init/DefaultInit.cpp Remove duplicated runtime/syscall/assert/startup glue.
hal_st/default_init/CMakeLists.txt Remove hal_st.default_init target and helper function.
hal_st/default_init/Atomic.cpp Remove duplicated __atomic_* shims (now provided elsewhere).
hal_st/cortex/InterruptCortex.hpp Remove duplicated Cortex interrupt abstraction.
hal_st/cortex/InterruptCortex.cpp Remove duplicated Cortex interrupt abstraction.
hal_st/cortex/DataWatchpointAndTrace.hpp Remove duplicated DWT wrapper.
hal_st/cortex/DataWatchpointAndTrace.cpp Remove duplicated DWT wrapper.
hal_st/cortex/CMakeLists.txt Remove hal_st.cortex library target.
hal_st/CMakeLists.txt Replace cortex/default_init subdirs with bringup.
hal_st/bringup/CMakeLists.txt Add bringup target and halst_target_bringup() helper with link-order rationale.
hal_st/bringup/Bringup.cpp Add startup glue (HAL_InitTick, Default_Handler_Forwarded).
hal_st/bringup/Assert.cpp Add assert hooks forwarding to std::abort().
examples/sesame/CMakeLists.txt Switch example target from default init to bringup.
examples/helloworld/CMakeLists.txt Switch example targets from default init to bringup.
examples/freertos/Main.cpp Update interrupt table type to hal::cortex::InterruptTable.
examples/freertos/CMakeLists.txt Switch example target from default init to bringup.
examples/blink/CMakeLists.txt Switch example targets from default init to bringup.
CMakeLists.txt Update embedded-infra-lib commit; enable Cortex-M components only for ST cross-compiles.
CLAUDE.md Add pointer document to canonical agent rules.
AGENTS.md Add canonical agent rules (style/constraints/build presets).
.ls-lint.yml Ignore .claude directory in ls-lint.
.gitignore Ignore .claude/scheduled_tasks.lock.
.claude/settings.json Add agent permissions configuration (Bash allow-list).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread hal_st/stm32fxxx/UartStmDuplexDma.hpp Outdated
Comment thread examples/blink/CMakeLists.txt
Comment thread .claude/settings.json
…estating comment

Addresses PR #58 review comments:
- README still documented the removed halst_target_default_init() CMake
  function; the bringup rework renamed it to halst_target_bringup().
- UartStmDuplexDma.hpp had a comment restating the overridden interface
  with no non-obvious "why", against repo comment style.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gabrielfrasantos

Copy link
Copy Markdown
Contributor Author

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ ACTION actionlint 5 0 0 0.06s
✅ CPP clang-format 15 6 0 0 1.39s
✅ CPP cppcheck 15 0 0 0.22s
✅ DOCKERFILE hadolint 1 0 0 0.04s
✅ JSON jsonlint 8 0 0 0.11s
✅ JSON prettier 8 3 0 0 1.59s
⚠️ MARKDOWN markdownlint 14 1 20 0 1.91s
✅ MARKDOWN markdown-table-formatter 14 1 0 0 1.2s
✅ REPOSITORY betterleaks yes no no 0.85s
✅ REPOSITORY checkov yes no no 19.02s
✅ REPOSITORY git_diff yes no no 1.24s
✅ REPOSITORY grype yes no no 66.73s
✅ REPOSITORY ls-lint yes no no 0.01s
✅ REPOSITORY osv-scanner yes no no 0.97s
✅ REPOSITORY secretlint yes no no 6.06s
✅ REPOSITORY syft yes no no 1.86s
✅ REPOSITORY trivy yes no no 10.96s
✅ REPOSITORY trivy-sbom yes no no 0.43s
✅ REPOSITORY trufflehog yes no no 3.46s
⚠️ SPELL lychee 41 6 0 23.44s
✅ YAML prettier 8 1 0 0 1.99s
✅ YAML v8r 8 0 0 4.81s
✅ YAML yamllint 8 0 0 0.52s

Detailed Issues

⚠️ SPELL / lychee - 6 errors
📝 Summary
---------------------
🔍 Total..........263
🔗 Unique.........243
✅ Successful.....252
⏳ Timeouts.........0
🔀 Redirected.....111
👻 Excluded.........5
❓ Unknown..........0
🚫 Errors...........6
⛔ Unsupported......6

Errors in .github/agents/orchestrator.agent.md
[ERROR] file://.github/copilot-instructions.md (at 52:23) | File not found. Check if file exists and path is correct
[ERROR] file://hal_st/cortex/InterruptCortex.hpp (at 56:22) | File not found. Check if file exists and path is correct

Errors in .github/ISSUE_TEMPLATE/add-or-update-hal-driver.md
[ERROR] http://mcd.rou.st.com/modules.php?name=mcu (at 28:63) | Connection failed. Check network connectivity and firewall settings

Errors in CHANGELOG.md
[502] https://github.com/philips-software/amp-hal-st/commit/da44299e5c1354578329ce6d6a01bd31a1a348b6 (at 54:98) | Rejected status code: 502 Bad Gateway

Errors in README.md
[404] https://api.securityscorecards.dev/projects/github.com/embedded-pro/hal-st (at 3:199) | Rejected status code: 404 Not Found
[ERROR] https://st.com/ (at 5:93) | HTTP/2 protocol error. Server may not support HTTP/2 properly | Followed 1 redirect. Redirects: https://st.com/ --[301]--> https://www.st.com/

Hint: Followed 111 redirects. You might want to consider replacing redirecting URLs with the resolved URLs. Use verbose mode (`-v`/`-vv`) to see redirection details.
Hint: You can configure accepted/rejected response codes with `-a` or `--accept`
⚠️ MARKDOWN / markdownlint - 20 errors
.github/agents/executor.agent.md:11 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the executor agent for..."]
.github/agents/orchestrator.agent.md:18:401 error MD013/line-length Line length [Expected: 400; Actual: 420]
.github/agents/orchestrator.agent.md:18 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the orchestrator agent..."]
.github/agents/planner.agent.md:11 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the planner agent for ..."]
.github/agents/planner.agent.md:39 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
.github/agents/reviewer.agent.md:14 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "You are the reviewer agent for..."]
.github/agents/reviewer.agent.md:122 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
.github/instructions/hal-st-cpp.instructions.md:18 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
.github/ISSUE_TEMPLATE/add-or-update-hal-driver.md:10 error MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "How to import a HAL driver"]
.github/prompts/orchestrate.prompt.md:8 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "Start a new development workfl..."]
CHANGELOG.md:83 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "⚠ BREAKING CHANGES"]
CHANGELOG.md:87 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:94 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Bug Fixes"]
CHANGELOG.md:103 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:122 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Bug Fixes"]
CHANGELOG.md:140 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "⚠ BREAKING CHANGES"]
CHANGELOG.md:144 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:151 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Features"]
CHANGELOG.md:162 error MD024/no-duplicate-heading Multiple headings with the same content [Context: "Bug Fixes"]
CLAUDE.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "hal-st — Claude Instructions"]

Notices

⚠️ Your configuration references items that have been removed from MegaLinter and are ignored: REPOSITORY_GITLEAKS, REPOSITORY_KICS. See Removed linters to find their replacements.

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@10.0.0 --custom-flavor-setup --custom-flavor-linters ACTION_ACTIONLINT,CPP_CPPCHECK,CPP_CLANG_FORMAT,DOCKERFILE_HADOLINT,JSON_JSONLINT,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_BETTERLEAKS,REPOSITORY_GRYPE,REPOSITORY_LS_LINT,REPOSITORY_OSV_SCANNER,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,SPELL_LYCHEE,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

@gabrielfrasantos
gabrielfrasantos merged commit 832130b into main Aug 28, 2026
14 checks passed
@gabrielfrasantos
gabrielfrasantos deleted the feat/issue-57-remove-duplicated-components branch August 28, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants