QSPI_SRECBootloader/bootloader.c
int SpiFlashRead(XSpi *SpiPtr, u32 Addr, u32 ByteCount, u8 ReadCmd)
{
	int Status;

	/*
	 * Wait while the Flash is busy.
	 */
	Status = SpiFlashWaitForFlashReady();
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Prepare the WriteBuffer. Only for Quad Mode 4 Byte Addressing
	 */
	WriteBuffer[BYTE1] = ReadCmd;
#if FLASH_4BYTES_ADDRESSING
	WriteBuffer[BYTE2] = (u8) (Addr >> 24);
	WriteBuffer[BYTE3] = (u8) (Addr >> 16);
	WriteBuffer[BYTE4] = (u8) (Addr >> 8);
	WriteBuffer[BYTE5] = (u8) Addr;
#else
	WriteBuffer[BYTE2] = (u8) (Addr >> 16);
	WriteBuffer[BYTE3] = (u8) (Addr >> 8);
	WriteBuffer[BYTE4] = (u8) Addr;
#endif

	/*
	 * Initiate the Transfer.
	 */
	Status = XSpi_Transfer( SpiPtr, WriteBuffer, ReadBuffer,
				(ByteCount + READ_EXTRA_BYTES));
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}


//	u32 rfifo = Xil_In32(QSPI_BASEADDR + XSP_RFO_OFFSET);
//	u32 tfifo = Xil_In32(QSPI_BASEADDR + XSP_TFO_OFFSET);
//	u32 drr = Xil_In32(QSPI_BASEADDR + AXI_QSPI_SPIDRR);


	if(ErrorCount != 0) {
		ErrorCount = 0;
		return XST_FAILURE;
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function reads the data from the Winbond Serial Flash Memory
*
* @param	SpiPtr is a pointer to the instance of the Spi device.
* @param	Addr is the starting address in the Flash Memory from which the
*		data is to be read.
* @param	ByteCount is the number of bytes to be read.
*
* @return	XST_SUCCESS if successful else XST_FAILURE.
*
* @note		None
*
******************************************************************************/
This function reads the data from the Winbond Serial Flash Memory
This function reads the data from the Winbond Serial Flash Memory
int SpiFlashRead(XSpi *SpiPtr, u32 Addr, u32 ByteCount, u8 ReadCmd)
{
	int Status;
	Status = SpiFlashWaitForFlashReady();
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	WriteBuffer[BYTE1] = ReadCmd;
#if FLASH_4BYTES_ADDRESSING
	WriteBuffer[BYTE2] = (u8) (Addr >> 24);
	WriteBuffer[BYTE3] = (u8) (Addr >> 16);
	WriteBuffer[BYTE4] = (u8) (Addr >> 8);
	WriteBuffer[BYTE5] = (u8) Addr;
#else
	WriteBuffer[BYTE2] = (u8) (Addr >> 16);
	WriteBuffer[BYTE3] = (u8) (Addr >> 8);
	WriteBuffer[BYTE4] = (u8) Addr;
#endif
	Status = XSpi_Transfer( SpiPtr, WriteBuffer, ReadBuffer,
				(ByteCount + READ_EXTRA_BYTES));
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	if(ErrorCount != 0) {
		ErrorCount = 0;
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}
int SpiFlashRead ( XSpi * SpiPtr , u32 Addr , u32 ByteCount , u8 ReadCmd ) { int Status ; Status = SpiFlashWaitForFlashReady ( ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } WriteBuffer [ BYTE1 ] = ReadCmd ; #if FLASH_4BYTES_ADDRESSING WriteBuffer [ BYTE2 ] = ( u8 ) ( Addr >> 24 ) ; WriteBuffer [ BYTE3 ] = ( u8 ) ( Addr >> 16 ) ; WriteBuffer [ BYTE4 ] = ( u8 ) ( Addr >> 8 ) ; WriteBuffer [ BYTE5 ] = ( u8 ) Addr ; #else WriteBuffer [ BYTE2 ] = ( u8 ) ( Addr >> 16 ) ; WriteBuffer [ BYTE3 ] = ( u8 ) ( Addr >> 8 ) ; WriteBuffer [ BYTE4 ] = ( u8 ) Addr ; #endif Status = XSpi_Transfer ( SpiPtr , WriteBuffer , ReadBuffer , ( ByteCount + READ_EXTRA_BYTES ) ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } if ( ErrorCount != 0 ) { ErrorCount = 0 ; return XST_FAILURE ; } return XST_SUCCESS ; }
This function reads the data from the Winbond Serial Flash Memory
This function reads the data from the Winbond Serial Flash Memory
/*
	 * Wait while the Flash is busy.
	 */ /*
	 * Prepare the WriteBuffer. Only for Quad Mode 4 Byte Addressing
	 */ /*
	 * Initiate the Transfer.
	 */ //	u32 rfifo = Xil_In32(QSPI_BASEADDR + XSP_RFO_OFFSET);
 //	u32 tfifo = Xil_In32(QSPI_BASEADDR + XSP_TFO_OFFSET);
 //	u32 drr = Xil_In32(QSPI_BASEADDR + AXI_QSPI_SPIDRR);
