Skip to content

edit stm32CubeProg.sh to be able to enter stlink serial number#116

Open
Bipoeman wants to merge 1 commit into
stm32duino:mainfrom
Bipoeman:select_stlink
Open

edit stm32CubeProg.sh to be able to enter stlink serial number#116
Bipoeman wants to merge 1 commit into
stm32duino:mainfrom
Bipoeman:select_stlink

Conversation

@Bipoeman

@Bipoeman Bipoeman commented Jul 7, 2026

Copy link
Copy Markdown

Pull Request template

Please, Make sure that your PR is not a duplicate.
Search among the Pull request before creating one.

IMPORTANT: Please review the [CONTRIBUTING.md] file for detailed contributing guidelines.

Thanks for submitting a pull request.
Please provide enough information so that others can review your pull request:

Summary

This PR updates the STM32CubeProgrammer flash script to support targeting specific programmers by their serial numbers during SWD operations, and adds support for the J-Link interface.

This PR fixes/implements the following bugs/features

  • Feature: Added -n / --serial-number CLI argument parsing.
  • Feature: Appended sn=${SERIAL_NUMBER} to the SWD connection string when the argument is provided.
  • Feature: Added jlink as a valid interface option (port=JLINK).
  • Breaking changes

Explain the motivation for making this change. What existing problem does the pull request solve?

When multiple ST-Link programmers or evaluation boards are connected to a single host machine, the STM32CubeProgrammer CLI requires a specific serial number to know which device to flash. Without this parameter, the script blindly connects to the first ST-Link it enumerates, which causes flashing failures or accidental overwrites in multi-device test/CI environments.

Additionally, this adds basic routing for the jlink protocol, allowing users using SEGGER J-Link probes to utilize the same script without needing a separate flashing utility.

Validation

  • Ensure CI build is passed.
  • Demonstrate the code is solid.
  • Local Testing: Ran the script on a Linux host with two ST-Link V2 probes connected. Ran ./flash.sh -i swd -f firmware.bin -n <serial_1> and verified only board 1 was flashed.
  • Verified getopt handles the new -n flag correctly on both GNU and BSD (macOS) variants.

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.

1 participant