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

Using nrfjprog to program application does not work

I'm developing an application on a custom nRF52 board. I have no problem to program the board with Keil. However when I try to program the application with the nrfjprog, the application won't run. What is the correct procedure to program with nrfjprog?

Below is my command line log:

$ nrfjprog -f NRF52 --program nrf52832_xxaa_s132.hex --sectorerase
Parsing hex file.
Erasing page at address 0x1C000.
Erasing page at address 0x1D000.
Erasing page at address 0x1E000.
Erasing page at address 0x1F000.
Erasing page at address 0x20000.
Erasing page at address 0x21000.
Erasing page at address 0x22000.
Erasing page at address 0x23000.
Erasing page at address 0x24000.
Applying system reset.
Checking that the area to write is not protected.
Programing device.

$ nrfjprog -f NRF52 --reset
Applying system reset.
Run.
  • my usual steps:

    nrfjprog -f NRF52 --program SOFTDEVICE.hex --chiperase --verify
    nrfjprog -f NRF52 --program APPLICATION.hex --verify
    nrfjprog -f NRF52 --reset

    It does look like your commands are correct though. Just make sure the Softdevice is programmed properly or else your BLE application won't run correctly.

    Using --sectorerase when programming your application will allow you to program the SoftDevice once and then continue to program your APPLICATION.hex as it changes without having to always reload the SoftDevice. My recommendation is to try the commands I listed above first though. Lets verify that atleast works so we can localize the problem. If that works then try the --sectorerase command again.

  • Hi Michael,

    I followed your steps exactly, the result was the same.

    $ nrfjprog -f NRF52 --program s132_nrf52_2.0.0_softdevice.hex --chiperase --verify
    Parsing hex file.
    Erasing code and UICR flash areas.
    Applying system reset.
    Checking that the area to write is not protected.
    Programing device.
    Verifying programming.
    Verified OK.
    
    $ nrfjprog -f NRF52 --program _build/nrf52832_xxaa_s132.hex --verify
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programing device.
    Verifying programming.
    Verified OK.
    
    $ nrfjprog -f NRF52 --reset
    Applying system reset.
    Run.
    

    Application was not running after the above steps. Then I used Keil to download the app and it ran.

  • Does it run if you physically switch the board off and on again?

  • OK, that's really weird.

    Can you make sure you have a recent version of nrfjprog: www.nordicsemi.com/.../nRF52832

    Just install the latest one for your OS there. You can also try nrfjprog -f NRF52 --recover once just to make sure nothing weird is going on with protection or anything.

  • Looks like "nrfjprog -f NRF52 --reset" could not run the application. However by following the below steps, I can get the app running:

    After flashing the softdevice and application with nrfjprog, go to Keil and open the 'Options for Target' dialog, in the Debug tag click the Settings button next to 'Use J-LINK/J-TRAce Cortex'. After the SW Device is detected just close the dialog. Then my application is running.

    Any idea why nrfjprog --reset does not work?

Related