Hi Team,
I am working with the MIMXRT1040-EVK and using MCUXpresso IDE with LinkServer/SWD.
I am facing an issue where my application works correctly when linked and executed from RAM, but when configured to execute from external FlexSPI NOR Flash, the debugger does not reach main().
RAM build:
"Link application to RAM" enabled
Application downloads successfully
Application executes correctly
Debugger reaches main()
I can debug the application normally
Flash/XIP build:
"Link application to RAM" disabled
Application is linked to external Flash starting at 0x60000000
Build completes successfully
.axf is generated
When I start debugging, the debugger does not reach main()
The CPU does not appear to execute from the expected 0x600xxxxx XIP address range
The generated .map file shows the expected XIP layout:
.boot_hdr 0x60000000
.boot_hdr.conf 0x60000000
.boot_hdr.ivt 0x60001000
.boot_hdr.boot_data
0x60001020
.text 0x60002000
.isr_vector 0x60002000
ResetISR 0x6000231C
main 0x60004EF4So the application appears to contain the expected FlexSPI NOR boot header, IVT, boot data, vector table, ResetISR, and application code.
I also have:
XIP_EXTERNAL_FLASH = 1 XIP_BOOT_HEADER_ENABLE = 1
After attempting to debug/program the Flash image, I checked the memory at:
0x60000000 0x60001000 0x60002000
and the memory window shows 0x00000000/empty data rather than the expected application contents.
For example, at:
0x60002000
I expected the application vector table, but the memory appears to contain zeros.
The CPU registers after the failed debug attempt also showed:
PC = 0x0020E368 SP = 0x20200F70 LR = 0x0020ED49
rather than a PC in the expected 0x600xxxxx XIP region.
I am using:
Debug Connection: SWD Connect script: RT1040_connect.scp
The Debug configuration has:
Load image: enabled Use project binary: igpio_led_output.axf Load symbols: enabled Use project binary: igpio_led_output.axf Set breakpoint at: main Request hardware breakpoint: enabled
The LinkServer Debug configuration is being used.
The project contains the standard XIP-related files:
xip/ ├── evkmimxrt1040_flexspi_nor_config.c ├── evkmimxrt1040_flexspi_nor_config.h ├── fsl_flexspi_nor_boot.c └── fsl_flexspi_nor_boot.h
The generated linker script also places the boot header and application into the BOARD_FLASH region beginning at 0x60000000.
Could someone please help me determine why the external FlexSPI NOR Flash is not being programmed with the generated XIP image when launching the LinkServer debug session?
Specifically:
Does the MIMXRT1040-EVK + LinkServer require a specific FlexSPI NOR Flash driver/configuration for debugging XIP applications?
Is RT1040_connect.scp sufficient for both connecting and programming the external NOR Flash?
Is there any additional Flash programming configuration required in the MCUXpresso Debug Configuration?
Should the Debug configuration use a specific flexspi_nor Flash driver or Flash Tool configuration?
Is there a known issue with LinkServer + MIMXRT1040 + external FlexSPI NOR + XIP debugging where the .axf is loaded as symbols but the external Flash is not actually programmed?
Is there a recommended NXP example project/configuration that I can compare against for a working MIMXRT1040-EVK FlexSPI NOR XIP debug session?
I would appreciate any guidance on what I should check next.
Thank you.
Thank you for the response.
I checked the MCU Settings → Memory details as you suggested. I have attached the screenshot.
The BOARD_FLASH memory is configured as:
Location: 0x60000000
Size: 0x800000
Flash Driver: MIMXRT1040_SFDP_QSPI.cfx
So, it appears that the specific external Flash driver is already configured for BOARD_FLASH.
I also tried the Serial Download Mode + MCU Provisioning Tool procedure. I was able to successfully Build Image and Write Image using the MCU Provisioning Tool.
However, after that, I was still unable to get the application programmed/debugged from Flash through the normal MCUXpresso + LinkServer debug flow.
Interestingly, when I tried flashing/debugging the code one more time later, it suddenly worked and the application was successfully running from Flash.
I did not intentionally change the project configuration, Flash driver, linker configuration, or boot settings between the failed and successful attempts.
So, at this point, I suspect there may be some intermittent issue related to the Flash programming/initialization/reset sequence rather than the application/linker configuration itself.
Could you please advise what could cause this behavior on the MIMXRT1040-EVK?
In particular:
Since the same configuration eventually worked without any intentional change, I would like to understand what could have caused the previous failure so that we can make the Flash debugging/programming reliable.
Thank you.
Hi @Prashanth1 ,
Based on the screenshot you provided, the Flash driver configuration appears to be fine.
Could you first try putting the board into serial download mode and using the MCUXpresso Secure Provisioning Tool to download the image to Flash by usb/uart?
This method isolates the influence of the debugger and can be used to check whether the board has any flash hardware issues. Additionally, please provide me with the log of the failed download attempt using the debugger.
On my end, I’ll arrange for an RT1040-EVK as soon as possible and try to reproduce the issue using the project package you previously attached.
Best regards,
Gavin
Hi Gavin Sir,
Thank you for the response.
I checked the MCU Settings → Memory details as you suggested. I have attached a screenshot.
In my project, the BOARD_FLASH memory is configured as:
So, it appears that the FlexSPI NOR Flash driver is already associated with the BOARD_FLASH memory region.
However, I noticed that the “Default LinkServer Flash Driver” field at the top of the MCU Settings is blank, while the driver column for BOARD_FLASH shows MIMXRT1040_SFDP_QSPI.cfx.
Could you please confirm:
My main issue is that the application is correctly linked for XIP at 0x60000000, but after launching the LinkServer debug session, I don't see the application contents at 0x60000000 / 0x60002000 in the Memory window.
RAM debugging works correctly with the same application.
I have attached the MCU Settings screenshot for reference.
Thank you.
Hi @Prashanth1 ,
Thanks for your interest in NXP MIMXRT series!
When using an external Flash, a specific Flash driver is required. Please check whether the Flash driver has been loaded correctly in the IDE: (My screenshot uses the RT1170 as an example; the process is similar for the RT1040.)
Best regards,
Gavin
Hi @Prashanth1 ,
Based on the described phenomenon, the most likely cause is that there was dirty data/image in the Flash memory previously. Whether it is an incorrect FCB header or an image that causes the MCU to enter an error state upon execution, such issues can lead to failure when attempting to re-flash the image. The standard recovery method in this scenario is to enter serial download mode. You may want to consult this article: https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs-Knowledge/RT-board-recovery-for-debugger-connect...
Regarding the selection of the flash loader, you simply need to select the appropriate flash driver in the "Flash" row within the IDE. The *.scp file is provided with the SDK and is used for pre-configuring the link server; You can go into the file to learn more about each line of command.
Best regards,
Gavin