write in the flash in twice

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

  • 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:

    Source Code

    1. device MIMXRT1176xxxA_M7
    2. if SWD
    3. speed auto
    4. connect
    5. sleep 1
    6. loadfile "FW/image/Ama_BootHdr.elf"
    7. sleep 1
    8. loadfile "FW/image/Ama.elf"
    9. exit




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

    Source Code

    1. SEGGER J-Link Commander V7.92n (Compiled Oct 31 2023 15:15:57)
    2. DLL version V7.92n, compiled Oct 31 2023 15:15:34
    3. J-Link Command File read successfully.
    4. Processing script file...
    5. J-Link>device MIMXRT1176xxxA_M7
    6. J-Link connection not established yet but required for command.
    7. Connecting to J-Link via USB...O.K.
    8. Firmware: J-Link Ultra V4 compiled Sep 22 2022 15:00:10
    9. Hardware version: V4.00
    10. J-Link uptime (since boot): N/A (Not supported by this model)
    11. S/N: 504400379
    12. License(s): RDI, FlashBP, FlashDL, JFlash, GDB
    13. VTref=3.308V
    14. J-Link>if SWD
    15. Selecting SWD as current target interface.
    16. J-Link>speed auto
    17. Selecting auto as target interface speed
    18. J-Link>connect
    19. Device "MIMXRT1176XXXA_M7" selected.
    20. Connecting to target via SWD
    21. Found SW-DP with ID 0x6BA02477
    22. DPIDR: 0x6BA02477
    23. CoreSight SoC-400 or earlier
    24. Scanning AP map to find all available APs
    25. AP[3]: Stopped AP scan as end of AP map has been reached
    26. AP[0]: AHB-AP (IDR: 0x84770001)
    27. AP[1]: AHB-AP (IDR: 0x24770011)
    28. AP[2]: APB-AP (IDR: 0x54770002)
    29. Iterating through AP map to find AHB-AP to use
    30. AP[0]: Core found
    31. AP[0]: AHB-AP ROM base: 0xE00FD000
    32. CPUID register: 0x411FC272. Implementer code: 0x41 (ARM)
    33. Cache: L1 I/D-cache present
    34. Found Cortex-M7 r1p2, Little endian.
    35. FPUnit: 8 code (BP) slots and 0 literal slots
    36. CoreSight components:
    37. ROMTbl[0] @ E00FD000
    38. [0][0]: E00FE000 CID B105100D PID 000BB4C8 ROM Table
    39. ROMTbl[1] @ E00FE000
    40. [1][0]: E00FF000 CID B105100D PID 000BB4C7 ROM Table
    41. ROMTbl[2] @ E00FF000
    42. [2][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7
    43. [2][1]: E0001000 CID B105E00D PID 000BB002 DWT
    44. [2][2]: E0002000 CID B105E00D PID 000BB00E FPB-M7
    45. [2][3]: E0000000 CID B105E00D PID 000BB001 ITM
    46. [1][1]: E0041000 CID B105900D PID 001BB975 ETM-M7
    47. [1][2]: E0042000 CID B105900D PID 004BB906 CTI
    48. [0][1]: E0043000 CID B105900D PID 001BB908 CSTF
    49. I-Cache L1: 32 KB, 512 Sets, 32 Bytes/Line, 2-Way
    50. D-Cache L1: 32 KB, 256 Sets, 32 Bytes/Line, 4-Way
    51. Memory zones:
    52. Zone: "Default" Description: Default access mode
    53. Cortex-M7 identified.
    54. J-Link>sleep 1
    55. Sleep(1)
    56. J-Link>loadfile "FW/image/Ama_BootHdr.elf"
    57. 'loadfile': Performing implicit reset & halt of MCU.
    58. Reset: Halt core after reset via DEMCR.VC_CORERESET.
    59. Reset: Reset device via AIRCR.SYSRESETREQ.
    60. Core did not halt after reset, halting it manually.
    61. AfterResetTarget() start
    62. Valid application detected. Setting PC / SP manually.
    63. Booting from FlexSPI1.
    64. AfterResetTarget() end - Took 52.8ms
    65. Downloading file [FW/image/Ama_BootHdr.elf]...
    66. J-Link: Flash download: Bank 0 @ 0x30000000: 1 range affected (65536 bytes)
    67. J-Link: Flash download: Total: 1.457s (Prepare: 0.277s, Compare: 0.212s, Erase: 0.467s, Program: 0.000s, Verify: 0.499s, Restore: 0.000s)
    68. J-Link: Flash download: Program speed: 0 KB/s
    69. ****** Error: Verification failed @ address 0x30000000
    70. Timeout while programming sector, RAMCode did not respond in time!
    71. Error while programming flash: Verify failed.
    72. J-Link>sleep 1
    73. Sleep(1)
    74. J-Link>loadfile "FW/image/Ama.elf"
    75. 'loadfile': Performing implicit reset & halt of MCU.
    76. Reset: Halt core after reset via DEMCR.VC_CORERESET.
    77. Reset: Reset device via AIRCR.SYSRESETREQ.
    78. Reset: SYSRESETREQ has confused core.
    79. Found SW-DP with ID 0x6BA02477
    80. DPIDR: 0x6BA02477
    81. CoreSight SoC-400 or earlier
    82. AP map detection skipped. Manually configured AP map found.
    83. AP[0]: AHB-AP (IDR: Not set)
    84. AP[0]: Core found
    85. AP[0]: AHB-AP ROM base: 0xE00FD000
    86. CPUID register: 0x411FC272. Implementer code: 0x41 (ARM)
    87. Cache: L1 I/D-cache present
    88. Found Cortex-M7 r1p2, Little endian.
    89. Reset: Using fallback: VECTRESET.
    90. Reset: Halt core after reset via DEMCR.VC_CORERESET.
    91. Reset: Reset device via AIRCR.VECTRESET.
    92. AfterResetTarget() start
    93. AfterResetTarget() end - Took 159ms
    94. Downloading file [FW/image/Ama.elf]...
    95. ****** Error: Timeout while get device description, RAMCode did not respond in time!
    96. SEGGER_OPEN_GetFlashInfo(): RAMCode never stops. failed to determine dynamic flash info.
    97. Error while determining flash info (Bank @ 0x30000000)
    98. Unspecified error -1
    99. J-Link>exit
    100. Script processing completed.
    Display All
    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:

    Source Code

    1. device MIMXRT1176xxxA_M7
    2. if SWD
    3. speed auto
    4. connect
    5. sleep 1
    6. loadfile "FW/image/Ama.elf"
    7. sleep 1
    8. loadfile "FW/image/Ama_BootHdr.elf"
    9. exit

    the behavior changes, I no longer have timeouts:


    Source Code

    1. SEGGER J-Link Commander V7.92n (Compiled Oct 31 2023 15:15:57)
    2. DLL version V7.92n, compiled Oct 31 2023 15:15:34
    3. J-Link Command File read successfully.
    4. Processing script file...
    5. J-Link>device MIMXRT1176xxxA_M7
    6. J-Link connection not established yet but required for command.
    7. Connecting to J-Link via USB...O.K.
    8. Firmware: J-Link Ultra V4 compiled Sep 22 2022 15:00:10
    9. Hardware version: V4.00
    10. J-Link uptime (since boot): N/A (Not supported by this model)
    11. S/N: 504400379
    12. License(s): RDI, FlashBP, FlashDL, JFlash, GDB
    13. VTref=3.308V
    14. J-Link>if SWD
    15. Selecting SWD as current target interface.
    16. J-Link>speed auto
    17. Selecting auto as target interface speed
    18. J-Link>connect
    19. Device "MIMXRT1176XXXA_M7" selected.
    20. Connecting to target via SWD
    21. Found SW-DP with ID 0x6BA02477
    22. DPIDR: 0x6BA02477
    23. CoreSight SoC-400 or earlier
    24. Scanning AP map to find all available APs
    25. AP[3]: Stopped AP scan as end of AP map has been reached
    26. AP[0]: AHB-AP (IDR: 0x84770001)
    27. AP[1]: AHB-AP (IDR: 0x24770011)
    28. AP[2]: APB-AP (IDR: 0x54770002)
    29. Iterating through AP map to find AHB-AP to use
    30. AP[0]: Core found
    31. AP[0]: AHB-AP ROM base: 0xE00FD000
    32. CPUID register: 0x411FC272. Implementer code: 0x41 (ARM)
    33. Cache: L1 I/D-cache present
    34. Found Cortex-M7 r1p2, Little endian.
    35. FPUnit: 8 code (BP) slots and 0 literal slots
    36. CoreSight components:
    37. ROMTbl[0] @ E00FD000
    38. [0][0]: E00FE000 CID B105100D PID 000BB4C8 ROM Table
    39. ROMTbl[1] @ E00FE000
    40. [1][0]: E00FF000 CID B105100D PID 000BB4C7 ROM Table
    41. ROMTbl[2] @ E00FF000
    42. [2][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7
    43. [2][1]: E0001000 CID B105E00D PID 000BB002 DWT
    44. [2][2]: E0002000 CID B105E00D PID 000BB00E FPB-M7
    45. [2][3]: E0000000 CID B105E00D PID 000BB001 ITM
    46. [1][1]: E0041000 CID B105900D PID 001BB975 ETM-M7
    47. [1][2]: E0042000 CID B105900D PID 004BB906 CTI
    48. [0][1]: E0043000 CID B105900D PID 001BB908 CSTF
    49. I-Cache L1: 32 KB, 512 Sets, 32 Bytes/Line, 2-Way
    50. D-Cache L1: 32 KB, 256 Sets, 32 Bytes/Line, 4-Way
    51. Memory zones:
    52. Zone: "Default" Description: Default access mode
    53. Cortex-M7 identified.
    54. J-Link>sleep 1
    55. Sleep(1)
    56. J-Link>loadfile "FW/image/Ama.elf"
    57. 'loadfile': Performing implicit reset & halt of MCU.
    58. Reset: Halt core after reset via DEMCR.VC_CORERESET.
    59. Reset: Reset device via AIRCR.SYSRESETREQ.
    60. Core did not halt after reset, halting it manually.
    61. AfterResetTarget() start
    62. Valid application detected. Setting PC / SP manually.
    63. Booting from FlexSPI1.
    64. AfterResetTarget() end - Took 53.1ms
    65. Downloading file [FW/image/Ama.elf]...
    66. J-Link: Flash download: Bank 0 @ 0x30000000: 1 range affected (262144 bytes)
    67. J-Link: Flash download: Total: 6.568s (Prepare: 0.326s, Compare: 1.632s, Erase: 1.835s, Program: 2.173s, Verify: 0.402s, Restore: 0.196s)
    68. J-Link: Flash download: Program speed: 117 KB/s
    69. ****** Error: Verification failed @ address 0x30000000
    70. Error while programming flash: Verify failed.
    71. J-Link>sleep 1
    72. Sleep(1)
    73. J-Link>loadfile "FW/image/Ama_BootHdr.elf"
    74. 'loadfile': Performing implicit reset & halt of MCU.
    75. Reset: Halt core after reset via DEMCR.VC_CORERESET.
    76. Reset: Reset device via AIRCR.SYSRESETREQ.
    77. Core did not halt after reset, halting it manually.
    78. AfterResetTarget() start
    79. Valid application detected. Setting PC / SP manually.
    80. Booting from FlexSPI1.
    81. AfterResetTarget() end - Took 53.0ms
    82. Downloading file [FW/image/Ama_BootHdr.elf]...
    83. J-Link: Flash download: Bank 0 @ 0x30000000: 1 range affected (262144 bytes)
    84. J-Link: Flash download: Total: 6.592s (Prepare: 0.326s, Compare: 1.627s, Erase: 1.805s, Program: 2.234s, Verify: 0.402s, Restore: 0.195s)
    85. J-Link: Flash download: Program speed: 114 KB/s
    86. ****** Error: Verification failed @ address 0x30000000
    87. Error while programming flash: Verify failed.
    88. J-Link>exit
    89. Script processing completed.
    Display All
    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: segger.com/ticket/

    Or you can contact us via e-mail.