Arm Mbed OS support forum

Mbed Studio hangs on "Erasing" with J-Link EDU

I’m trying out Mbed Studio for the first time. It’s a Windows 10 machine with Mbed Studio 1.4.1 and Mbed OS 6.11.0. I’m trying to flash the simply Blinky example to a custom nRF52 board using a J-Link EDU.

The short story is that Mbed Studio hangs with an “Erasing…” message. I am confident that my connections to the J-Link and the nRF52 board are good as I get successful flashes through Keil as well as through VS Code with the PlatformIO plugin installed. I’ve swapped back and forth between Mbed Studio and Keil to ensure flashing is still working.

When I first ran Mbed Studio with the J-Link connected, there was a pop-up stating that the device could not be automatically configured and would I like to do it manually. (This was surprising given that it’s a standard J-Link device.)

The manual setup is configured with a build target of “Nordic nRF52-DK” (the same as I use in Keil and VS Code), debug flags are set to --target nrf52 --erase=chip, and I’ve tried the “Deploy and debug target” as both “nrf52 (Native)” and “nRF52832_xxAA”.

If anyone has suggestions as to what to look at next, I would appreciate it. Thanks!

1 Like

Hello,

I hope information from this discussion, please see below, will help you to solve or understand to this problem.

BR, Jan

It does explain the problem, so thank you for that.

Unfortunately, though, it doesn’t help solve it. I’m using Mbed Studio 1.4.1 and that post refers to 1.4.0 having a potential fix.

For me it seems to be that MBED studio adds zeroes before the uid and that makes it hang:

[2021-06-05T14:31:40.550] [INFO] root/mbs-deploy - flash --uid 000682112252 --target nrf52 --erase=chip /home/tjheiska/Mbed Programs/mbed-os-example-ble/BLE_GattServer_CharacteristicWrite/BUILD/NRF52_DK/ARMC6/BLE_GattServer_CharacteristicWrite.hex []
[2021-06-05T14:31:40.551] [DEBUG] root/process - Starting raw process: /home/tjheiska/.config/Mbed Studio/mbed-studio-tools/python/bin/pyocd, with args: flash --uid 000682112252 --target nrf52 --erase=chip /home/tjheiska/Mbed Programs/mbed-os-example-ble/BLE_GattServer_CharacteristicWrite/BUILD/NRF52_DK/ARMC6/BLE_GattServer_CharacteristicWrite.hex,  with options: {"cwd":"/home/tjheiska/.config/Mbed Studio/mbed-studio-tools/python/bin"} []
[2021-06-05T14:31:41.879] [INFO] root/mbs-deploy - Waiting for a debug probe matching unique ID '000682112252' to be connected...

pyocd list output

  #   Probe                                    Unique ID  
----------------------------------------------------------
  0   Segger J-Link OB-SAM3U128-V2-NordicSem   682112252  
1 Like

@ctpearson If you haven’t tried putting your J-Link into CMSIS-DAP mode yet, try it.
Putting this up for everyone’s reference. I’ve also included info for those with the nRF52840-DK dev board.

I had the same issue - hang during erase step - with an nRF52840-DK, in both Mbed Studio 1.4.1 and mbed-tools CLI v2. Because I primarily use SEGGER Embedded Studio, the onboard J-Link was running stock J-Link firmware.

mbed-tools, hence Mbed Studio, require the J-Link to be running CMSIS-DAP firmware. They won’t work in “J-Link mode.”

I don’t own a standalone J-Link, but it appears you can switch it into CMSIS-DAP mode as follows:

For those with the Nordic dev board: the nRF52840-DK has an onboard J-Link OB, which is a cost-reduced version. It must be flashed manually between J-Link and CMSIS-DAP modes. Note that it is possible to flash it back into J-Link mode, but the link for the .bin file is not in a proper download gallery, rather an attachment on Nordic’s forums. Knowing how links may go bad, make sure you have that .bin file before trying this, so you can always reflash back. That said, here’s how to convert your Nordic dev board; I tested it and can now flash from Mbed’s toolchain:

  • Download the CMSIS-DAP firmware for the nRF52840-DK’s onboard J-Link OB here.
  • Switch off the nRF52840-DK. While holding down the IF BOOT/RESET pushbutton, turn on the board. Release the button.
  • The board’s J-Link OB will boot into bootloader mode and should mount a drive on your computer. Drag the firmware .bin file onto this drive and allow it to flash (approx 5 seconds). LED5 will begin blinking when complete.
  • Switch the board off, then back on. It’s now in CMSIS-DAP mode.

It’s possible to reflash the board back to J-Link mode, so you can play with Mbed and go back to your regular development tools like SEGGER Embedded Studio:

  • Download the Nordic J-Link OB firmware .bin from this thread
  • Download SEGGER’s Software and Documentation pack using the top link for v7.5.0; not strictly needed, just for updating to the latest version of J-Link firmware.
  • Put the board into bootloader mode as above, by holdig the BOOT pushbutton during power-on. Drag the OB firmware .bin onto the mounted drive, let it flash (LED5 will begin blinking when done, as described above) and then power-cycle the board.
  • Note this posted firmware file is several years old. To update, run J-Link Configurator, select the checkbox next to your J-Link in the list, then click “Update firmware of selected probes and programmers.”

Note that CMSIS-DAP / DAPLink programmers can be purchased very cheaply online for USD 10-15. You may want to purchase a separate CMSIS-DAP programmer for use with Mbed, and leave your J-Link as a… J-Link.

A thought for starving hackers: if you have the NRF52840-DONGLE, purchasing a CMSIS-DAP programmer for use with Mbed would get you a very economical little nRF + Mbed development environment. You would not be dependent on the Nordic bootloader anymore, and could program “bare metal,” at least with Mbed and other toolchains that support CMSIS-DAP programmers.

1 Like

@Asa_Durkee , thank you for the excellent information! I didn’t realize there was a CMSIS-DAP mode available.

Personally, I’m now using VSCode with the CMake-Tools and cortex-debug extensions, which works well for the newer CLI 2 CMake Mbed projects. Setting that up isn’t all that easy, though, and Mbed Studio would definitely be the easier route for someone looking to experiment with Mbed. Your documentation will definitely help some people out!