pyOCD icon indicating copy to clipboard operation
pyOCD copied to clipboard

Option `enable_semihosting` is not working

Open caspermeijn opened this issue 2 years ago • 3 comments

Thank you for this great project. I have been using it as part of the Zephyr project and it works great.

I am using ARM semihosting for my printf statements and for each debug session I type monitor arm semihosting enable. After getting sick of doing that I wanted to enable semihosting by default for my board. When looking at the pyOCD options documentation, I got the feeling that I needed to create the following config file to enable arm semihosting.

# Set to True to handle semihosting requests. Also see the semihost_console_type option. Default is False.
enable_semihosting: True

However with this config file the semihosting breakpoints were still not parsed. So I tried pyocd gdbserver -O enable_semihosting=true, which also didn't work. After trying lots of variations I finally found the following working command: pyocd gdbserver --semihosting.

My conclusion was that the options parsing doesn't work correctly for enable_semihosting.

caspermeijn avatar Dec 11 '21 08:12 caspermeijn

Hi @caspermeijn, thanks for the report. I'll try to reproduce and fix.

In fact, I've been writing some detailed documentation for semihosting, so it would be nice if what's documented actually works!

flit avatar Dec 11 '21 17:12 flit

Turns out the problem is that the -S / --semihosting command line argument, whether set or not, always overrides the enable_semihosting option's initial value from -O or config file. Only if set later via arm semihosting enable or set option enable_semihosting=1 will it take effect. (This bug affects several other options, too.)

I won't be able to get to it right away, but it's on the list now. Thanks!

flit avatar Dec 11 '21 20:12 flit

Good to hear you found the underlaying issue. Don't hurry for me, as I have my workaround using the --semihosting argument. Thanks for the quick response.

caspermeijn avatar Dec 14 '21 15:12 caspermeijn