mohamed AFASSI
mohamed AFASSI

Reputation: 41

How to Read Data from a specific address of the FPGA QSPI Flash board?

I'm new to Vitis and XilinX-edk world.

I'm working on a project and i want to implement a design that uses microblaze to do these 3 tasks :

1-Read some data from a specific QSPI Flash address.

2-Save into the BRAM.

3-Wait for 1 in a GPIO Input then print the BRAM data to the UART.

I just have a question for the first task, so firstly I saved the bitstream file and a hex file containing some data into the QSPI using Vivado. My Hex file is saved to the address 0x01E00000.

My question now is; how can I read back my file from the QSPI Flash? I found this function to Write/Read into and from QSPI but there is no way to set the address to read from:

status = XSpi_Transfer(&QSPI, qspi_write_buffer, qspi_read_buffer, (unsigned int)bytes_to_read);
if (status == XST_FAILURE) 
{
   xil_printf("QSPI read failed!\r\n");
   break;
}

Upvotes: 1

Views: 899

Answers (2)

mohamed AFASSI
mohamed AFASSI

Reputation: 41

Thank you Justin N for you response, It really helped.
So I read the datasheet of my ISSI S25FL256S and indeed I found all the commands that this type of flash uses, I will explain my approach so it may help someone lost and passes by this thread.
Firstly in the datasheet I found in the 76 page explanation on how to read FhashId, so I tested it with this function that i Wrote :

int FlashReadID(void)
{
//Modified code by AFASSI Mohamed
int Status;
int i;

WriteBuffer[BYTE1] = 0x90;
WriteBuffer[BYTE2] = 0x00;      /* 3 dummy bytes (wait for 24ck_rising edges)*/
WriteBuffer[BYTE3] = 0x00;
WriteBuffer[BYTE4] = 0x00;
WriteBuffer[BYTE5] = 0xff;      /* 2 dummy reading bytes */
WriteBuffer[BYTE6] = 0xff;

Status = XSpi_Transfer(&Spi, WriteBuffer, ReadBuffer, 6);
if (Status != XST_SUCCESS) {
    return XST_FAILURE;
}

FlashID[0] = ReadBuffer[4]; //save iD into the FlashID buffer
FlashID[1] = ReadBuffer[5];

xil_printf("FlashID=0x%x 0x%x\n\r", FlashID[0], FlashID[1]);

//FOR S25FL256S
if(ReadBuffer[BYTE5]==0x01&&ReadBuffer[BYTE6]==0x18){
    xil_printf("ISSI S25FL256S Flash detected\n\r");
    return XST_SUCCESS;
}
else return XST_INVALID_VERSION;
}

And surely I received the FlashID in the Output.

Upvotes: 1

Justin N
Justin N

Reputation: 911

XSpi_Transfer is a raw SPI function and doesn't implement the protocol for your flash chip. The chip has a read command that you need to send first, and that will include the address. The bytes that make up that command will go in qspi_write_buffer.

Upvotes: 0

Related Questions