cancel
Showing results for 
Search instead for 
Did you mean: 

Program Stalled in OSPI_WaitFlagStateUntilTimeout During Execution

Ayoub_Bnina
Associate III

Hello everyone,

I'm facing a perplexing issue with my program getting stuck after a successful upload. The upload process completes without errors (screen remains lit white), but upon running the program, it hangs at  MX_OCTOSPI1_Init() and the screen remains black.

Ayoub_Bnina_1-1716210098978.png

 

Symptoms:

  • Program hangs indefinitely in the OSPI_WaitFlagStateUntilTimeout function.
  • This occurs during initial program execution, before TouchGFX & FreeRTOS starts.
  • The upload itself is successful (white screen persists).
Ayoub_Bnina_0-1716209996270.png

 

Background:

This problem recently emerged, and the program was functioning correctly beforehand. I've even tried creating new projects from TouchGFX Designer, but the issue persists.

Request for Assistance:

I believe the culprit might be the MX25LM51245G_AutoPollingMemReady function, which verifies if the NOR Flash memory (MX25LM51245G) is ready for new commands. However, I'm seeking your help to pinpoint the exact cause.

Additional Information:

  • I'd appreciate it if you could provide insights into what might be causing this issue and how to resolve it.
  • Are there any debugging techniques or resources specifically suited for the OSPI_WaitFlagStateUntilTimeout function that you could recommend?

OCTOSPI Configuration:
I have followed this schematic to configure my OCTOSPI Pins https://www.st.com/content/ccc/resource/technical/layouts_and_diagrams/schematic_pack/group1/e0/e5/29/92/9d/37/47/91/MB1332-H7B3I-B02_Schematic/files/MB1332-H7B3I-B02_Schematic.PDF/jcr:content/translations/en.MB1332-H7B3I-B02_Schematic.PDF 

 

Ayoub_Bnina_2-1716210270141.png

Development Environment:

  • STM32CubeIDE 1.15.1 ( First Encountred in 1.14.1)
  • STM32CubeMX 6.11.1

Thank you in advance for your assistance!

7 REPLIES 7

Make sure to clear out auto/local structures in functions so they don't contain random junk.

Don't have infinite time-outs, other than erase most things should complete in 100's of milliseconds.

Make sure the SystemTick is functioning and counting off time.

Check what state it's waiting for here, and what state it's seeing. Instrument so you can see what's happening in real-time and don't have to fish state out of registers, stack and structures.

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

Hello @Ayoub_Bnina ,

Are you able to run OSPI_NOR_MemoryMapped_DTR example? Please take a look at this example may help you.

Could you please check the OCTOSPI configuration, for that please refer to AN5050  table 8 STM32CubeMX - Configuration of OCTOSPI parameters and precisely Octal-SPI Flash Macronix MX25LM51245GXDI00 column and/or to OSPI_NOR_MemoryMapped_DTR example.  

Could you please try to enable delay hold quarter cycle.

 

OSPIHandle.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_ENABLE;

 

 

Thank you.

Kaouthar

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.

Hi @KDJEM.1, I have been Following the OCTOSPI (Macronix) pins Configuration corresponding to my STM32H7B3I-DK board and it mentions octospi1 instance on the pins label MB1332 (st.com), While in the AN5050 (st.com) you provided, it mentions that the Macronix is situated on the octospi2 instance. which one should I follow ?

Your board is using OCTOSPIM PORT1, use *THAT*

https://github.com/STMicroelectronics/stm32h7b3i-dk-bsp/blob/fbc7d98d3d93327d3a1d45f0c4850b393bf2241d/stm32h7b3i_discovery_ospi.h#L135

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

@KDJEM.1 @Tesla DeLorean  This my OCTOSPI Configuration 

Ayoub_Bnina_0-1716237687458.png


Ayoub_Bnina_1-1716237767914.png

Now I am encountring an old problem situated in Texts.cpp, The program unable to find typedTextDatabaseArray[id]

Ayoub_Bnina_2-1716237905346.png

I am pretty sure my configuration is right, if not please help me understand the problem. Thank you!

 

 

Pins look correct.

The External Loader typically Memory Maps the device, and does a HAL_OSPI_DeInit() prior to HAL_OSPI_Init() to break it out of that mode of operation, and typically sends a RESET to the memory IC to ensure both sides start from a known operational mode from the outset.

The ordering of your MX_XYZ_Init() functions may also be critical.

Build some of the DK's examples the don't use CubeMX to auto-generate, nor use the RTOS.

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

Hi @Ayoub_Bnina ,

To clarify my last comment, the same reference memory MX25LM51245GXDI00 is connected to OCTPOSPI1 instance in STM32H7B3-DK board and to OCTOSPI2 instance in STM32L4P5G-DK board. So, you can refer to AN5050 or to OSPI_NOR_MemoryMapped_DTR and check the memory configuration "devise size, Delay hold quarter cycle, Chip select boundary...."

--> Now I am encountring an old problem situated in Texts.cpp, The program unable to find typedTextDatabaseArray[id]

May this MOOC can help you TouchGFX Webinar - 3 - Project customization (youtube.com)

Thank you.

Kaouthar

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.