cancel
Showing results for 
Search instead for 
Did you mean: 

what is HAL_OSPI_AutoPolling() ? how to fix it ?

MNapi
Senior III

After trying the sample code from STM32Cube_FW_L4_V1.18.0

for octo spi

I getting stuck on

HAL_OSPI_AutoPolling(hospi, &sConfig, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);

it is not working, after reading posts and

STM32L4Rxxx and STM32L4Sxxx device errata

I found information that:

"Auto-polling mode not functional with new octal memories"

any idea how to work around it or fix ?

the sample code does not work, I cannot test OSPI.

28 REPLIES 28
STTwo-32
ST Employee

Hello @MNapi 

As you can see on the errata 2.8.2 of the ES0393, "Automatic status-polling mode with octal memories is not functional.". So, as a workaround, you have to Use memory-mapped access to poll the status registers.

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

It is basically the repetitive reading of the same register, with a bit mask, and match method, so you can say spin on the STATUS REGISTER (1) waiting for WIP (WRITE IN PROGRESS) to clear.

ie if ((DATA & MASK) == MATCH) then DONE

Depending on the platform you need to ABORT the QSPI/OSPI on a timeout, otherwise it keeps going indefinitely.

I'd not bother with Memory-Mapped mode to overcome this, but rather just go back to a simple read method and doing the check manually. ie Read the Status Register, check the Busy / Ready / Write-In-Progress bits, as necessary.

You want the part to come ready, and use that to pace operations, as if you keep ploughing on forward, ignoring the device, it's apt to ignore subsequent commands and fail..

 

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi

would you be able to share some code how to do it. I already looked at the memory mapped mode

but I am not quite there to make it working.

I see that there is HAL function.

HAL_OSPI_MemoryMapped(OSPI_HandleTypeDef *hospi, OSPI_MemoryMappedTypeDef *cfg);

I see a lot of samples, they have the same HAL drivers but none is working.

I just downloaded a few days ago

STM32Cube_FW_L4_V1.18.0

and I would assume that STM fixed the old bug long time ago. But it is still there. Bunch of examples and nothing is working.

I am trying it on STM32H7A3IIT6Q and I have the same FLASH MX25LM51245GMI00 like on the Discovey board

 

 

Hi

I am not quite sure what you mean by simple reading this one, read the register ?

HAL_OSPI_Receive(OSPI_HandleTypeDef *hospi, uint8_t *pData, uint32_t Timeout);

I am not quite sure how to ready it if it is still writing data over the same 8 lines.

 

Uphill both ways...

It's an entirely different command transaction.

Here's a manual implementation of waiting on the STATUS REGISTER on the OCTOSPI chip, see it reading the register, via the normal command methods, and waiting for the matching condition.

https://github.com/STMicroelectronics/stm32l4p5g-dk-bsp/blob/4e0bcd00f0d37a23bd929290b538bf2352b6963a/stm32l4p5g_discovery_ospi_nor.c#L1052

And here an unpacked OSPI_NOR_AutoPollingMemReady() method in lieu of HAL_OSPI_AutoPolling()

https://github.com/STMicroelectronics/stm32l4p5g-dk-bsp/blob/4e0bcd00f0d37a23bd929290b538bf2352b6963a/stm32l4p5g_discovery_ospi_nor.c#L1085

You can use READ STATUS REGISTER command whilst the flash array is busy completing a Erase/Write, but the chip won't accept other READ MEMORY, or WRITE PAGE type commands whilst busy. Other non-memory array commands may also work, you'd need to read the chip documentation to understand the limits and expectations.

Top post tagged as STM32H7 not STM32L4

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

>>I am not quite sure what you mean by simple reading this one, read the register ?

Normally as part of the command structure passed to HAL_OSPI_AutoPolling(), or the command immediately proceeding, depending on STM32 family and HAL library version, you specify a READ FLAG STATUS, or READ STATUS REGISTER (MICRON's have two registers reporting slightly differently, and for multi-die, etc)

The normal peripheral level method is to keep resending the command, and/or clocking the repetitive output from the memory IC until the status mask/match occur. The idea being that it's much more efficient, and would allow for interrupts, and for the MCU to go off and do more productive work rather than burn cycles in a software polling loop.

See how the QSPI method sets up the command portion and then calls  HAL_QSPI_AutoPolling(&QSPIHandle, &sCommand, &sConfig, Timeout)

https://github.com/STMicroelectronics/stm32l476g-eval-bsp/blob/31280bc4a9d038f9981b8fe4c2824582efc163fe/stm32l476g_eval_qspi.c#L735

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

unfortunately there is more, after replacing this part another error pops up

 

/* Enable write operations ------------------------------------------- */
OSPI_WriteEnable(&OSPIHandle);

/* Erasing Sequence -------------------------------------------------- */
sCommand.Instruction = OCTAL_SECTOR_ERASE_CMD;
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
sCommand.Address = address;
sCommand.DataMode = HAL_OSPI_DATA_NONE;
sCommand.DummyCycles = 0;

if (HAL_OSPI_Command(&OSPIHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
Error_Handler();
}

 

this time it cannot write command.

I see a lot of examples from STM and nothing works and I using the same FLASH used on the Discovery boards.

>>unfortunately there is more, after replacing this part another error pops up

A compiler error, or a functional one?

Are you sure the hardware design is viable? What's the pin configuration?

STM32H7A3IIT6Q
MX25LM51245GMI00
PB2:AF9 CLK
PB6:AF10 NCS
PA1:AF11 DQS
PF8:PF10 D0
PF9:PF10 D1
PF7:PF10 D2
PF6:PF10 D3
PD4:AF10 D4
PC2:AF11 D5
PC3:AF11 D6
PD7:AF10 D7

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I already checked all pins. The reason I chose MX25LM51245GMI00 because it is the same used on Discovery boards. I can compile, no errors, I can upload and debug.

I read all the application notes they have it connected to OCTOSPI2. I have connected to OCTOSPI1. I do not think it is the reason, both ports are the same.

The other thing I see is

OSPI_RegularCmdTypeDef sCommand;

which has 20 variables.

so when I do

HAL_OSPI_Command(&OSPIHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);

I do not what know happens, it tries to transfer 20 variables ?

for example:

/* Erasing Sequence -------------------------------------------------- */
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
sCommand.Instruction = OCTAL_SECTOR_ERASE_CMD;
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
sCommand.Address = address;
sCommand.DataMode = HAL_OSPI_DATA_NONE;
sCommand.DummyCycles = 0;

if (HAL_OSPI_Command(&OSPIHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)

according to data sheet you send only 2 bytes as command not 20 or 6.

I am looking the the new links you provided to start from scratch again. Maybe something is not defined properly or missing..