Error in programming SAMD51N19A => Failed to prepare RAMCode using RAM

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Error in programming SAMD51N19A => Failed to prepare RAMCode using RAM

      for a faster programming in developing I am writing a script resp. batch file, which calls the corresponding functions/commands of J-link in the CMD window.

      I have J-Flash software V.6.98c installed and I use a J-LINK plus
      The controller I use is a SAMD51N19A, there is no external flash or ram connected to it.

      With this skript I do
      -resetting the fuse bits
      -erasing the device from 0x00000 to 0x7FFFF
      then programming
      -setting the fuse bits

      When I do this, i get the error
      "Error: failed to prepare RAMCode using RAM
      Error while determining flash info (Bank @ 0x04000000)
      ERROR: Erase retunred with error code - 1

      The error also comes up when I try to erase the "whole" RAM, resp. I dont use the erase with the range indication.
      If I do the script without the erase command, it works. But I need to erase it first (I guess this should be done...)
      Anyway, the error also comes up, when I use the j-flash - software itself in "Target => Manual Programming => Erase Chip"

      I read a lot in this forum of people having similar problems. But I could not figure out any solution that would work for my problem.

      Has anybody an idea how to eliminate this error?





      Here is a part of my bat-file:

      echo connect > script.jlink
      echo r >> script.jlink
      echo w4 0x00804000 0xFE9A9235 >> script.jlink
      echo w4 0x00804004 0xAEECFF80 >> script.jlink
      echo erase [0x000000, 0x7FFFF]>> script.jlink
      echo loadfile "%hexfile%" >> script.jlink
      echo w4 0x00804000 0xEE9A9234 >> script.jlink
      echo w4 0x00804004 0xAEECFF80 >> script.jlink
      echo r >> script.jlink
      echo g >> script.jlink
      echo q >> script.jlink

      :FLASH
      jlink.exe -device ATSAMD51N19 -if SWD -speed 4000 -CommanderScript script.jlink -autoconnect 1 -ExitOnError 0
      IF %errorlevel% == 0 GOTO PASS
      IF %errorlevel% NEQ 0 GOTO ERROR
    • Hello,

      Thank you for your inquiry.
      Such an issue is not known to us.
      Could you provide a J-Link log of the failing session?
      Does this issue appear with any image programmed or just this specific one?

      Best regards,
      Nino
      Please read the forum rules before posting: Forum Rules

      Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Hello,

      This appears with all of the images I have.

      Here's a log of the failing session:

      ********************************************************************************************************************************************************************
      SEGGER J-Link Commander V6.98c (Compiled Mar 16 2021 12:20:44)
      DLL version V6.98e, compiled Mar 29 2021 14:18:39

      J-Link Commander will now exit on Error

      J-Link Command File read successfully.
      Processing script file...

      J-Link connection not established yet but required for command.
      Connecting to J-Link via USB...O.K.
      Firmware: J-Link V10 compiled Feb 4 2021 12:58:41
      Hardware version: V10.10
      S/N: 600116830
      License(s): RDI, FlashBP, FlashDL, JFlash, GDB
      VTref=3.315V
      Device "ATSAMD51N19" selected.


      Connecting to target via SWD
      InitTarget() start
      InitTarget()
      InitTarget() end
      InitTarget() end
      Found SW-DP with ID 0x2BA01477
      DPIDR: 0x2BA01477
      Scanning AP map to find all available APs
      AP[2]: Stopped AP scan as end of AP map seems to be reached
      AP[0]: AHB-AP (IDR: 0x24770011)
      AP[1]: AHB-AP (IDR: 0x74770001)
      Iterating through AP map to find AHB-AP to use
      AP[0]: Core found
      AP[0]: AHB-AP ROM base: 0x41003000
      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] @ 41003000
      ROMTbl[0][0]: E00FF000, CID: B105100D, PID: 000BB4C4 ROM Table
      ROMTbl[1] @ E00FF000
      ROMTbl[1][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
      ROMTbl[1][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
      ROMTbl[1][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
      ROMTbl[1][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
      ROMTbl[1][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
      ROMTbl[1][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
      ROMTbl[1][6]: E0042000, CID: B105900D, PID: 003BB907 ETB
      Cortex-M4 identified.

      Reset delay: 0 ms
      Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
      Reset: Halt core after reset via DEMCR.VC_CORERESET.
      Reset: Reset device via AIRCR.SYSRESETREQ.

      Writing FE9A9235 -> 00804000

      Writing AEECFF80 -> 00804004

      Without any give address range, Erase Chip will be executed
      Erasing device...
      J-Link: Flash download: Total time needed: 2.777s (Prepare: 0.102s, Compare: 0.000s, Erase: 2.672s, Program: 0.000s, Verify: 0.000s, Restore: 0.003s)
      J-Link: Flash download: Total time needed: 0.068s (Prepare: 0.020s, Compare: 0.000s, Erase: 0.045s, Program: 0.000s, Verify: 0.000s, Restore: 0.003s)

      ****** Error: Failed to prepare RAMCode using RAM
      Error while determining flash info (Bank @ 0x04000000)
      ERROR: Erase returned with error code -1.

      Script processing completed.

      ERROR
      ********************************************************************************************************************************************************************