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

Failed to download firmware in nRF52840 chip

Hello,

I'm trying to run my application from Segger Embedded Studio into my custom nRF52840 board but it is not working !

Preparing target for download
Executing script TargetInterface.resetAndStop()
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
Downloading ‘s140_nrf52_6.0.0_softdevice.hex’ to J-Link
Programming 2.5 KB of addresses 00000000 — 00000a17
Programming 144.9 KB of addresses 00001000 — 000253c7
J-Link: Flash download: Restarting flash programming due to program error (possibly skipped erasure of half-way erased sector).
J-Link: Flash download: Skip optimizations disabled for second try.

I switched to Jlink commander to get more details 

I'm able to connect to the target and read it's infos

connect
Device "NRF52840_XXAA" selected.


Connecting to target via SWD
Found SW-DP with ID 0x2BA01477
Found SW-DP with ID 0x2BA01477
AP map detection skipped. User manually configured AP map.
AP[0]: AHB-AP (IDR: Not set)
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
Cortex-M4 identified.

I'm able to erase it with "erase all" command or with nrfgo Studio, but when trying to download the firmware with loadbin I get the same error as in Segger IDE

loadbin firmware.bin,0x00000000
Halting CPU for downloading file.
Downloading file [frimware.bin]...
J-Link: Flash download: Restarting flash programming due to program error (possibly skipped erasure of half-way erased sector).
J-Link: Flash download: Skip optimizations disabled for second try.
Error while programming flash: Programming failed.

and it seems that the jlink is having a hard time switching to another page of the flash memory cause I can see that starting from address 0x00001000 the flash is still empty!

Starting to write the bin file from page 1 ( loadbin firmware.bin,0x00001000) produce the same behavior : page 2 ( 0x00002000 ) is empty

Writing bytes directly to the flash seems to work correctly : 

J-Link>w4 1000,DEADBEEF
Writing DEADBEEF -> 00001000
J-Link>mem 1000,4
00001000 = EF BE AD DE

I'm using the recent version of jlink 6.34b and sw to connect to the target.

I noticed that this problem was discussed here but it was more about OS system (I'm using windows) and it's 3 years ago ! I believe if it's an issue in segger firmware then most likely it is fixed already ?

do you have more details about this problem and maybe how to fix it ?

Parents
  • Hi Chaabane, 

    How have you connected the programmer/nRF52xxx DK to your custom board?

    Could you try to use nrfjprog from the nRF Command Line Tools to erase the nRF52840 chip, i.e. 

    nrfjprog --family nrf52 --eraseall

    and then try flashing the chip with SES again. If you still see the issue after performing a full erase, then try using the --recover command. You can also try to use nrfjprog to flash the compiled hex file using 

    nrfjprog -f nrf52 --program <name of hex file>.hex --sectorerase --verify --reset

    Best regards

    Bjørn

  • Thank you Bjorn,

    I used the P20 ( VGT,SWD IO, SWD CLK, RESET and GND DETECT).

    I tried the commands you mentionned but got the same results !

    I was able to download the firmware on some boards (2 of 6) so I asked the production team to check them but they couldn't find anything wrong with the soldering or the components. It's confusing how we can erase, write to a single page of the flash and not able to write the hole firmware ! Any idea where this behavior could be coming from ?

    Thx,

    Chaabane

  • nrfjprog version 9.7.1 and Jlink 6.34b

    I compared both SWD traces. the clock is stable at 880-1000 KHz.

    In the case of the bugged board  values read from the debug port and the access port (after read request ) are not always the same as the returned values in the working board. the trace on CLK and IO looks normal for the write cycles before these reads. Below is the records for SWD trace for both boards if it might help

     nrf52840_SWD_Working_Board.csv

    nrf52840_SWD_Bugged_Board.csv

    Thank you

  • Are you using a Saleae to capture the traces? If so, could you provide the traces as .logicdata files and not .csv? It makes it a bit easier to analyze. 

    Could you also try the nrfjprog commands again, but this time append the --log option. The nrfjprog log output will then be placed in a log.log file in the directory where you called nrfjprog from. Please attach the logs to this case. 

  • Please, Find attached the requested logs

    working board.logicdata

    Notworking board.logicdata

    --------------------------------------------------------------------------------
    nrfjprog --log --family nrf52 --eraseall
    nrfjprog verion 9.7.1
    --------------------------------------------------------------------------------
    FUNCTION: open_dll.
    FUNCTION: open_dll.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_without_snr.
    FUNCTION: enum_emu_snr.
    Device "NRF52832_XXAA" selected.
    FUNCTION: read_device_version.
    FUNCTION: read_device_version.
    Found SW-DP with ID 0x2BA01477
    Found SW-DP with ID 0x2BA01477
    Scanning AP map to find all available APs
    AP[2]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x24770011)
    AP[1]: JTAG-AP (IDR: 0x02880000)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    Found Cortex-M4 r0p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
    ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
    ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
    ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
    ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
    ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
    FUNCTION: disable_bprot.
    FUNCTION: disable_bprot.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    FUNCTION: erase_all.
    FUNCTION: erase_all.
    FUNCTION: sys_reset.
    FUNCTION: sys_reset.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    FUNCTION: close_dll.
    FUNCTION: close_dll.
    --------------------------------------------------------------------------------
    nrfjprog -f nrf52 --log --program C:\Nordic\nRF5_SDK_15.0.0_a53641a\examples\peripheral\blinky\pca10059\mbr\ses\Output\Release\Exe\blinky_pca10059_mbr.hex --sectorerase --verify --reset
    nrfjprog verion 9.7.1
    --------------------------------------------------------------------------------
    FUNCTION: open_dll.
    FUNCTION: open_dll.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_without_snr.
    FUNCTION: enum_emu_snr.
    Device "NRF52832_XXAA" selected.
    FUNCTION: read_device_version.
    FUNCTION: read_device_version.
    Found SW-DP with ID 0x2BA01477
    Found SW-DP with ID 0x2BA01477
    Scanning AP map to find all available APs
    AP[2]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x24770011)
    AP[1]: JTAG-AP (IDR: 0x02880000)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    Found Cortex-M4 r0p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
    ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
    ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
    ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
    ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
    ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
    FUNCTION: readback_status.
    FUNCTION: readback_status.
    FUNCTION: read_region_0_size_and_source.
    FUNCTION: read_region_0_size_and_source.
    FUNCTION: erase_page.
    FUNCTION: erase_page.
    FUNCTION: sys_reset.
    FUNCTION: sys_reset.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    FUNCTION: power_ram_all.
    FUNCTION: power_ram_all.
    FUNCTION: is_qspi_init.
    FUNCTION: is_qspi_init.
    FUNCTION: read_region_0_size_and_source.
    FUNCTION: read_region_0_size_and_source.
    FUNCTION: disable_bprot.
    FUNCTION: disable_bprot.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    FUNCTION: write.
    FUNCTION: write.
    FUNCTION: write.
    FUNCTION: write.
    FUNCTION: is_qspi_init.
    FUNCTION: is_qspi_init.
    FUNCTION: read.
    FUNCTION: read.
    FUNCTION: read.
    FUNCTION: read.
    FUNCTION: is_qspi_init.
    FUNCTION: is_qspi_init.
    FUNCTION: sys_reset.
    FUNCTION: sys_reset.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    FUNCTION: go.
    FUNCTION: go.
    FUNCTION: close_dll.
    FUNCTION: close_dll.
    --------------------------------------------------------------------------------
    nrfjprog --log --family nrf52 --eraseall
    nrfjprog verion 9.7.1
    --------------------------------------------------------------------------------
    FUNCTION: open_dll.
    FUNCTION: open_dll.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_without_snr.
    FUNCTION: enum_emu_snr.
    Device "NRF52832_XXAA" selected.
    FUNCTION: read_device_version.
    FUNCTION: read_device_version.
    Found SW-DP with ID 0x2BA01477
    Found SW-DP with ID 0x2BA01477
    Scanning AP map to find all available APs
    AP[2]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x24770011)
    AP[1]: JTAG-AP (IDR: 0x02880000)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    Found Cortex-M4 r0p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
    ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
    ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
    ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
    ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
    ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
    FUNCTION: disable_bprot.
    FUNCTION: disable_bprot.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    FUNCTION: erase_all.
    FUNCTION: erase_all.
    FUNCTION: sys_reset.
    FUNCTION: sys_reset.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    FUNCTION: close_dll.
    FUNCTION: close_dll.
    --------------------------------------------------------------------------------
    nrfjprog -f nrf52 --log --program C:\Nordic\nRF5_SDK_15.0.0_a53641a\examples\peripheral\blinky\pca10059\mbr\ses\Output\Release\Exe\blinky_pca10059_mbr.hex --sectorerase --verify --reset
    nrfjprog verion 9.7.1
    --------------------------------------------------------------------------------
    FUNCTION: open_dll.
    FUNCTION: open_dll.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_without_snr.
    FUNCTION: enum_emu_snr.
    Device "NRF52832_XXAA" selected.
    FUNCTION: read_device_version.
    FUNCTION: read_device_version.
    Found SW-DP with ID 0x2BA01477
    Found SW-DP with ID 0x2BA01477
    Scanning AP map to find all available APs
    AP[2]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x24770011)
    AP[1]: JTAG-AP (IDR: 0x02880000)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    Found Cortex-M4 r0p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
    ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
    ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
    ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
    ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
    ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
    FUNCTION: readback_status.
    FUNCTION: readback_status.
    FUNCTION: read_region_0_size_and_source.
    FUNCTION: read_region_0_size_and_source.
    FUNCTION: erase_page.
    FUNCTION: erase_page.
    FUNCTION: sys_reset.
    FUNCTION: sys_reset.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    FUNCTION: power_ram_all.
    FUNCTION: power_ram_all.
    FUNCTION: is_qspi_init.
    FUNCTION: is_qspi_init.
    FUNCTION: read_region_0_size_and_source.
    FUNCTION: read_region_0_size_and_source.
    FUNCTION: disable_bprot.
    FUNCTION: disable_bprot.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    FUNCTION: write.
    FUNCTION: write.
    FUNCTION: write.
    FUNCTION: write.
    FUNCTION: is_qspi_init.
    FUNCTION: is_qspi_init.
    FUNCTION: read.
    FUNCTION: read.
    FUNCTION: close_dll.
    FUNCTION: close_dll.
    

  • Hi Chaabane, 

    I'll take a look at the logic traces, meanwhile, the latest version of nrfjprog is v9.7.3. Could you try to download this version, link, and then retry the commands with the --log option? The latest version provides more verbose log output than the older one. 

    Also, please post the console output from nrfjprog as well as the .log file

    Bjørn

  • Attached is the logs with the newer version and the screenshot of the console.

    With this version It worked with the blinky example hex file but not with my project hex file.

    1067.log.log

    Thank  you

Reply Children
Related