sandeepmistry / arduino-nRF5

Arduino Core for Nordic Semiconductor nRF5 based boards
Other
872 stars 278 forks source link

Issue flashing soft device on nRF52832 module - Error: Could not find MEM-AP to control the core #522

Open EmikVayts opened 3 months ago

EmikVayts commented 3 months ago

Hello,

I am facing an issue with flashing S132 soft device to a nRF52832 module. I am using a J-Link EDU Mini to flash.

The specific error shown is: "Error: Could not find MEM-AP to control the core". Here is the screenshot from Arduino IDE: nrf52_memory_access_error

I did not find this same error in any issues of this project (which is why I am starting a new issue on this) - but I did find this same error mentioned in this blog post: https://limitedresults.com/2020/06/nrf52-debug-resurrection-approtect-bypass/

The blog post says that this error is due to APPROTECT register, which seems to protect the board from being programmed or debugged with the J-Link.

The blog post offered two methods for removing APPROTECT - one method using OpenOCD to modify the register - and the other method to use 'nrfjprog' utility to 'recover' the module. The OpenOCD method didn't work for me, but looks like I was able to recover the board using 'nrfjprog' method: nrfjprog_recover

After resetting the board using nrfjprog, I used 'Zadig' utility to switch my J Link back to WinUSB, and at this point I was able to successfuly flash the S132 soft device to my nRF52832 module.

TLDR - I was able to find a workaround to this issue but it required resetting my module using external 'nrfjprog' utility. I am wondering if there is a more efficient way to reset the board from Arduino IDE, thanks!

EmikVayts commented 3 months ago

Additional note - if you have already configured the 'WinUSB' driver on the J Link using 'Zadig' utility, the external 'nrfjprog' utility will no longer work.

In order to make 'nrfjprog' utility work, you have to first re-install the official J Link driver in the 'Restoring the USB driver' of this documentation page (https://wiki.segger.com/OpenOCD)

Then you should be able to use 'nrfjprog' utility to reset the BLE module.

Afterwards, you have to go back to Zadig and install the WinUSB driver again, and at that point you should be able to flash the SoftDevice.

Just want to point out that it is an inconvenience to switch between drivers on the J Link - which is why I would like to figure out if there is a good solution using Open OCD or in the Arduino project. Thanks