flexspi_nor_config.[ch] for Macronix MX66L1G45G?

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

flexspi_nor_config.[ch] for Macronix MX66L1G45G?

Jump to solution
3,372 Views
Littell
Contributor III

Is there a flexspi_nor_config.[ch] available for the Macronix MX66L1G45G?  This device seems notably different from the Winbond W25Q512NW device on the RT1170 EVKB and I'm not sure how to proceed in modifying the files from the EVKB to support the Macronix.

1 Solution
3,129 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Littell ,

   Thanks for your updated information.

  Yes, you also can use the winbond QSPI if you don't want to do more modification. At least, our EVKB based on it, the debugger programmer, and the sample code are all based on it, it may save your time to do to the related modification.

   Anyway, if you meet any issues in the future, welcome to create the question post, and let us know.

Best Regards,

kerry

View solution in original post

0 Kudos
Reply
7 Replies
3,320 Views
Littell
Contributor III

Hi, Kerry!  Thanks very much for the response.  Maybe it would be easier if we go through the areas I'm having trouble.  Here's the flexspi_nor_config.c (base on the evkbmimxrt1170_... file) that I've tried to adapt to the Macronix:

/* Based on evkbmimxrt1170_flexspi_nor_config.c & adapted to the Macronix MX66L1G45G device. */

#include "flexspi_nor_config.h"

/* Component ID definition, used by tools. */
#ifndef FSL_COMPONENT_ID
#define FSL_COMPONENT_ID "platform.drivers.xip_board"
#endif

/*******************************************************************************
 * Code
 ******************************************************************************/
#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
__attribute__((section(".boot_hdr.conf"), used))
#elif defined(__ICCARM__)
#pragma location = ".boot_hdr.conf"
#endif

#define FLASH_DUMMY_CYCLES 0x06
#define FLASH_DUMMY_VALUE  0x01  /* See MX66L1G45G Data Sheet Table 10 "Quad Output Fast Read" @ 104 MHz */

const flexspi_nor_config_t qspiflash_config = {
    .memConfig =
        {
            .tag              = FLEXSPI_CFG_BLK_TAG,
            .version          = FLEXSPI_CFG_BLK_VERSION,
            .readSampleClksrc=kFlexSPIReadSampleClk_LoopbackFromDqsPad,
            .csHoldTime       = 3u,
            .csSetupTime      = 3u,
            // Enable DDR mode, Wordaddassable, Safe configuration, Differential clock, etc.
            .controllerMiscOption = (0x1 <<  | (0x1 << 4),
            .deviceType           = kFlexSpiDeviceType_SerialNOR,
            .sflashPadType        = kSerialFlash_4Pads,
            .serialClkFreq        = kFlexSpiSerialClk_100MHz,
            .sflashA1Size         = 128u * 1024u * 1024u,
            /* Enable flash configuration feature */
            .configCmdEnable   = 1u,
            .configModeType[0] = kDeviceConfigCmdType_Generic,
            /* Set configuration command sequences */
            .configCmdSeqs[0] =
                {
                    .seqNum   = 1,
                    .seqId    = 12,
                    .reserved = 0,
                },
            /* Macronix Configuration Register? (page 38): write the DC[1:0] bits, set "4 BYTE", default ODS[2:0] */
            .configCmdArgs[0] = (FLASH_DUMMY_VALUE << 6) | (0x1 << 5) | (0x7),
            .lookupTable =
                {
                    // Read: (4READ4B)
                    [0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEC, RADDR_SDR, FLEXSPI_4PAD, 0x20),
                    [1] = FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, FLASH_DUMMY_CYCLES, READ_SDR, FLEXSPI_4PAD, 0x04),

                    // Read Status: (RDSR)
                    [4 * 1 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05, READ_SDR, FLEXSPI_1PAD, 0x04),

                    // Write Enable: (WREN)
                    [4 * 3 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06, STOP, FLEXSPI_1PAD, 0x0),

                    // Erase Sector: (SE4B)
                    [4 * 5 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x21, RADDR_SDR, FLEXSPI_1PAD, 0x20),

                    // Erase Block: (BE)
                    [4 * 8 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8, RADDR_SDR, FLEXSPI_1PAD, 0x18),

                    // Page Program: (PP4B)
                    [4 * 9 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x12, RADDR_SDR, FLEXSPI_1PAD, 0x20),
                    [4 * 9 + 1] = FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04, STOP, FLEXSPI_1PAD, 0x0),

                    // Erase Chip: (CE)
                    [4 * 11 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60, STOP, FLEXSPI_1PAD, 0x0),

    // Set Read Parameters: (Winbond - [6:4]: 6 Dummy Clocks 0b000; [1:0]: Wrap Length 0b01 (ignored in SPI mode) Sect 8.2.23)
            // Set Burst Length: (Macronix - 0x01 sets 16-byte wrap ??? (should be 0x02) (0x1x to disable wrap) Sect. 9-25)
                    [4 * 12 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xC0, WRITE_SDR, FLEXSPI_1PAD, 0x01),
                    [4 * 12 + 1] = FLEXSPI_LUT_SEQ(STOP, FLEXSPI_1PAD, 0x00, 0, 0, 0),
                },
        },
    .pageSize           = 256u,
    .sectorSize         = 4u * 1024u,
    .ipcmdSerialClkFreq = 0x1,
    .blockSize          = 64u * 1024u,
    .isUniformBlockSize = false,
};
#endif /* XIP_BOOT_HEADER_ENABLE */

 

My first concern is the LUT sequence [4 * 12 + 0].  The 0xCO instruction to the Flash is Winbond's "Set Read Parameters" (W25Q512NW Data Sheet Section 8.2.23) with the data value 0x01.  Is the intent to enable the Winbond's wrap?  It appears to be setting 6 dummy clocks and that's all.  The third paragraph is particularly confusing as it seems to say a different instruction (0x77) is needed to set the wrap length.

For the Macronix device (MX66L1G45G Data Sheet Section 9-25) the data value 0x01 will set a 16-byte wrap, which seems decidedly wrong as the cache lines are 32 bytes, right?

Next, I can't make any sense of this portion of the structure definition:

            /* Set configuration command sequences */
            .configCmdSeqs[0] =
                {
                    .seqNum   = 1,
                    .seqId    = 12,
                    .reserved = 0,
                },
            /* Macronix Configuration Register? (page 38): write the DC[1:0] bits, set "4 BYTE", default ODS[2:0] */
            .configCmdArgs[0] = (FLASH_DUMMY_VALUE << 6) | (0x1 << 5) | (0x7),

 Is the intent to write to the Macronix Configuration Register?  If so, I believe my values are correct for the Macronix but I can't be sure because I can't figure out if the original Winbond code accomplishes the same thing.

Thanks very much for all your help.

Dave

0 Kudos
Reply
3,305 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Littell ,

  No, not the just the FCB, please still refer to my previous reply, run the  flexspi_polling demo in the SDK from internal RAM, modify the LUT table related commander.

  As this method also can help you to check your hardware QSPI flash is OK or not, just when this demo is passed, then you can modify the app FCB for the booting.

  So, please try my first email method, if you still have issues about it, please kindly let me know.

Best Regards,

kerry 

0 Kudos
Reply
3,282 Views
Littell
Contributor III

Hi Kerry,

The MCU Boot Utility seems to be able to interact with the Macronix Flash, including Chip Erase as well as programming an app image via the All-In-One Action.  Here's a screenshot of the settings:

BootUtility_BootDeviceConfiguration.png

The MCU Boot Utility also appears to have written an FCB to the Flash at the correct offset:

BootUtility_FCB.png

So, shouldn't that FCB be usable by an app for its flexspi_nor_config.c content?  Or at least a good starting point for reverse-engineering the initialization settings and LUT contents?

(I'm sure you're wondering why I'm avoiding the flexspi_polling demo.  The short answer is I have no debugger connectivity at this point and I'm trying everything I can think of to make some progress until that's fixed.)

 

Thanks,

Dave

0 Kudos
Reply
3,261 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Littell 

Answer your questions:

So, shouldn't that FCB be usable by an app for its flexspi_nor_config.c content?  Or at least a good starting point for reverse-engineering the initialization settings and LUT contents?

=>Answer: Yes, you can use this working FCB in the mcubootutility to  your flexspi_nor_config.c content, it is OK. Just make sure your LUT is supported by your flash datasheet defined command.

 

Wish it helps you!

If you still have question about it, please kindly let me know.

If your question is solved, please help to mark the correct answer, just to close this case, thanks.

Any new issues, welcome to create the new case.

Best Regards,

kerry

0 Kudos
Reply
3,217 Views
Littell
Contributor III

Thanks very much for your help on this issue.  We learned quite a bit but are unfortunately out of time in trying to resolve this particular problem and have to revert to the EVKB's Winbond device.  Possibly we can revisit the Macronix at some point in the future but for now we must abandon that effort.

0 Kudos
Reply
3,130 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Littell ,

   Thanks for your updated information.

  Yes, you also can use the winbond QSPI if you don't want to do more modification. At least, our EVKB based on it, the debugger programmer, and the sample code are all based on it, it may save your time to do to the related modification.

   Anyway, if you meet any issues in the future, welcome to create the question post, and let us know.

Best Regards,

kerry

0 Kudos
Reply
3,329 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Littell ,

  Thank you for your interest in the NXP MIMXRT product, I would like to provide service for you.

  In fact, your mentioned macronix MX66L1G45G is just the QSPI flash:

https://www.macronix.com/Lists/Datasheet/Attachments/8734/MX66L1G45G,%203V,%201Gb,%20v1.5.pdf

 You totally can use this code:

https://mcuxpresso.nxp.com/en/builder?hw=MIMXRT1170-EVKB

  You can import the flexspi_polling code, you need to run the code from RAM at first, as you are not sure your QSPI flash is working.

  To the flexSPI_Polling code, you just need to care about 2points:

1. LUT commander

In your code, check the LUT related commander, eg, read, erase, qe enable, write, commander, need to match to your used flash datasheet commander table.

kerryzhou_1-1722839379058.png

kerryzhou_2-1722839512882.png

 

 

2. QE bit position

This will be used to enable the Quad mode.

kerryzhou_0-1722839295787.png

kerryzhou_3-1722839542916.png

 

the QE bit is 0X40.

BTW, you also can run the rom_api demo:

option is like this:

kerryzhou_5-1722839841661.png

kerryzhou_6-1722839860894.png

Just follow the option table, choose the correct configuration, the correct QE bit position.

 

 

Wish it helps you!

If you still have question about it, please kindly let me know!

If your question is solved, please help to mark the correct answer, just to close this case, thanks.

Any new issues, welcome to create the new question post.

Best Regards,

Kerry

 

 

 

0 Kudos
Reply