[SOLVED] J-Link Script: How to write a value to NVM USER AREA Flash

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

  • [SOLVED] J-Link Script: How to write a value to NVM USER AREA Flash

    Hi,

    I'm writing a script to update some fuses in the NVM USER AREA of a Microchip SAME54 Microcontroller.

    The script reads some values, changes some flags, erases the User Area page then fails on the write back.

    It fails with the following error message on the SEGGER J-Flash:

    - ERROR: Error while evaluating J-Link script file: Error while compiling. Line 103, column 62:
    JLINK_MEM_WriteU32(0x00804000 + n * 4, NVM[n * 4]);
    ^
    Internal: Destination register not allocated

    Is this because I'm trying to write to flash and the JLINK_MEM_WriteU32() function doesn't support it?
    Is there a method for writing to flash in J-Link Script?

    Thanks.

    Regards, Mike.
  • Possible solution...

    replace

    JLINK_MEM_WriteU32(0x00804000 + n * 4, NVM[n * 4);

    with

    NVMVal = NVM[n * 4];
    JLINK_MEM_WriteU32(0x00804000 + n * 4, NVMVal);

    Maybe the JLINK_MEM_WriteU32() function can't handle the array indexing.

    Regards, Mike.