cancel
Showing results for 
Search instead for 
Did you mean: 

(BUG FOUND + SOLUTION) OctoSpi configuration fails when sending only Data without instruction, address, or alternate byte, or dummy-cycle in regular-command protocol

DBark.2
Associate III

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!

4 REPLIES 4
Imen.D
ST Employee

Hello @DB.7arke​ ,

Thanks for sharing this issue with solution.

I will check this and I will come back to you soon with update.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
DBark.2
Associate III

Thanks @Imen DAHMEN​, I hope it can get patched!

Imen.D
ST Employee

Hi @DB.7arke​ ,

Sorry for the delayed reply on this, but some periods of the year are more busy than others.

I confirm that your temporary solution is working fine.

I escalated internally your feedback with the solution to our development team, and they are working to resolve this accordingly to the priority.

Thanks

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
QLiu.6
Associate II

I'm working on H723, and want to send out data session only. The bug is still there.

In OSPI_ConfigCmd(...)

Run into

    /* ---- Invalid command configuration (no instruction, no address) ---- */

   status = HAL_ERROR;

   hospi->ErrorCode = HAL_OSPI_ERROR_INVALID_PARAM;

STM32CubeIDE

Version: 1.10.1

Build: 12716_20220707_0928 (UTC)

STM32CubeH7 Firmware Package V1.10.0 / 11-February-2022