(BUG FOUND + SOLUTION) OctoSpi configuration fails when sending only Data without instruction, address, or alternate byte, or dummy-cycle in regular-command protocol
According to the OctoSpi Documentation, only one of the five phases needs to be active in order to configure OctoSpi.
"20.4.3 OCTOSPI Regular-command protocol
When in Regular-command protocol, the OCTOSPI communicates with the external device using commands. Each command can include the following phases:
• Instruction phase
• Address phase
• Alternate-byte phase
• Dummy-cycle phase
• Data phase
Any of these phases can be configured to be skipped, but at least one of the instruction, address, alternate byte, or data phases must be present." (dm00346336, 632)
However, when attempting to configure using only data (see below) the configuration will fail.
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_NONE;
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
sCommand.NbData = YOUR_CUSTOM_SIZE_HERE;
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
sCommand.DummyCycles = 0;
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
if (HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) !=
HAL_OK)
{
ret = FPGA_WRITE_F;
}The solution is the insert the following code snippet in the OSPI_ConfigCmd function in the stm32l5xx_hal_ospi.c file on line 2785, replacing the old error check after each regeneration.
if (cmd->DataMode != HAL_OSPI_DATA_NONE)
{
// ---- Command with data ----
// Configure the CCR register with all communication parameters
MODIFY_REG((*ccr_reg), (OCTOSPI_CCR_DMODE | OCTOSPI_CCR_DDTR),
(cmd->DataMode | cmd->DataDtrMode));
}
else
{
// ---- Invalid command configuration (no instruction, no address) ----
status = HAL_ERROR;
hospi->ErrorCode = HAL_OSPI_ERROR_INVALID_PARAM;
}Hopefully this is helpful!
