lib/sw_apps/img_rcvry/src/xbir_sd.c
int Xbir_SdErase(u64 Length)
{
	int Status = XST_FAILURE;
	u64 NumBlocks = Length / XBIR_SDPS_BLOCK_SIZE;
	u64 BlockIndex;
	u8 WrBuffer[XBIR_SDPS_WRITE_CHUNK_SIZE] = {0U};

	for (BlockIndex = 0UL; BlockIndex < NumBlocks;
		BlockIndex += XBIR_SD_RAW_NUM_SECTORS) {
		Status = XSdPs_WritePolled(&SdInstance, BlockIndex,
			XBIR_SD_RAW_NUM_SECTORS, WrBuffer);
		if (Status != XST_SUCCESS) {
			Xbir_Printf("%0x..\n\r", BlockIndex);
			Status = XBIR_ERROR_SD_ERASE;
			goto END;
		}
	}
	if ((Length % XBIR_SDPS_BLOCK_SIZE) != 0L) {
		Status = XSdPs_WritePolled(&SdInstance, BlockIndex, 1U,
			WrBuffer);
		if (Status != XST_SUCCESS) {
			Status = XBIR_ERROR_SD_ERASE;
		}
	}

END:
	return Status;
}
/*****************************************************************************/
/**
 * @brief
 * This function erases given sectors in SD card from the start.
 *
 * @param	Length  Number of bytes to erase
 *
 * @return	XST_SUCCESS on successful write
 * 		Error code on failure
 *
 ******************************************************************************/
@brief
This function erases given sectors in SD card from the start.

@param       Length  Number of bytes to erase

@return      XST_SUCCESS on successful write
Error code on failure
@brief This function erases given sectors in SD card from the start . @param Length Number of bytes to erase @return XST_SUCCESS on successful write Error code on failure
int Xbir_SdErase(u64 Length)
{
	int Status = XST_FAILURE;
	u64 NumBlocks = Length / XBIR_SDPS_BLOCK_SIZE;
	u64 BlockIndex;
	u8 WrBuffer[XBIR_SDPS_WRITE_CHUNK_SIZE] = {0U};
	for (BlockIndex = 0UL; BlockIndex < NumBlocks;
		BlockIndex += XBIR_SD_RAW_NUM_SECTORS) {
		Status = XSdPs_WritePolled(&SdInstance, BlockIndex,
			XBIR_SD_RAW_NUM_SECTORS, WrBuffer);
		if (Status != XST_SUCCESS) {
			Xbir_Printf("%0x..\n\r", BlockIndex);
			Status = XBIR_ERROR_SD_ERASE;
			goto END;
		}
	}
	if ((Length % XBIR_SDPS_BLOCK_SIZE) != 0L) {
		Status = XSdPs_WritePolled(&SdInstance, BlockIndex, 1U,
			WrBuffer);
		if (Status != XST_SUCCESS) {
			Status = XBIR_ERROR_SD_ERASE;
		}
	}
END:
	return Status;
}
int Xbir_SdErase ( u64 Length ) { int Status = XST_FAILURE ; u64 NumBlocks = Length / XBIR_SDPS_BLOCK_SIZE ; u64 BlockIndex ; u8 WrBuffer [ XBIR_SDPS_WRITE_CHUNK_SIZE ] = { 0U } ; for ( BlockIndex = 0UL ; BlockIndex < NumBlocks ; BlockIndex += XBIR_SD_RAW_NUM_SECTORS ) { Status = XSdPs_WritePolled ( & SdInstance , BlockIndex , XBIR_SD_RAW_NUM_SECTORS , WrBuffer ) ; if ( Status != XST_SUCCESS ) { Xbir_Printf ( " \n \r " , BlockIndex ) ; Status = XBIR_ERROR_SD_ERASE ; goto END ; } } if ( ( Length % XBIR_SDPS_BLOCK_SIZE ) != 0L ) { Status = XSdPs_WritePolled ( & SdInstance , BlockIndex , 1U , WrBuffer ) ; if ( Status != XST_SUCCESS ) { Status = XBIR_ERROR_SD_ERASE ; } } END : return Status ; }
@brief
 This function erases given sectors in SD card from the start.
@brief This function erases given sectors in SD card from the start .