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

Unable to flash nRF9160 with "ninja flash"

I'm building some of the samples using command line in Ubuntu and have a strange issue. Everything builds fine, the merged.hex file is generated, however when I try to flash the device using "ninja flash" the boot loader never runs the application:

SPM: MSP_NS 20023088
SPM: prepare to jump to Non-Secure image

However the following all work:

1. Flashing the image using J-FlashLite

2. nrfjprog -e; nrfjprof --program merged.hex

3. nrfjprog -e; ninja flash

SPM: MSP_NS 200236c8
SPM: prepare to jump to Non-Secure image
***** Booting Zephyr OS 1.14.99 *****
The AT host sample started

Does anyone know what the issue might be here? Is ninja flash corrupting something during the erase?

For some reason I am currently unable to reply to the below posts so I'm adding this here:

$ nrfjprog -v
nrfjprog version: 10.1.1
JLinkARM.dll version: 6.46g

  • Hi,

     

    Q1: What project are you compiling? Is this the behavior for all projects?

    Q2: What revision/tag have you checked out? 

    Does anyone know what the issue might be here? Is ninja flash corrupting something during the erase?

    ninja just acts as the build system. In the background, nrfjprog is being called, so it should be equal to manually flashing.

     

    Kind regards,

    Håkon

  • I get the same result with nrf/samples/nrf9160/at_client, and with mqtt_simple. I haven't tried any more at this time.

    This is on v0.4.0

    How would I find out exactly which nrfjprog commands are being executed by ninja? There must be some sort of discrepancy if #3 above works.

  • If I'm reading your problem right, you are finding that invoking ninja flash is not actually flashing a different application to the DK right?

    I have had a few instances of ninja flash just straight up not doing anything but reseting the device with the same firmware that was on it previously.

    I generally just invoke a JLinkExe erase by writing to the NVMC Erase All register:

    w4 0x50039504 2 //sets NVMC config register to erase enabled
    w4 0x5003950c 1 //NVMC eraseall

    That should invoke an erase of the nRF9160, then ninja flash it again and it should actually work this time. I believe this is what nrfjprog does under the hood for nRF9160s, my version of JLink doesn't identify the cortex as an nRF9160, only as M33. So some manual tinkering is used. Alternatively you could try the Desktop NRF Connect Programmer application but I don't know if that is avaliable on Linux.

    I use this method to erase and reflash a DK remotely.

    Edit: Actually re-reading your OP, I guess this isn't your issue but for #2, you haven't set an nRF family type so it probably won't manipulate the NVMC which you must do to enable flashing and erasing. You could try it this way as I described to erase, then do it again and set NVMC to write enabled, then use 'loadfile <merged.hex>' to flash the firmware. See page 32 of the OPS on NVMC config.

  • What is the output of nrfjprog -v? Is either JLink (should be v6.40 or newer) or nrfjprog old (v9.8.1 or newer)?

    If you have an old one in path, it might not accept "-f nrf91" (west invokes nrfjprog with this switch), but still try to program it. West checks the connected jlinks, provides a list if more than one is present, then passes that on to nrfjprog with --ids switch.

    You can find the latest nrfjprog here: https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools/Download#infotabs

      

    Cheers,

    Håkon

  • Looks like my tools are all up to date:

    $ nrfjprog -v
    nrfjprog version: 10.1.1
    JLinkARM.dll version: 6.46g

Related