Conversation
…ction - Add SWD/JTAG programming as alternative to serial bootloader methods - Support for debug probe discovery and management - Automated target chip selection using dynamic detection - Optional pyOCD dependency via `pyocd` extra - Replace hardcoded target mappings with dynamic API-based detection - Parse MCU info from `sys.implementation._machine` strings - Fuzzy matching algorithm for target selection - Direct probe-based target detection with fallback to fuzzy matching - Extensible architecture for future OpenOCD/J-Link support - Add `--method pyocd` option for explicit SWD/JTAG programming - Add `--probe-id` option for specific debug probe selection - Maintain existing serial bootloader behavior as default - Clean integration with existing flash method selection - Abstract debug probe layer for extensibility - Target detector abstraction with registry system - Proper error handling and fallback mechanisms - Performance optimized with caching and lazy loading - `mpflash/flash/debug_probe.py` - Debug probe abstraction layer - `mpflash/flash/pyocd_probe.py` - pyOCD-specific probe implementation - `mpflash/flash/pyocd_flash.py` - pyOCD flash programming interface - `mpflash/flash/pyocd_targets.py` - Target detection wrapper functions - `mpflash/flash/dynamic_targets.py` - Dynamic target detection engine - `mpflash/cli_pyocd.py` - pyOCD-specific CLI commands (future) - `mpflash/common.py` - Add FlashMethod enum for different programming methods - `mpflash/flash/__init__.py` - Integrate pyOCD into flash method selection - `mpflash/cli_flash.py` - Add CLI options for pyOCD method and probe selection - `pyproject.toml` - Add optional pyOCD dependency - `mpflash/cli_download.py` - Fix unused pytest import - **No hardware requirements change** - existing serial methods remain default - **Automated target selection** - no manual target configuration needed - **Extensible design** - easy to add OpenOCD, J-Link, etc. in future - **Performance optimized** - direct API calls instead of subprocess shells - **Maintainable** - eliminates hardcoded target mappings ```bash mpflash flash mpflash flash --method pyocd mpflash flash --method pyocd --probe-id stlink uv sync --extra pyocd ``` None - all existing functionality preserved with same default behavior.
- Updated test cases in `test_cli_integration.py` to replace `flash_list` with `flash_tasks` for flashing operations. - Adjusted mock setups and assertions accordingly to ensure correct behavior and parameter passing. - Improved test structure by consolidating mock patches and ensuring proper cleanup in setup and teardown methods. - Enhanced clarity in test descriptions and assertions to better reflect the expected outcomes. - Ensured consistent use of `create_worklist` in tests where applicable. - Refactored related tests to maintain functionality while improving readability and maintainability. Refactor probe management tests for clarity and consistency - Updated `test_probe_management.py` to improve import organization and mock usage. - Consolidated mock patches for better readability and reduced redundancy. - Enhanced test descriptions for clarity on the purpose of each test case. - Improved handling of mock return values and assertions to ensure accurate testing of probe discovery and flashing functionality. Refactor target detection tests for improved structure and clarity - Updated `test_target_detection.py` to enhance the organization of imports and mock usage. - Improved test descriptions and assertions for better clarity on expected outcomes. - Consolidated mock patches and ensured proper setup and teardown for target detection tests. - Enhanced handling of subprocess calls and error scenarios to ensure robustness in testing. Overall, these changes aim to improve the readability, maintainability, and reliability of the test suite while ensuring that all functionality remains intact. Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #67 +/- ##
==========================================
- Coverage 74.53% 70.51% -4.02%
==========================================
Files 54 58 +4
Lines 2929 3744 +815
Branches 464 602 +138
==========================================
+ Hits 2183 2640 +457
- Misses 620 965 +345
- Partials 126 139 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Owner
Author
|
@pi-anl , I have tried to bang this into shape - but cant really tests this as I don't have the hardware. Or is it worth testing part of this on other HW ? (not a PyOCD user yet) |
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
a947bae to
495088d
Compare
see: pyocd/libusb-package#28 Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
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.
this is a rebased version of #36 by Andrew.
pyOCD Integration
Add SWD/JTAG programming as alternative to usb bootloader methods
Optional pyOCD dependency via pyocd extra
Support for debug probe discovery and management
Automated target chip selection using dynamic detection