Arm Mbed OS support forum

Cannot use space characters in custom target debug flags

Steps to reproduce:

  • Mbed Studio 1.3.0 on Windows 10:
  • Open the “Manage Custom Targets” dialog box.
  • Choose a USB device and fill in the fields.
  • In the “Debug flags” field, manually enter a flag containing a space character, e.g. --pack followed by a path containing a space character.
  • Start the debugger.

Result in the Debug Console:

Selected port 50000 for debugging
usage: pyocd [-h] [-V] [–help-options] …
pyocd: error: unrecognized arguments: <portion of the path following the space character>
“GDB server stopped unexpectedly with exit code 2”

I’ve tried single- and double-quoting, escaping, %20, but nothing seems to be working.

However, if this field is not filled manually, but automatically after selecting a “Deploy and debug target”, then there is no issue, even though this field contains in this case a --pack c:\ProgramData\Mbed Studio\mbed-studio-tools\cmsis-packs\<something>.pack, so an instance of a flag with a space character, not even quoted. Actually, in this case, debugFlags is empty in custom_targets.json, so the displayed debug flags must come from the CMSIS pack.

There is also no way of specifying a custom CMSIS pack path in “Deploy and debug target”.

The only workaround is to edit custom_targets.json.

Hi Benoît,

thanks for raising this issue. We have confirmed this is a problem and are investigating a fix.

In the meantime, there are 2 workarounds which should work:

  • Use a path without spaces. Although not ideal, this should get you by

  • Modify the custom_targets.json directly and add a cmsisPack field

This last approach is a little more involved, but should allow spaces.
To do this, set up your custom target without modifying the debug flags and then edit the file at:

%AppData%/Mbed Studio/custom_targets.json

to look similar to:

    "9900000039914e45005290070000004d0000000097969906": {
        "name": "My Target",
        "target": "K64F",
        "debugTarget": "Dname from cmsis pack",
        "cmsisPack": "path to cmsis pack"

Kind regards,


Hi Rob,

Thanks. I had already tried these approaches, and they work. The only issue that I have with the 2nd one is that I need to combine two downloaded CMSIS packs (MCU + board, otherwise the debugger does not work), but I don’t think that cmsisPack can be an array instead of a single string (I have not tried, though).