J-Flash failed to erase chip

Hi,

I build a custom board (nRF52840) but I'm not able to flash it using nRF5340DK with J-Flash via SWD interface.

1. The first thing I did was to do a full chip erase. However, I got the error message "RAMCode did not respond in time".

2. I later tried to use nrfjprog to do the chip erase, which seems to work without any error message. (at address 0x26)

3. I use nrfjprog to flash the device with the verify flag on, but it keeps saying the flash content doesn't match.

4. I later use the nRF Connect Desktop Programmer to flash the target, and read the target flash content. 

5. I use nrfjprog to verify the flash with hex file, and it still complains the flash doesn't match. (at address 0x246)

6. I compare the dumped hex file (from step 4) and find the locations where nrfjprog complains (in step 2 and step 5), it seems to match the original hex file.

My understanding is that the nrfjprog is a wrapper of segger j-flash, so nrfjprog should behave similarly to J-Flash. Although the flash seems correct, the MCU is still not running.

Any suggestions?

Thanks!

--

J-Flash error codes

Connecting ...
 - Connecting via USB to probe/ programmer device 0
 - Probe/ Programmer firmware: J-Link OB-nRF5340-NordicSemi compiled Oct 30 2023 12:13:06
 - Probe/ Programmer S/N: 1050080092
 - Device "NRF52840_XXAA" selected.
 - Target interface speed: 2000 kHz (Fixed)
 - VTarget = 3.300V
 - InitTarget() start
 - InitTarget() end - Took 3.96ms
 - Found SW-DP with ID 0x2BA01477
 - DPIDR: 0x2BA01477
 - CoreSight SoC-400 or earlier
 - 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.
 - Cortex-M: The connected J-Link (S/N 1050080092) uses an old firmware module: V1 (current is 2)
 - FPUnit: 6 code (BP) slots and 2 literal slots
 - CoreSight components:
 - ROMTbl[0] @ E00FF000
 - [0][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7
 - [0][1]: E0001000 CID B105E00D PID 003BB002 DWT
 - [0][2]: E0002000 CID B105E00D PID 002BB003 FPB
 - [0][3]: E0000000 CID B105E00D PID 003BB001 ITM
 - [0][4]: E0040000 CID B105900D PID 000BB9A1 TPIU
 - [0][5]: E0041000 CID B105900D PID 000BB925 ETM
 - Executing init sequence ...
  - Initialized successfully
 - Target interface speed: 2000 kHz (Fixed)
 - Found 1 JTAG device. Core ID: 0x2BA01477 (None)
 - Connected successfully
Erasing chip ...
 - 257 sectors, 2 ranges, 0x0 - 0xFFFFF, 0x10001000 - 0x10001FFF
 - Start of preparing flash programming
 - End of preparing flash programming
 - Start of determining dirty areas in flash cache
 - End of determining dirty areas
 - CPU speed could not be measured.
 - Start of erasing chip
 - ERROR: Timeout while erasing chip, RAMCode did not respond in time (PC = 0x00000A64, XPSR = 0x21000003, SP = 0x20000588)!
 - ERROR: Failed to erase chip.
Failed to execute RAMCode for chip erase!
 - End of erasing chip
 - ERROR: Erase failed
 - Start of restoring
 - End of restoring
 - ERROR: Failed to erase chip
Disconnecting ...
 - Disconnected

nrfjprog flash with verify error message

[ #################### ]   2.063s | Program file - Done programming
[error] [ Client] - Encountered error -160: Command verify_file executed for 203 milliseconds with result -160
[error] [  nRF52] - Failed while performing 'Verify' operation on target address 0x00000000.
-160: Data does not match in address range [0x00000000 - 0x00000AFF] (Flash)
Expected byte value 0x00 but read 0x20 at address 0x00000026.
[error] [  nRF52] - Failed while verifying device. -160: Data does not match in address range [0x00000000 - 0x00000AFF] (Flash)
Expected byte value 0x00 but read 0x20 at address 0x00000026.
[error] [ Worker] - Data does not match in address range [0x00000000 - 0x00000AFF] (Flash)
Expected byte value 0x00 but read 0x20 at address 0x00000026.
ERROR: Write verify failed.
NOTE: For additional output, try running again with logging enabled (--log).
NOTE: Any generated log error messages will be displayed.

nrfjprog verify error message

[error] [ Client] - Encountered error -160: Command verify_file executed for 200 milliseconds with result -160
[error] [  nRF52] - Failed while performing 'Verify' operation on target address 0x00000000.
-160: Data does not match in address range [0x00000000 - 0x00000AFF] (Flash)
Expected byte value 0x4F but read 0x7F at address 0x00000246.
[error] [  nRF52] - Failed while verifying device. -160: Data does not match in address range [0x00000000 - 0x00000AFF] (Flash)
Expected byte value 0x4F but read 0x7F at address 0x00000246.
[error] [ Worker] - Data does not match in address range [0x00000000 - 0x00000AFF] (Flash)
Expected byte value 0x4F but read 0x7F at address 0x00000246.
ERROR: Write verify failed.

Parents Reply
  • Hello,

    That may be the case. It may be that you are lucky and it works on the bad unit if you try to reduce the clockspeed. You can try to use the flag -c or --clockspeed to set the debugger SWD clockspeed. I see from your screenshots and logs that it is anywhere from 2000 to 4000 kHz, so try setting it to 1000, or even 500 kHz:

    nrfjprog --clockspeed 500 --eraseall
    nrfjprog --clockspeed 500 --program <path_to_hex> --verify

    Best regards,

    Edvin

Children
No Data
Related