如何从FPGA QSPI Flash板的特定地址读取数据?

huangapple go评论57阅读模式
英文:

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

问题

I'm new to Vitis and Xilinx EDK world.

我是Vitis和Xilinx EDK世界的新手。

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

我正在进行一个项目,我想实现一个设计,使用MicroBlaze执行以下3个任务:

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

1- 从特定的QSPI Flash地址读取一些数据。

2- Save into the BRAM.

2- 保存到BRAM中。

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

3- 等待GPIO输入中的1,然后将BRAM数据打印到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.

我只对第一个任务有一个问题,首先我使用Vivado将比特流文件和包含一些数据的十六进制文件保存到了QSPI中。我的十六进制文件保存到地址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:

我的问题是,现在我如何从QSPI Flash中读回我的文件?我找到了这个用于写入/读取QSPI的函数,但没有设置要读取的地址的方法:

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;
}
英文:

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;
}

答案1

得分: 1

谢谢 Justin N 的回应,它真的帮了我很多。所以我阅读了我的 ISSI S25FL256S 的数据手册,确实找到了这种闪存使用的所有命令。我会解释我的方法,希望能帮助一些迷失方向的人,并经过这个帖子。

首先,在 数据手册 的第76页,我找到了如何读取 FhashId 的解释,所以我用这个我编写的函数进行了测试:

int FlashReadID(void)
{
	//AFASSI Mohamed 修改的代码
	int Status;
	int i;

	WriteBuffer[BYTE1] = 0x90;
	WriteBuffer[BYTE2] = 0x00;		/* 3 个虚拟字节(等待 24ck 上升沿) */
	WriteBuffer[BYTE3] = 0x00;
	WriteBuffer[BYTE4] = 0x00;
	WriteBuffer[BYTE5] = 0xff;		/* 2 个虚拟读取字节 */
	WriteBuffer[BYTE6] = 0xff;

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

	FlashID[0] = ReadBuffer[4]; //将 ID 保存到 FlashID 缓冲区中
    FlashID[1] = ReadBuffer[5];

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

	//对于 S25FL256S
	if(ReadBuffer[BYTE5]==0x01&&ReadBuffer[BYTE6]==0x18){
		xil_printf("检测到 ISSI S25FL256S 闪存\n\r");
		return XST_SUCCESS;
	}
	else return XST_INVALID_VERSION;
}

当然,我在输出中收到了 FlashID。

英文:

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.

答案2

得分: 0

XSpi_Transfer 是一个原始的 SPI 函数,不实现你的闪存芯片的协议。芯片有一个需要首先发送的读取命令,其中包括地址。构成该命令的字节将放在 qspi_write_buffer 中。

英文:

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.

huangapple
  • 本文由 发表于 2023年5月25日 21:41:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76332958.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定