Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Josverl/mpflash
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
Loading
...
head repository: Josverl/mpflash
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: pyocd_jv
Choose a head ref
Loading
Checking mergeability… Don’t worry, you can still create the pull request.
  • 18 commits
  • 21 files changed
  • 2 contributors

Commits on May 15, 2026

  1. Implement pyOCD SWD/JTAG programming support with dynamic target dete…

    …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.
    pi-anl authored and Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    d649da8 View commit details
    Browse the repository at this point in the history
  2. cli_flash: use ctx.exit() so exit codes propagate via Click

    cli_flash_board previously returned 0/1/2 from the callback, but Click
    ignores function return values for exit_code in standalone_mode, so the
    CLI always exited 0 even on flash failure or user cancellation.
    
    Switch to ctx.exit(N) so the documented exit codes (0 success, 1 flash
    failure, 2 user cancellation) actually reach the shell and CliRunner.
    
    Test adjustments:
    - tests/integration/test_cli_integration.py:
      * Remove xfail from test_flash_failure_handling and
        test_interactive_parameter_prompting now that exit codes propagate.
      * test_flash_failure_handling now asserts on mock calls instead of
        loguru log output, which is order-dependent across the full suite.
    - tests/cli/test_cli_flash.py:
      * test_mpflash_connected_comports: when serial ports are detected the
        test expects success, so make flash_tasks return a non-empty list
        and stub show_mcus to keep the success path quiet.
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    9610d5c View commit details
    Browse the repository at this point in the history
  3. test_cli_integration: assert on mock calls instead of log output

    test_complete_pyocd_workflow_success previously asserted on the loguru
    log message 'Flashed 1 boards' reaching result.output, which is fragile
    because loguru handler configuration can change across tests run earlier
    in the suite. The test passed in isolation but failed in full-suite runs.
    
    Replace the log-output assertion with assertions on the show_mcus mock:
    the mock must have been called once, with the boards returned by
    flash_tasks. This verifies the same code path without depending on
    loguru capture.
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    f82749f View commit details
    Browse the repository at this point in the history
  4. test_probe_management: fix TestFlashPyOCDFunction patch targets

    The flash_pyocd() implementation in mpflash/flash/pyocd_flash.py imports
    is_pyocd_supported and get_unsupported_reason from pyocd_core (not the
    _from_mcu variants), and probe selection happens inside PyOCDFlash, not
    via find_probe_for_target / get_pyocd_target_from_mcu. The previous tests
    patched names that do not exist on the pyocd_flash module, so the class
    was xfailed.
    
    Rewrite the three tests to:
    - patch mpflash.flash.pyocd_flash.is_pyocd_supported
    - patch mpflash.flash.pyocd_flash.get_unsupported_reason
    - assert PyOCDFlash is constructed with probe_id / auto_install_packs
    - simulate 'no probe' by having PyOCDFlash.flash_firmware raise the same
      MPFlashError the real code raises (probe lookup is internal to it now)
    
    Remove the @pytest.mark.xfail marker on TestFlashPyOCDFunction.
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    914dbc0 View commit details
    Browse the repository at this point in the history
  5. test_probe_management: rewrite TestPyOCDFlash against the real API

    PyOCDFlash.__init__ calls detect_pyocd_target() and is_pyocd_available()
    (imported from pyocd_core) and stores the resulting target on
    self.target_type. PyOCDFlash.flash_firmware() looks up the probe via
    find_pyocd_probe() (defined in pyocd_flash itself), then calls
    probe.program_flash(fw, target_type, **options).
    
    The previous tests patched is_debug_programming_available,
    get_pyocd_target_dynamic and find_debug_probe on pyocd_flash, none of
    which exist there, so the whole class was xfailed.
    
    Rewrite all six tests to patch the correct names on the pyocd_flash
    module and to give Mock(spec=PyOCDProbe) a description attribute so the
    debug log line in flash_firmware does not blow up. Remove the
    @pytest.mark.xfail marker on TestPyOCDFlash.
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    18b4d86 View commit details
    Browse the repository at this point in the history
  6. feat: use python-dotenv for environment variable management

    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    78e3e33 View commit details
    Browse the repository at this point in the history
  7. chore: dependencies: --all-extras

    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    2ede53a View commit details
    Browse the repository at this point in the history
  8. feat: Add warning for missing libusb backend on Windows+Latest Python

    see: pyocd/libusb-package#28
    
    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    af41b12 View commit details
    Browse the repository at this point in the history
  9. tests: Enhance test fixtures for non-interactive defaults

    - avoid hardcoded tempfile
    
    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    4c18da8 View commit details
    Browse the repository at this point in the history
  10. CI: Skip pyocd on 3.14 due to libusb

    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    48cdb59 View commit details
    Browse the repository at this point in the history
  11. test: handle CI runners having no physical serial ports.

    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    6bc3b12 View commit details
    Browse the repository at this point in the history
  12. feat: Add handling for known dependency issues with pyOCD on Python 3…

    ….14+
    
    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 15, 2026
    Configuration menu
    Copy the full SHA
    f5e0760 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2026

  1. fix: py 3.14 libusb dependencies

    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 16, 2026
    Configuration menu
    Copy the full SHA
    a65baf1 View commit details
    Browse the repository at this point in the history
  2. fix: adjust dependency installation for Python 3.14 compatibility

    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 16, 2026
    Configuration menu
    Copy the full SHA
    4b0e494 View commit details
    Browse the repository at this point in the history
  3. fix: comment out known dependency issue for Python 3.14 libusb

    This should not be needed if the fallback version works good enough
    
    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 16, 2026
    Configuration menu
    Copy the full SHA
    d634746 View commit details
    Browse the repository at this point in the history
  4. stm32: also download .hex binaries.

    They can be used by pyOCD flashing
    
    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 16, 2026
    Configuration menu
    Copy the full SHA
    df95172 View commit details
    Browse the repository at this point in the history
  5. Fix SWD flash and reset.

    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 16, 2026
    Configuration menu
    Copy the full SHA
    317b733 View commit details
    Browse the repository at this point in the history
  6. chore: format code

    Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
    Josverl committed May 16, 2026
    Configuration menu
    Copy the full SHA
    10a902f View commit details
    Browse the repository at this point in the history
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.