Unable to flash nrf5340DK or custom board with SEGGER over SWD

I tried adapting the blinky sample project to work with a custom board. After an hour or two I was able to define the GPIOs of my schematic including I2C with the device tree visualizer in nrf Connect extension for VS Code.

I am able to build the project with the custom board successfully. Flashing the custom board sometimes succeeded but usually failed, and the "Connected Devices" tab in nRF Connect in VS Code successfully showed the nrf5340 device on the Ezurio module without failure.

I launched J-Link commander and noticed problems resetting the device at the default 4000kHz. I lowered this to 100kHz and it worked fine.

The issue seems to be that SWD at 4Mhz is too fast a SWD speed over my 6" ribbon cable.

Next I tried changing the board back to the nrf5340DK and flashing to the SWD connector directly. This also failed in the same manner.

I'm convinced that I cannot flash/debug at 4Mhz using my J-Link device and ribbon cable. It works fine using the built-in J-Link emulator on the nrf5340DK.

How can I override the SWD clock speed to flash/debug within VS Code's nRF Connect extension?

I have no problem modifying configuration files if that's the only way. I tried modifying runners.yaml to change the --clockspeed parameter but it seems that it's not getting passed through to nrfjprog.

How can I lower my SWD speed for flashing/debugging without abandoning nRF Connect?

-Thanks

-Brad

  • Note when I say

    Next I tried changing the board back to the nrf5340DK and flashing to the SWD connector directly. This also failed in the same manner.

    I mean I changed from using my physical board to the nrf5340DK physical board, I also updated the build configuration to reflect this as my board target.

    My point is, I cannot flash SWD to either the nrf5340DK using my Segger J-Link. Nor can I flash to my custom PCBA with the Ezurio nrf5340 module with the same Segger J-Link.

  • Hello,

    bradcb212 said:

    I mean I changed from using my physical board to the nrf5340DK physical board, I also updated the build configuration to reflect this as my board target.

    My point is, I cannot flash SWD to either the nrf5340DK using my Segger J-Link. Nor can I flash to my custom PCBA with the Ezurio nrf5340 module with the same Segger J-

    Have you tried communicating with your board via J-Link Commander? When you attempt to communicate using J-Link Commander, you need to specify the interface speed. How does that work?

    I am not sure if I fully understand your question. Are you asking whether it is possible to set the SWD speed in the nRF Connect VS Code extension by configuring the `launch.json` file? I am not certain if this can be done through the VS Code extension. If this is what you are asking, please let me know, and I will inquire with the VS Code team for further clarity.

    Kind Regards,

    Abhijith

  • I would appreciate the ability to vary SWD speeds.

    In the end, programming just started working. Maybe my IDC cable is less than perfect.

  • Hello,

    bradcb212 said:
    In the end, programming just started working. Maybe my IDC cable is less than perfect.

    Good to hear that it is working for you. Using a subpar IDC cable may lead to unreliable support for higher speeds, this could prevent you from increasing the SWD (Serial Wire Debug) speed during the flashing process, as SWD typically necessitates a high-quality cable to maintain higher speeds without errors.

    Kind Regards,

    Abhijith

Related