Skip to main content
Graduate II
April 5, 2024
Question

what is HAL_OSPI_AutoPolling() ? how to fix it ?

  • April 5, 2024
  • 4 replies
  • 5878 views

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.

    This topic has been closed for replies.

    4 replies

    Technical Moderator
    April 5, 2024

    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 

    MNapiAuthor
    Graduate II
    April 5, 2024

    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

     

     

    Graduate II
    April 5, 2024

    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..

     

     

    MNapiAuthor
    Graduate II
    April 5, 2024

    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.

     

    Graduate II
    April 5, 2024

    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

    Super User
    April 6, 2024

    > I get  FlashID = 0xC2

    Likely you get also a memory corruption, because the FlashID arg to MX25LM51245G_ReadID is a pointer to array of 3 bytes at least. So two bytes after your FlashID variable were overwritten. This can cause undefined behavior.

     

    MNapiAuthor
    Graduate II
    April 6, 2024

    I changed to 3 byte array (previously uint8_t FlashID; )

    uint8_t FlashID[3];

    MX25LM51245G_ReadID(&hospi1, MX25LM51245G_SPI_MODE, MX25LM51245G_STR_TRANSFER, FlashID)

    now I get

    FlashID[0] = 0xC3

    FlashID[1]= 0x85

    FlashID[2]=0x3A

     

    so, do you think that the memory is working ?

     

     

    Graduate II
    April 6, 2024

    What is your pin configuration? The same as the DISCO board?

    What are you trying to build? The .STLDR? A loader that runs in application space?

    The ReadID is consistent with the data-sheet

    https://www.mxic.com.tw/Lists/Datasheet/Attachments/8729/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf

    Super User
    April 7, 2024

    > I found information that:"Auto-polling mode not functional with new octal memories"

    >any idea how to work around it or fix ?

    Poll "manually"?

     

    Graduate II
    April 7, 2024

    Yes, covered earlier.

    The forum makes it very hard to navigate longer threads, hiding / masking content