This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

After programming S110 SoftDevice, I get "Erase Failed! Error: Download Failed - Cortex M0

I have a 51822-DK board. I have followed all of the instructions to set up the environment. Loaded all NRF tools, Keil v 5, install SDK. I began working on the examples. I was able to run the blinky example and load the chip. Then I programmed the S110 soft device. I loaded up the heart rate monitor example as suggested in the SDK documentation (using the pack installer) . I was able to successfully compile it but not able to load it onto the chip. I've wasted 2 days on this. Please help!

Here is some background on what I have already tried. Checked target and it is set to S110. Checked memory target. Checked programming algorithms. See attached screenshots of configuration. See screenshots for configuration.

Debug tab Device tab Algorithm setting Target tab

I am getting the following output when trying to upload:

Rebuild target 'nrf51422_xxac_s110' compiling main.c... compiling bsp.c... assembling arm_startup_nrf51.s... compiling system_nrf51.c... compiling ble_bas.c... compiling ble_dis.c... compiling ble_hrs.c... compiling ble_srv_common.c... compiling device_manager_peripheral.c... compiling ble_advdata.c... compiling ble_conn_params.c... compiling nrf_delay.c... compiling app_uart_fifo.c... compiling pstorage.c... compiling app_button.c... compiling app_error.c... compiling app_fifo.c... compiling app_gpiote.c... compiling app_scheduler.c... compiling app_timer.c... compiling app_trace.c... compiling ble_sensorsim.c... compiling nrf_assert.c... compiling retarget.c... compiling softdevice_handler.c... linking... Program Size: Code=15176 RO-data=332 RW-data=328 ZI-data=3648
FromELF: creating hex file... "._build\nrf51422_xxac_s110.axf" - 0 Error(s), 0 Warning(s). Build Time Elapsed: 00:00:14 Load "C:\Users\Rona\Documents\Development Kit Files\Examples\ble_peripheral\ble_app_hrs\pca10028\s110\arm5\_build\nrf51422_xxac_s110.axf" Set JLink Project File to "C:\Users\Rona\Documents\Development Kit Files\Examples\ble_peripheral\ble_app_hrs\pca10028\s110\arm5\JLinkSettings.ini"

  • JLink Info: Device "NRF51822_XXAC" selected.

JLink info:

DLL: V4.96d, compiled Jan 29 2015 11:45:37 Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Nov 28 2014 10:32:04 Hardware: V1.00 S/N : 681341448

  • JLink Info: Found SWD-DP with ID 0x0BB11477
  • JLink Info: Found Cortex-M0 r0p0, Little endian.
  • JLink Info: FPUnit: 4 code (BP) slots and 0 literal slots ROMTableAddr = 0xF0000003

Target info:

Device: nRF51822_xxAC VTarget = 3.300V State of Pins: TCK: 0, TDI: 1, TDO: 1, TMS: 1, TRES: 1, TRST: 1 Hardware-Breakpoints: 4 Software-Breakpoints: 8192 Watchpoints: 2 JTAG speed: 1000 kHz

Erase Failed! Error: Flash Download failed - "Cortex-M0" Flash Load finished at 19:22:06

  • In a last ditch effort, I kept looking. I found another post that focused me back on the memory setting. I erased the flash with nrf studio and reprogrammed it. I noticed that the memory location changed in the application section of the window. I changed the memory in the target settings in Keil and recompiled it. I was able to upload. I'm not sure if it is fixed as the new application doesn't seem to work but I'll post that as a new question if I can't figure it out.

  • From the target setup it is apparent that you are setting the executable IROM address space to 0x00000-0x1FFFF.

    This will mean that any code you generate will try to overwrite the soft device, so the erase fails.

    What you need to do is select the correct build target: either nrf51822_xaa_s110 (256kB) or rf51822_xaa_s110 (128kB).

    This will set the IROM addresses as 0x18000-0x1FFFF.

    That does not overlap the softdevice and is where the soft device expects an application to be.

  • Important Address ( under Target options settings in Keil IDE )

    Address without BLE Softdevice( BLE STACK ) application:

    In case application runs over bluestack softdevice then address will be

    • Address are : IROM1 : 0x16000 - 0x29000
    • Address are : IRAM1 : 0x20002000 - 0x2000

    In case application runs without bluestack softdevice then address will be

    • Address are : IROM1 : 0x0 - 0x40000
    • Address are : IRAM1 : 0x20000000 - 0x4000

    Rest of the default setting i request not to be changed until you are sure about it. Once i was also using keil to flash up the binaries but it screwed up the chip itself by messing up in driver or erasing chip as well. Hence i tried recovering the chip first. Search around the net you will get the correct way to recover the chip if you are not getting a proper window in nrfGo Studio application. I suggest you to use nrfGO Studio application for uploading your application, softdevice and bootloader binaries. These are the above settings which got me working on it. I hope this would have helped you.

Related