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

Flash download failed - "Cortex-M4" after I import some c files from other example

Hi all

I am doing multiprotocal from sdk15.3 and I am trying to add nrf_gzp.c, nrf_gzp_host.c, and nrf_gzp_host_nrf5x.c in to the project

after compile successfully and try to download to pca10040

here comes the error information Flash download failed - "Cortex-M4"

the compile information said 

Program Size: Code=33540 RO-data=3224 RW-data=360 ZI-data=12612  before I import the c files

Program Size: Code=33048 RO-data=7316 RW-data=372 ZI-data=12612  after I import the c files

so i think there is something wrong with my ROM and RAM settings

here is my ROM and RAM settings

could anyone tells me how to modified the address and the size?

  • Hi Stian

    there are no errors while compiling, but downloading to the demo board will shows the Flash download failed - "Cortex-M4" error

    please see the log below, thanks

    *** Using Compiler 'V5.05 update 2 (build 169)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
    Build target 'nrf52832_xxaa'
    ".\_build\nrf52832_xxaa.axf" - 0 Error(s), 0 Warning(s).
    Build Time Elapsed:  00:00:02
    Load "D:\\nRF5_SDK_15.3.0_59ac345\\examples\\multiprotocol\\ble_app_gzll\\pca10040\\s132\\arm5_no_packs\\_build\\nrf52832_xxaa.axf" 
    Set JLink Project File to "D:\nRF5_SDK_15.3.0_59ac345\examples\multiprotocol\ble_app_gzll\pca10040\s132\arm5_no_packs\JLinkSettings.ini"
    * JLink Info: Device "NRF52832_XXAA" selected.
     
    JLink info:
    ------------
    DLL: V4.98e, compiled May  5 2015 11:00:52
    Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 12 2018 11:44:41
    Hardware: V1.00
    S/N : 682290234 
     
    * JLink Info: Found SWD-DP with ID 0x2BA01477
    * JLink Info: Found Cortex-M4 r0p1, Little endian.
    * JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
    * JLink Info: CoreSight components:
    * JLink Info: ROMTbl 0 @ E00FF000
    * JLink Info: ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB00C SCS
    * JLink Info: ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 003BB002 DWT
    * JLink Info: ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 002BB003 FPB
    * JLink Info: ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 003BB001 ITM
    * JLink Info: ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 000BB9A1 TPIU
    * JLink Info: ROMTbl 0 [5]: FFF42000, CID: B105900D, PID: 000BB925 ETM
    ROMTableAddr = 0xE00FF003
     
    Target info:
    ------------
    Device: nRF52832_xxAA
    VTarget = 3.300V
    State of Pins: 
    TCK: 0, TDI: 1, TDO: 1, TMS: 1, TRES: 1, TRST: 1
    Hardware-Breakpoints: 6
    Software-Breakpoints: 8192
    Watchpoints:          4
    JTAG speed: 1000 kHz
     
    Erase Failed!
    Error: Flash Download failed  -  "Cortex-M4"
    Flash Load finished at 08:36:41

  • Thanks! The error is: "Erase Failed!"

    You will get an erase failed error if Keil tries to erase flash where the softdevice is located. So most likely your application is overlapping with the softdevice.

    1. Can you describe the procedure on how you flash the softdevice? Before you flash the application? And after full erase? which program, etc.
    2. Which softdevice version are you using?
    3. Can you post the hex-file that Keil is creating, and I can have a look and see if there's data in an area where it shouldn't be data.
    4. Can you download the command line tools and use nrfjprog to do a full erase of the chip. nRF go studio is deprecated now. You can use nrfjprog or nRF connect and the programmer app.
  • Hello Stian

    1. I will face this problem if i flash the softdevice before i flash the application. But no fail when i flash the application first.
    2. And the softdevice is from the SDK-s132_nrf52_6.1.1_softdevice which i flash by using keilC
    3. Here is the file which keil create2330.nrf52832_xxaa.hex
    4. Yes i have download command line tools and do what you asked me to do, but the fail will shows again
  • Looking at the application hex file I can see that it contains data at the address 0x1000. This is in the softdevice region and Keil will give you an erase failed error if the area is already occupied by a softdevice.

    Looking through the files you included I can see that In nrf_gzp_config.h included by the nrf_gzp.h file there's a variable called GZP_PARAMS_STORAGE_ADR, which is set to 0x1000, which is used for storing parameters. Since this area is now used by the softdevice, you must move the storage to where the application is located, e.g. 0x27000

    Please also have a look at the multiprotocol examples in the SDK: examples\multiprotocol\ble_app_gzll

  • Thanks you, the problem is fixed after the address of GZP_PARAMS_STORAGE_ADR change to the storage where the application is located.

Related