Skip to content

Enable semihosting for pyOCD for 'launch' configs#84

Merged
jreineckearm merged 6 commits into
mainfrom
pyocd-semihosting
Dec 17, 2025
Merged

Enable semihosting for pyOCD for 'launch' configs#84
jreineckearm merged 6 commits into
mainfrom
pyocd-semihosting

Conversation

@jreineckearm
Copy link
Copy Markdown
Collaborator

  • Adds -S to pyOCD launch configurations (single and multi-core) if telnet>mode setting exists and is different from off.
  • Note the implementation is copied from J-Link but without port which should be set via cbuild-run.yml. Could be further cleaned up but leaving as is due to limited time.

NOTE: Only did a quick test with a multicore launch config with CMSIS-DAP@pyOCD. Other variants need more testing before release.

…r off is set

Signed-off-by: Jens Reinecke <jens.reinecke@arm.com>
@RobertRostohar
Copy link
Copy Markdown
Collaborator

I have just slightly changed the order of command line options and used --semihosting instead of -S in order to easier understand the generated launch.json.

Tried it out and it seems to work except the following limitation.

In multi-core, the options will be enabled only if the core being launched has telnet enabled (regardless of the other core telnet settings). I'm not sure if this can be covered too.

In addition, the semihosting option should be added also to CMSIS Run task. I was not able to achieve this quickly. I'm lacking knowledge about the scripting and data available.

@jreineckearm
Copy link
Copy Markdown
Collaborator Author

I have just slightly changed the order of command line options and used --semihosting instead of -S in order to easier understand the generated launch.json.

👍

In multi-core, the options will be enabled only if the core being launched has telnet enabled (regardless of the other core telnet settings). I'm not sure if this can be covered too.

May need monitor commands to enable through GDB initCommands in attach config. That's at least how I added support for J-Link.

In addition, the semihosting option should be added also to CMSIS Run task. I was not able to achieve this quickly. I'm lacking knowledge about the scripting and data available.

a3a247c , please give it a try @RobertRostohar , it's untested

@RobertRostohar
Copy link
Copy Markdown
Collaborator

CMSIS Run does not look right. Seems to be broken:

        {
            "label": "CMSIS Run",
            "type": "shell",
            "command": "pyocd",
            "options": {
                "cwd": "<%= data.cwd %>",
                "shell": "<%= data.shell[process.platform] %>"
            },
            "args": [
                "gdbserver",
                "--probe",
                "stlink:",
                "<% if (config['probe-id']) { %>",
                "--uid",
                "<%= config['probe-id'] %>\n",
                "<% } %>",
                "--connect",
                "attach",
                "--persist",
                "--reset-run",
                "<% const telnetMode = data.telnetOptionsInput[pname ?? '']?.mode ?? data.telnetOptionsDefault.mode %>",
                "<% if (telnetMode && telnetMode !== 'off') { %>",
                "--semihosting",
                "<% } %>",
                "--cbuild-run",
                "${command:cmsis-csolution.getCbuildRunFile}",
                "--quiet",
                "--log",
                "*.cbuild_run,*server=info"
            ],
            "problemMatcher": []
        },

Signed-off-by: Jens Reinecke <jens.reinecke@arm.com>
@jreineckearm
Copy link
Copy Markdown
Collaborator Author

CMSIS Run does not look right. Seems to be broken:

Sorry, my bad. Used pname instead of start_pname for the run task. Please try again.

@RobertRostohar
Copy link
Copy Markdown
Collaborator

Seems to work now.

@ReinhardKeil
Copy link
Copy Markdown
Collaborator

@jreineckearm I suggest to use just the 'telnet' node to enable semihosting. When telnet is disabled, the telnet node does not exist. IMHO this is sufficient and should also cover the multi-core scenarios when one core as telnet off.

@RobertRostohar
Copy link
Copy Markdown
Collaborator

In the future, pyOCD will automatically enable semihosting when using telnet in cbuild-run.yml.

Therefore, the command line options are only a temporary solution for this release and will be soon removed.

@jreineckearm
Copy link
Copy Markdown
Collaborator Author

I am fine either way (will remove now for pyOCD). Will leave it in for J-Link though at the moment as I don't have time for re-testing that part before my holidays. I am more than certain that we'll touch these parts again when we have gained more experience with the feature in the field. So, will clean it up for 1.4.0.

Signed-off-by: Jens Reinecke <jens.reinecke@arm.com>
@jreineckearm
Copy link
Copy Markdown
Collaborator Author

Please try again: 83643f2

@RobertRostohar
Copy link
Copy Markdown
Collaborator

Seems to work as expected.

@jreineckearm jreineckearm merged commit f591a22 into main Dec 17, 2025
2 checks passed
@jreineckearm jreineckearm deleted the pyocd-semihosting branch December 17, 2025 07:56
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