MX RT FlexSPI get vendor id always returns 0

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

MX RT FlexSPI get vendor id always returns 0

1,503 Views
csutyaksancsoft
Contributor II

Hello All,

I am attempting to use the FlexSPI driver to drive a NAND-Flash Chip (winbond W25n01GVxx1G) using the polling_transfer SDK example on a custom XRT116x board. The starting point to talking to a SPI Flash device is to read the ID and go from there. However, No matter what, the ID I read from the chip is always 0.

However, what is weird, is when I hooked a scope to each pin they are doing exactly what should be done based on this diagram from the NAND Chip:

csutyaksancsoft_1-1693493703521.png

In other words, the DI pin and DO pin are correctly sending the expected data where DI is sending the command 9F and the DO pin is sending the ID. 

Some extra configuration info

The chip is connected as the image below where:

  • NAND_SCLK is connected to GPIO_EMC_B2_10:FLEXSPI2_A_SCLK
  • NAND_SS0 is connected to GPIO_EMC_B2_11:FLEXSPI2_A_SS0B
  • NAND_DATA0 is connected to GPIO_EMC_B2_13:FLEXSPI2_A_DATA0
  • NAND_DATA1 is connected to GPIO_EMC_B2_14:FLEXSPI2_A_DATA1
  • NAND_DATA2 is connected to GPIO_EMC_B2_15:FLEXSPI2_A_DATA2
  • NAND_DATA3 is connected to GPIO_EMC_B2_16:FLEXSPI2_A_DATA3

csutyaksancsoft_0-1693493114629.png

 

The things I changed from the original example

(app.h) changed all defs to use FLEXSPI2

#define EXAMPLE_FLEXSPI FLEXSPI2
#define FLASH_SIZE 0x20000 /* 128Mb/KByte */
#define EXAMPLE_FLEXSPI_AMBA_BASE FlexSPI2_AMBA_BASE
#define FLASH_PAGE_SIZE 256
#define EXAMPLE_SECTOR 20
#define SECTOR_SIZE 0x200 /* 4K */
#define EXAMPLE_FLEXSPI_CLOCK kCLOCK_Flexspi2
#define FLASH_PORT kFLEXSPI_PortA2

(flexspi_nor_flash_ops.c : flex_spi_nor_get_vendor_id) changed size to 4 and used an array for data

uint8_t temp[10] = {0,0,0,0,0,0,0,0,0,0};
flexspi_transfer_t flashXfer;
flashXfer.deviceAddress = 0;
flashXfer.port = FLASH_PORT;
flashXfer.cmdType = kFLEXSPI_Read;
flashXfer.SeqNumber = 1;
flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_READID;
flashXfer.data = (uint32_t*)temp;
flashXfer.dataSize = 4;

status_t status = FLEXSPI_TransferBlocking(base, &flashXfer);

//NOTE: temp is always full of 0s after transferBlocking. 

*vendorId = temp[0];

(flexspi_nor_polling_transfer.c: main) I manually pulled down the CS pin using

GPIO_PinInit(GPIO8, 21, &GPIO_config);

GPIO_PinWrite(GPIO8, 21, 0);

(flexspi_nor_polling_transfer.c: CustomLUT) changed 0x4 -> 0x18
/* Read ID */
[4 * NOR_CMD_LUT_SEQ_IDX_READID] =
FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x9F, kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x18),

 

I believe this is a config issue that I am not experienced enough to understand yet. I don't know if the port is configured correctly based on my HW configuration. I imagine I am doing something wrong because I had to manually pull down the CS Pin. 

 

Thanks,

Cole 

0 Kudos
Reply
6 Replies

1,407 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @csutyaksancsoft,

Could you please take a look to the Hardware Development Guide for the MIMXRT1160/1170 Processor

Also, it might be useful to check the i.MX RT1170 Processor Reference Manual. Section 10.6.3.3 Serial NAND configuration block (512 bytes)., which includes an example of Serial NAND configuration block for Winbond W25N01GVZEIG; and Table 10-1. ROM Bootloader Peripheral PinMux., for FLEXSPI NAND Flash set up and a Note to Serial NAND Flash Boot over FlexSPI.

Best regards, Raul.

1,403 Views
csutyaksancsoft
Contributor II

Hey Raul,

Thanks for the reply! I have been struggling to fix this problem for a long time.

I am not trying to boot over flash, I am simply trying to store NV-Data onto the chip.
Also after reading, where is flexspi_nand_config_t located? There are no SDK examples that include that struct. Also are there any examples, tutorials, or manuals that explain how to use flexspi_nand_config_t to configure flexspi? 

Thanks,

Cole

0 Kudos
Reply

1,300 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @csutyaksancsoft,

Could you please try the following suggestions?

  • First, change #define EXAMPLE_FLEXSPI_RX_SAMPLE_CLOCK to kFLEXSPI_ReadSampleClkLoopbackInternally in app.h
  • Second, try use the flashXfer and temp just as the example in flexspi_nor_flash_ops.c

Also, could you tell us why are you changing CustomLUT from 0x4 to 0x18, and SECTOR_SIZE to 0x200?

Also are there any examples, tutorials, or manuals that explain how to use flexspi_nand_config_t to configure flexspi? 

Unfortunately, there are not any examples about how to use flexspi_nand_config_t.

Best regards, Raul.

1,210 Views
csutyaksancsoft
Contributor II

Hey Raul,

I have tried both of those suggestions to start with, however, I tried them again just now to make sure. They didn't fix the issue. I am fairly confident that the problem is within the the initialization of the flexspi and not when calling the flexspi_nor_get_vendor_id. The reason I believe  this is because when I step through the code in the FLEXSPI_TransferBlocking when I get within the FLEXSPI_ReadBlocking the data in base->RFDR is wrong, it repeats the same byte to fill up whatever size I set it to. 

Also, could you tell us why are you changing CustomLUT from 0x4 to 0x18, and SECTOR_SIZE to 0x200?

I changed CustomLUT from 0x4 to 0x18 to reflect the amount of bytes I am expecting to get. I read on a couple blogs that the 6th param of FLEXSPI_LUT_SEQ is the size that you expect from the 4th param. In other words, I expected 3 bytes or 24 bits from kFLEXSPI_Command_READ_SDR so I set it to 0x18. 

I changed SECTOR_SIZE to 0x200 to reflect the sector size of my flash chip based on the specifications. 

Its also worth noting that I have tried all of the default configs in the example. Meaning everything I have changed, I started by trying the default values. 

Thanks,

Cole

 

0 Kudos
Reply

1,133 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @csutyaksancsoft,

Could you please check the following points about the FlexSPI Initialization?

  • In flexspi_nor_flash_init(EXAMPLE_FLEXSPI) look for flexspi_clock_init(). Could you please check it out has the kCLOCK_Root_Flexspi2 instead of kCLOCK_Root_Flexspi1?
  • Double check your LUT configuration. In the following community post it is mentioned how a customer solved a similar issue by making some changes to the LUT: FlexSpi NOR and NAND Flash Configuration - NXP Community. Double check the flexspi_device_config_t deviceconfig, and the customLUT for your NAND Flash.
  • Finally, you could double check the initialization of FlexSPI in flexspi_nor_flash_init() and i.MX RT1160 Processor Reference Manual. Section 30.5. Initialization.

Best regards, Raul.

0 Kudos
Reply

1,462 Views
csutyaksancsoft
Contributor II

Update: So I have 3 custom boards. 2 always returns 0 and 1 always returns 08, and when I expand the datasize, the 08 populate every byte. 

 

0 Kudos
Reply