Mbed Studio padding J-Link serial number with leading zeros, breaks pyocd

Hi,

Mbed studio appears to be padding the Serial number of J-Link’s when attempting to run pyocd.

For example:

Mbed studio is calling:

pyocd flash --uid 000123145678 --target k64f --erase=chip

For a j-link with a SN of 12345678. pyocd will wait for that j-link to connect for ever, where as

pyocd flash --uid 123145678 --target k64f --erase=chip

Will work properly.

Is there a way to work around this?

Hi Kyle,

Thanks for the feedback, this is unexpected behaviour. Would you mind sharing your log file using the feedback link in mbed studio so we can investigate?

Kind regards,

Rob

Sent

I’m aware this is a but of a thread from the dead but was there a resolution? As I’ve just hit this very issue in Mbed studio 1.4.3. I’m running on Windows 10 for my sins.

I have worked around this by adding a quick ‘fix’ to
\Mbed Studio\mbed-studio-tools\python\Lib\site-packages\pyocd\core\helpers.py

I added:

        if unique_id is not None:
            unique_id = unique_id.lstrip('0')

at the start of ‘get_all_connected_probes’ and all comes to life.

1 Like

Hi Tom,

Actually, this is still an issue for me. I don’t see that path on either my Mac OS nor my Windows Mbed Studio installs. Can you potential elaborate on where that file is?

Hi Kyle, on my windows install it is:
C:\Users<user>\AppData\Local\Mbed Studio\mbed-studio-tools\python\Lib\site-packages\pyocd\core

Not sure about on Mac.

Got this working on my mac! Path is:
/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/core/helpers.py

Someone should probably make a pull request on pyocd to fix this. Do you want to do it?

Looking at the pyocd github page this is a known issue:
PyOCD incorrectly truncates device Serial Numbers starting with ‘0’ · Issue #917 · pyocd/pyOCD (github.com)

Maybe they need some prodding to address it. I am guessing not many people are using the jlink probes due to the cost. I’m only using it because we have a box of them left over from legacy projects that used IAR and Keil.