Skip to content

Conversation

@hkpeprah
Copy link
Contributor

@hkpeprah hkpeprah commented Jul 31, 2025

[ISSUE-242] Un-conditionally Halt the CPU

Overview

In rare instances, the call to .halted() fails, resulting in .halt() not being called, which can lead to un-expected behaviour when attempting to flash or erase a target as the CPU may still be running. This patch addresses that by removing the .halted() check to ensure that .halt() is called un-conditionally.

In some instances, `.halt()` not being called can lead to un-expected behaviour
when attempting to flash or erase a target as the CPU may still be running.
This patch addresses that by removing the `.halted()` check to ensure that
`.halt()` is called un-conditionally.
@hkpeprah hkpeprah requested review from bbrown1867 and Copilot July 31, 2025 14:01
@hkpeprah hkpeprah self-assigned this Jul 31, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes conditional halting checks to ensure the CPU is always halted before erase and flash operations. The change addresses rare instances where the .halted() check fails, preventing the .halt() call and potentially causing unexpected behavior during target operations.

Key changes:

  • Removes .halted() conditional checks before calling .halt() in erase, flash, and flash_file methods
  • Updates test cases to reflect the new unconditional halt behavior
  • Simplifies the halt logic while maintaining exception handling

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pylink/jlink.py Removes conditional .halted() checks and calls .halt() unconditionally in erase, flash, and flash_file methods
tests/unit/test_jlink.py Updates test mocks and assertions to reflect unconditional halt behavior, removes halted-related test scenarios


# Halted exception
self.jlink.halted.side_effect = JLinkException(-1)
# Halt exception
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment should be "# Halt exception" to match the change from halted to halt, but it should be more descriptive. Consider "# Test halt exception handling" for clarity.

Suggested change
# Halt exception
# Test halt exception handling

Copilot uses AI. Check for mistakes.

# Halted
self.jlink.halted.return_value = True
# Halt exception
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment should be more descriptive. Consider "# Test halt exception handling" for clarity.

Suggested change
# Halt exception
# Test halt exception handling during flash_file execution

Copilot uses AI. Check for mistakes.
@hkpeprah hkpeprah merged commit 6a00172 into master Aug 5, 2025
5 checks passed
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.

3 participants