write in the flash in twice

  • hi,
    I use RT1176 and i have to write flash (mapped to 0x30000000)
    The FW is divided into two parts,

    • a first part called the boot header exactly 8K in size
    • a second part which is the actual application and starts at offset 0x2000.

    For each of the two parts I have an elf file.


    How do I write both parts into the flash using a script?

    I tried the following script:

    Code
    device MIMXRT1176xxxA_M7
    if SWD
    speed auto
    connect
    sleep 1
    loadfile "FW/image/Ama_BootHdr.elf"
    sleep 1
    loadfile "FW/image/Ama.elf"
    exit


    But I get a timeout error when trying to write the second part:

    in particular I notice that the affected ranges for the boot header is 64KB which corresponds to the largest erasable sector of my flash. In addition, I have a verification error.

    I tried swapping the two files:

    Code
    device MIMXRT1176xxxA_M7
    if SWD
    speed auto
    connect
    sleep 1
    loadfile "FW/image/Ama.elf"
    sleep 1
    loadfile "FW/image/Ama_BootHdr.elf"
    exit


    the behavior changes, I no longer have timeouts:


    for both parts I have the address 0x30000000, which is incorrect for the application, and the affected range is 262144 for both. They also both fail verification.


    so how should the script be for me to write the two parts, verifying both?

    best regards
    Max

  • Hello,

    The cause of the issue you are referring to is that the J-Link erases the whole sector before programming it.

    To resolve this issue, you can either:

    1. Combine the data of the two .elf files into one data file and then flash this single file.Or
    2. Set the RMW threshold to 64KB via "exec SetFlashDLNoRMWThreshold 0x10000", then program the larger .elf file first and the smaller one afterward.

    For more details, please refer to SetFlashDLNoRMWThreshold .

    Best regards,
    Simon

    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: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!