Fails how?
Try using the BSP code, and without interrupts.
Make sure the chip isn't in 4-bit address mode.
Make sure the sCommand structure is clean.
MT25TL01G_BlockErase(&hqspi, QSPI_Ctx[Instance].InterfaceMode, BlockAddress, BlockSize)
STM32Cube_FW_H7_V1.7.0\Drivers\BSP\STM32H747I-DISCO\stm32h747i_discovery_qspi.c
STM32Cube_FW_H7_V1.7.0\Drivers\BSP\Components\mt25tl01g\mt25tl01g.c
/**
* @brief Erases the specified block of the QSPI memory.
* MT25TL01G support 4K, 32K, 64K size block erase commands.
* SPI/QPI; 1-1-0/4-4-0
* @param Ctx Component object pointer
* @param Mode Interface mode
* @param BlockAddress Block address to erase
* @retval QSPI memory status
*/
int32_t MT25TL01G_BlockErase(QSPI_HandleTypeDef *Ctx, MT25TL01G_Interface_t Mode ,uint32_t BlockAddress, MT25TL01G_Erase_t BlockSize)
{
QSPI_CommandTypeDef s_command;
switch(BlockSize)
{
default :
case MT25TL01G_ERASE_4K :
s_command.Instruction = MT25TL01G_SUBSECTOR_ERASE_4_BYTE_ADDR_CMD_4K;
break;
case MT25TL01G_ERASE_32K :
s_command.Instruction = MT25TL01G_SUBSECTOR_ERASE_CMD_32K;
break;
case MT25TL01G_ERASE_64K :
s_command.Instruction = MT25TL01G_SECTOR_ERASE_4_BYTE_ADDR_CMD;
break;
case MT25TL01G_ERASE_CHIP :
return MT25TL01G_ChipErase(Ctx, Mode);
}
/* Initialize the erase command */
s_command.InstructionMode = (Mode == MT25TL01G_QPI_MODE) ? QSPI_INSTRUCTION_4_LINES : QSPI_INSTRUCTION_1_LINE;
s_command.AddressMode = QSPI_ADDRESS_4_LINES;
s_command.AddressSize = QSPI_ADDRESS_32_BITS;
s_command.Address = BlockAddress;
s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
s_command.DataMode = QSPI_DATA_NONE;
s_command.DummyCycles = 0;
s_command.DdrMode = QSPI_DDR_MODE_DISABLE;
s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
/* Send the command */
MT25TL01G_WriteEnable(Ctx,Mode);
if (HAL_QSPI_Command(Ctx, &s_command, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return MT25TL01G_ERROR_COMMAND;
}
MT25TL01G_AutoPollingMemReady(Ctx,Mode);
return MT25TL01G_OK;
}