J-Flash sector erase (RMW threshold needed)

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

  • J-Flash sector erase (RMW threshold needed)

    Hi,

    I had an earlier thread: [SOLVED] JFlash overwrites incorrect pages where Segger provided a solution using GDB to prevent the J-Link erasing data in the flash that we need to protect. I have the same problem with J-Flash: we use a 2-step programming process, where the 2nd step writes data into a sector that already contains code (but the data doesn't overlap). In our case the code is at 0x0 - 0x7fdff, and some data is placed at 0x7fe00 - 0x7ffff. The flash sector size is 32kB, so sector 15 has range 0x78000-0x7ffff. When writing the data, J-Flash erases sector 15, and part of the code is lost.
    We solved that for GDB by using the J-Link command "SetFlashDLNoRMWThreshold = 0xffffffff", and I want to do the same for J-Flash. I tried to put that command in a J-Link script file (see attached), but get errors from J-Flash during the load operation:



    - Connected successfully
    Checking if selected data fits into selected flash sectors.
    Programming and verifying target (580548 bytes, 3 ranges) ...
    - Start of preparing flash programming
    - ERROR: Can not read register 20 (CFBP) while CPU is running
    - ERROR: CPU is not halted
    - ERROR: Timeout while checking target RAM, RAMCode did not respond in time
    - ERROR: Failed to prepare for programming.
    Failed to execute RAMCode for RAM check!
    - End of preparing flash programming
    - ERROR: Failed to program and verify target
    Disconnecting ...
    - Disconnected

    I'm not sure if this command should be placed in the InitTarget() function, or if there are other commands needed before it.

    Can you provide an example of this command in a Jlink script file, or point out the issue?

    Thanks,

    Henry
    Files
  • Hi Henry,


    By specifying InitTarget(), the default InitTarget() is overwritten.

    For this use case, I would recommend to use SetupTarget(), which is called after InitTarget() and is not implemented by default,
    thus it is possible to extend the SEGGER software without changing any existing behavior.


    Best regards,
    Niklas
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    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.
  • Hi Niklas,

    I modified the script to put the J-Link command in the SetupTarget() function as you suggested, but the issue is still the same: in the J-Flash log I can see the following:

    - Start of blank checking
    - End of blank checking
    - Erasing range 0x00070000 - 0x00077FFF (001 Sector, 32 KB)
    - Start of blank checking
    - End of blank checking
    - Erasing range 0x00078000 - 0x0007FFFF (001 Sector, 32 KB)
    - End of erasing sectors
    - Start of flash programming
    ...etc

    So even though the RMW limit is very high (0xffffffff), J-Flash is still doing a sector erase. Can you suggest a solution?

    Thanks,

    Henry
    Files
  • Hi Henry,


    I reached out to the PM of J-Flash regarding this issue.
    Currently, J-Flash ignores the Threshold and never executes a read-modify-write.
    This is intended, since J-Flash is a production tool.
    In our case the code is at 0x0 - 0x7fdff, and some data is placed at 0x7fe00 - 0x7ffff.

    May I ask why the data files are not merged before production?
    Data files can be merged using J-Flash either via GUI or (automated) via the command line interface.



    Best regards,
    Niklas
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    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.
  • Hi Niklas,

    Thanks for your comments.
    May I ask why the data files are not merged before production?
    Our process is to load the application (executable and data), and in a second step, load the device's security certificate. Our production tool uses a single .hex file for the application, and then fetches the next serial/key from a database, and programs it. Unfortunately due to the very large sector size in the LPC, we can't afford a whole page for the certificate. Is there any way to perform the 1st stage as an erase-program-verify process, and the second as program-verify only? I don't see a 'don't erase' option in J-Flash.

    Thanks,

    Henry