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!
@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:
Run J-Link Configurator. Your J-Link should appear in the list of USB devices.
Right-click your J-Link in the list, choose Configure, and in the window that appears, change its boot mode to CMSIS-DAP.
Reset the J-Link so it boots into the new mode.
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:
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.
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.
@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!