Skip to content

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

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

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

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

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.

@fpistm

fpistm commented Jul 21, 2026

Copy link
Copy Markdown
Member

Hi @Bipoeman
Thanks for the PR, I'm currently working on the script and will integrate your PR (probably in a different way).
Anyway don't see any stuff related to jlink as it is already supported by the script.

@fpistm fpistm added the enhancement New feature or request label Jul 21, 2026
@fpistm

fpistm commented Jul 21, 2026

Copy link
Copy Markdown
Member

Superseded by #119

@fpistm fpistm closed this Jul 21, 2026
@fpistm fpistm added the duplicate This issue or pull request already exists label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants