Skip to main content
DBark.2
Associate II
April 6, 2021
Question

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

  • April 6, 2021
  • 4 replies
  • 1833 views

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!

This topic has been closed for replies.

4 replies

ST Technical Moderator
April 6, 2021

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

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
DBark.2
DBark.2Author
Associate II
April 21, 2021

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

ST Technical Moderator
May 28, 2021

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

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
QLiu.6
Associate II
October 11, 2022

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