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

Keil uVision 5 NRF52840 ERROR: flash download failed - "Cortex M4"

I have seen this problem posted several times in these forums but none of the existing solutions sit right with me.  

I have an NRF52840 (using a UBlox BMD-340 dev board).  I am using the S140 soft device (v.7.2.0).

I'm using Keil uVision 5.  

---

I am able to build applications in Keil as normal.

I am able to use nrfjprog to program my application and soft device and get it to run without issue.

I am not, however, able to program my uBlox BMD-340 from Keil to debug.  During the 'erase' step, it fails.

**JLink Warning: T-bit of XPSR is 0 but should be 1. Changed to 1.

On an interesting side note:  I AM able to program (using Keil) example applications like Blinky, so I'm wondering if there is something wrong with my custom project file.

For what it's worth, I was able to debug/program last week with my custom project.  Keil seems to like to change things in the project without me knowing about it, so it is completely reasonable that Keil nuked something or changed something behind the scenes, but I don't know how to figure out what that something might be.  

Parents
  • Hello,

    This is a typical error you would see in Keil if you are trying to flash a non-softdevice example to a DK containing a softdevice. Perhaps someone has used a different softdevice with a different size on your device?

    Try to erase the board, program the correct softdevice (both using nrfjprog: nrfjporg -e && nrfjprog --program <softdevice>.hex), and then try to program from Keil.

    If that doesn't work, do any of the unmodified examples from the SDK work? Perhaps you have touched something in the programming settings in your Keil project?

    Best regards,

    Edvin

  • Edvin,

    I am able to program fine with nrfjprog, but I cannot in Keil.  

    Yes, I am able to program other example projects in Keil.

    I was also previously able to program the device in Keil but now I am not.  

    I agree it is probably something wrong with the project file, but I don't know how to identify what went wrong or how to fix it.  

    Do you know of a way I could see in my project setup if it is expecting a soft device?

Reply
  • Edvin,

    I am able to program fine with nrfjprog, but I cannot in Keil.  

    Yes, I am able to program other example projects in Keil.

    I was also previously able to program the device in Keil but now I am not.  

    I agree it is probably something wrong with the project file, but I don't know how to identify what went wrong or how to fix it.  

    Do you know of a way I could see in my project setup if it is expecting a soft device?

Children
  • Greg Nowak said:
    Do you know of a way I could see in my project setup if it is expecting a soft device?

     Look at the keil settings' Utilities tab. What does it look like? In the current SDKs, it looks something like this:

    Perhaps you can compare it to another project from your SDK.

    Also make sure that the "Debug" tab looks the same as your other examples' settings:

    Best regards,

    Edvin

  • Note:  I've gone through all of these with an example project that DOES work and I didn't notice any differences.  

  • I probably don't know more about Keil setups than you do. 

    Please also check the settings in the "debug" tab:

    If that doesn't work, I guess another option would be to copy the Keil project file from another example, and include your custom files again. Is there some way for me to reproduce what you are seeing? Can you zip the project so that I can unzip it somewhere in an unmodified SDK and reproduce the issue (please test this before sending it). Also, what SDK version do you use? SDK17.0.2?

    BR,
    Edvin

  • Edvin,

    I figured out my issue, but I'm not sure why it fails. 

    I tried to implement Monitor Mode Debugging and based on my JlinkSettings.ini it'll either 'fail to erase' or work as expected.  

    ---- This works

    [BREAKPOINTS]
    ForceImpTypeAny = 0
    ShowInfoWin = 1
    EnableFlashBP = 2
    BPDuringExecution = 0
    [CFI]
    CFISize = 0x00
    CFIAddr = 0x00
    [CPU]
    MonModeVTableAddr = 0xFFFFFFFF
    MonModeDebug = 0
    MaxNumAPs = 0
    LowPowerHandlingMode = 0
    OverrideMemMap = 0
    AllowSimulation = 1
    ScriptFile=""
    [FLASH]
    CacheExcludeSize = 0x00
    CacheExcludeAddr = 0x00
    MinNumBytesFlashDL = 0
    SkipProgOnCRCMatch = 1
    VerifyDownload = 1
    AllowCaching = 1
    EnableFlashDL = 2
    Override = 0
    Device="ARM7"
    [GENERAL]
    WorkRAMSize = 0x20000
    WorkRAMAddr = 0x20000000
    RAMUsageLimit = 0x00
    [SWO]
    SWOLogFile=""
    [MEM]
    RdOverrideOrMask = 0x00
    RdOverrideAndMask = 0xFFFFFFFF
    RdOverrideAddr = 0xFFFFFFFF
    WrOverrideOrMask = 0x00
    WrOverrideAndMask = 0xFFFFFFFF
    WrOverrideAddr = 0xFFFFFFFF

    ---  This doesn't allow me to erase

    [CPU]
    MonModeVTableAddr = 0x27000
    MonModeDebug = 1

    Do you know anything about Monitor Mode Debugging?  I'm wondering if my MonModeVTableAddr is wrong if I'm running an application with a soft device.  

  • I have never tested monitor mode debugging before, but a colleague of mine wrote a guide on how to get it up and running. Perhaps you can try that?

    Please remember that Monitor Mode Debugging is an external project/property. If you are struggling to get it up and running, then you would need to contact Segger (who wrote it). 

    Best regards,

    Edvin

Related