MIMXRT1042 cannot write in external NOR flash

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MIMXRT1042 cannot write in external NOR flash

1,277 Views
tbonkers
Contributor II

I am working on a custom board with MIMXRT1042 and 2 x AT25FF081A-SSHN-T NOR flash memories connected to FlexSPI 1 and 2. Using MCUXpresso, I can build and flash application in RAM, downloading the application in flash via SWD seems to work, but the program does not run. It is stuck at the following place:

tbonkers_2-1700806107816.png

 

The processor's fuses are all in their default state:

tbonkers_1-1700805861300.png

I am using JLink, so I thought it may be the case that the programmer does not use suitable algorithm, and tried to flash via the serial bootloader, with no success.

tbonkers_0-1700805407300.png

Using JFlash, I can write/read from the NOR flash via SWD.

I have two questions:

1) Will enabling JTAG access and using JTAG instead of SWD have any effect?

2) Is there anything else I can do to verify the NOR flash chips work?

EDIT: I connected a logic analyzer to the flash signals - they all appear OK.

MCU Boot Utility also fails; log attached.

I would be really grateful if someone from NXP support looks at the issue.

Thanks

 

0 Kudos
Reply
6 Replies

1,147 Views
tbonkers
Contributor II

Bought a MCU-LINK debug probe and changed the board flash to W25Q16JVSNIQ. Also burned fuse BT_FUSE_SEL.

Still no luck. When trying to program the target I run into errors:

============= SCRIPT: RT1040_connect.scp =============
RT1040 Connect Script
DpID = 0BD11477
APID = 0x04770041
Disabling MPU
Configure FlexRAM for 256KB OC RAM, 128KB I-TCM, 128KB D-TCM
Finished
============= END SCRIPT =============================
Probe Firmware: MCU-LINK (r0FF) CMSIS-DAP V3.128 (NXP Semiconductors)
Serial Number:  4ZMOPUJTWS5ZG
VID:PID:  1FC9:0143
USB Path: 0002:0001:00
Using memory from core 0 after searching for a good core
debug interface type      = CoreSight DP (DAP DP ID 0BD11477) over SWD TAP 0
processor type            = Cortex-M7 (CPU ID 00000C27) on DAP AP 0
number of h/w breakpoints = 8
number of flash patches   = 0
number of h/w watchpoints = 4
Probe(0): Connected&Reset. DpID: 0BD11477. CpuID: 00000C27. Info: <None>
Debug protocol: SWD. RTCK: Disabled. Vector catch: Disabled.
Content of CoreSight Debug ROM(s):
RBASE E00FD000: CID B105100D PID 000008E88C ROM (type 0x1)
ROM 1 E00FE000: CID B105100D PID 04000BB4C8 ROM (type 0x1)
ROM 2 E00FF000: CID B105100D PID 04000BB4C7 ROM (type 0x1)
ROM 3 E000E000: CID B105E00D PID 04000BB00C Gen SCS (type 0x0)
ROM 3 E0001000: CID B105E00D PID 04000BB002 Gen DWT (type 0x0)
ROM 3 E0002000: CID B105E00D PID 04000BB00E Gen (type 0x0)
ROM 3 E0000000: CID B105E00D PID 04000BB001 Gen ITM (type 0x0)
ROM 2 E0041000: CID B105900D PID 04001BB975 CSt ARM ETMv4.0 type 0x13 Trace Source - Core
ROM 2 E0042000: CID B105900D PID 04004BB906 CSt type 0x14 Debug Control - Trigger, e.g. ECT
ROM 1 E0040000: CID B105900D PID 04000BB9A9 CSt type 0x11 Trace Sink - TPIU
ROM 1 E0043000: CID B105F00D PID 04001BB101 Sys (type 0x0)
NXP: MIMXRT1042xxxxB
DAP stride is 1024 bytes (256 words)
Inspected v.2 External Flash Device on SPI using SFDP JEDEC ID MIMXRT1040_SFDP_QSPI.cfx
Image 'iMXRT1040_SFDP_QSPI Mar 21 2023 13:23:10'
Opening flash driver MIMXRT1040_SFDP_QSPI.cfx
Sending VECTRESET to run flash driver
Flash variant 'JEDEC_SFDP_Device' detected (2MB = 32*64K at 0x60000000)
Closing flash driver MIMXRT1040_SFDP_QSPI.cfx
Connected: was_reset=false. was_stopped=true
Awaiting telnet connection to port 3330 ...
GDB nonstop mode enabled
FreeRTOS stack backtrace is disabled
Opening flash driver MIMXRT1040_SFDP_QSPI.cfx (already resident)
Sending VECTRESET to run flash driver
Flash variant 'JEDEC_SFDP_Device' detected (2MB = 32*64K at 0x60000000)
Writing 27360 bytes to address 0x60000000 in Flash
ProgramPage (0x60000000, 0x20005770, 0x4000) status 0x1 - driver reported driver error - EXTSPIJ driver rc 117 (0x75)
Sectors written: 1, unchanged: 0, total: 1
Closing flash driver MIMXRT1040_SFDP_QSPI.cfx
Target error from Commit Flash write: Ef(49): Flash driver operation gave error.
GDB stub (C:\nxp\MCUXpressoIDE_11.7.1_9221\ide\plugins\com.nxp.mcuxpresso.tools.bin.win32_11.7.1.202303220859\binaries\crt_emu_cm_redlink) terminating - GDB protocol problem: Pipe has been closed by GDB.

 

Googling for the above error leads to another thread. I tried following the steps outlined there, but they do not work for me. Flashing example "evkmimxrt1040_flexspi_nor_polling_transfer" without any modifications into RAM fails:

FLEXSPI example started!
Vendor ID: 0xef
Erasing Serial NOR over FlexSPI...
Erase data -  read out data value incorrect !

 

This turns to be a very difficult issue to solve.

0 Kudos
Reply

1,253 Views
tbonkers
Contributor II

A schematic of the memory below.

tbonkers_0-1700910034410.png

tbonkers_1-1700910113531.png

 

 

0 Kudos
Reply

1,202 Views
tbonkers
Contributor II

Update: I have flashed the SDK example evkmimxrt1040_flexspi_nor_polling_transfer, and it runs up until reading data from the flash, and then it fails. Below is the config struct:

 

const flexspi_nor_config_t qspiflash_config = {
    .memConfig =
        {
            .tag              = FLEXSPI_CFG_BLK_TAG,
            .version          = FLEXSPI_CFG_BLK_VERSION,
            .readSampleClksrc=kFlexSPIReadSampleClk_LoopbackFromDqsPad,
            .csHoldTime       = 6u,	// from flash datasheet
            .csSetupTime      = 6u,
            .sflashPadType    = kSerialFlash_4Pads,
            .serialClkFreq    = kFlexSpiSerialClk_100MHz,
            .sflashA1Size     = 1u * 1024u * 1024u,

            .lookupTable =
                {
                    // Read LUTs
                    FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18),
                    FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),
                },
        },
    .pageSize           = 256u,
    .sectorSize         = 4u * 1024u,
    .blockSize          = 64u * 1024u,
    .isUniformBlockSize = false,
};

 

 

Here's the serial output:

 

FLEXSPI example started!
Vendor ID: 0x1f
Erasing Serial NOR over FlexSPI...
Erase data - successfully.
Program data -  read out data value incorrect !

 

 

Program data fails, so I compared the buffer that was read out from the device with the expected value. It looks like it's shifted to the left, and some values are corrupted. Printing out the two buffers over the serial link:

 

FLEXSPI example started!
Vendor ID: 0x1f
Erasing Serial NOR over FlexSPI...
Erase data - successfully.
s_nor_read_buffer:
FE:FF: 4: 5: 6: 7: 8: 9: A: B: C:  E: F:10:11:12:13:14:15:16:17:18:19:1A:1B:1C:1D:1E:1F:20:21:22:23:24:25:26:27:28:29:2A:2B:2C:2D:2E:2F:30:31:32:33:34:35:36:37:38:39:3A:3B:3C:3D:3E:3F:40:41:42:43:44:45:46:47:48:49:4A:4B:4C:4D:4E:4F:50:51:52:53:54:55:56:57:58:59:5A:5B:5C:5D:5E:5F:60:61:62:63:64:65:66:67:68:69:6A:6B:6C:6D:6E:6F:70:71:72:73:74:75:76:77:78:79:7A:7B:7C:7D:7E:7F:80:81:82:83:84:85:86:87:88:89:8A:8B:8C:8D:8E:8F:90:91:92:93:94:95:96:97:98:99:9A:9B:9C:9D:9E:9F:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:AA:AB:AC:AD:AE:AF:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:BA:BB:BC:BD:BE:BF:C0:C1:C2:C3:C4:C5:C6:C7:C8:C9:CA:CB:CC:CD:CE:CF:D0:D1:D2:D3:D4:D5:D6:D7:D8:D9:DA:DB:DC:DD:DE:DF:E0:E1:E2:E3:E4:E5:E6:E7:E8:E9:EA:EB:EC:ED:EE:EF:F0:F1:F2:F3:F4:F5:F6:F7:F8:F9:FA:FB:FC:FD:FE:FF:FF:FF:
s_nor_program_buffer:
 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: A: B: C:  E: F:10:11:12:13:14:15:16:17:18:19:1A:1B:1C:1D:1E:1F:20:21:22:23:24:25:26:27:28:29:2A:2B:2C:2D:2E:2F:30:31:32:33:34:35:36:37:38:39:3A:3B:3C:3D:3E:3F:40:41:42:43:44:45:46:47:48:49:4A:4B:4C:4D:4E:4F:50:51:52:53:54:55:56:57:58:59:5A:5B:5C:5D:5E:5F:60:61:62:63:64:65:66:67:68:69:6A:6B:6C:6D:6E:6F:70:71:72:73:74:75:76:77:78:79:7A:7B:7C:7D:7E:7F:80:81:82:83:84:85:86:87:88:89:8A:8B:8C:8D:8E:8F:90:91:92:93:94:95:96:97:98:99:9A:9B:9C:9D:9E:9F:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:AA:AB:AC:AD:AE:AF:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:BA:BB:BC:BD:BE:BF:C0:C1:C2:C3:C4:C5:C6:C7:C8:C9:CA:CB:CC:CD:CE:CF:D0:D1:D2:D3:D4:D5:D6:D7:D8:D9:DA:DB:DC:DD:DE:DF:E0:E1:E2:E3:E4:E5:E6:E7:E8:E9:EA:EB:EC:ED:EE:EF:F0:F1:F2:F3:F4:F5:F6:F7:F8:F9:FA:FB:FC:FD:FE:FF:

 

 

I tried reducing the flexspiRootClk, but no results.

However, when changed deviceconfig.ARDSeqIndex to NOR_CMD_LUT_SEQ_IDX_READ_FAST, the example runs fine:

 

flexspi_device_config_t deviceconfig = {
    .flexspiRootClk       = 100000000,
    .flashSize            = FLASH_SIZE,
    .CSIntervalUnit       = kFLEXSPI_CsIntervalUnit1SckCycle,
    .CSInterval           = 2,
    .CSHoldTime           = 6,
    .CSSetupTime          = 6,
    .dataValidTime        = 1,
    .columnspace          = 0,
    .enableWordAddress    = 0,
    .AWRSeqIndex          = 0,
    .AWRSeqNumber         = 0,
    .ARDSeqIndex          = NOR_CMD_LUT_SEQ_IDX_READ_FAST,
    .ARDSeqNumber         = 1,
    .AHBWriteWaitUnit     = kFLEXSPI_AhbWriteWaitUnit2AhbCycle,
    .AHBWriteWaitInterval = 0,
};

 

 

Does that mean that the flash is not working in Quad mode?

My question now is how to ensure Flash is working in Quad mode, and how to generate a working FCB from the RAM image, it this is possible.

0 Kudos
Reply

1,179 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi @tbonkers ,

 

It is an expected result since you are using single wire flash with RT, please update LUT to single wire mode and try again.

Kan_Li_0-1701242753620.png

 

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

 

0 Kudos
Reply

1,160 Views
tbonkers
Contributor II
Hi Kan,
I am not sure how to do this. Can you point me to a resource which shows how to initialize Flash in Quad mode, and be able to upload code to Flash?
My previous post referred to flashing the code example into RAM.

Thanks
0 Kudos
Reply

1,120 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi @tbonkers ,

 

please kindly refer to the data sheet of the qspi flash for details.https://www.renesas.com/us/en/products/memory-logic/non-volatile-memory/spi-nor-flash/at25ff081a-8mb... 

 

Kan_Li_0-1701933129137.png

 

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

 

0 Kudos
Reply