cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with flash in stm32wb55

IlliaGx
Associate III

Hello.
I found a problem with Flash. After successfully operating with flash before entering MX_APPE_Process(), the possibility of entering standby mode disappears. I had issues with the visibility of variable values after these operations, but I could say it was successful. I used standard functions to work with Flash. Something similar to what is in the examples for STM32WB.

Then I found this thread https://community.st.com/t5/stm32-mcus-wireless/stmwb55-flash-write-access-during-ble-connection/td-p/268121/page/3 where @Remi QUINTIN advised to use the Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\BLE\BLE_RfWithFlash project, where I found a nice flash driver file.

I thought this should help to extinguish all conflicts in the sequencer and allow it to go into standby mode after using flash.

Below, I attach a project that has a demo of working with Flash and an algorithm for getting into standby, which was provided to me by the esteemed @FilipKremen.

I did not repeat all the functionality of the original application, but I took some elements from there. In particular, I put SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7); in APP_BLE_Init.


If you run the FD_Wrapper_InitConfig(); function from the wrapper file in the part of initialization before the while(1) loop or from the rtc timer callback (in order not to enable tasks when the sequencer is not running yet), the task hangs somewhere here in the debugger:
line 308 if ((local_evtset & EvtWaited)== 0U) of function void UTIL_SEQ_Run( UTIL_SEQ_bm_t Mask_bm ). And it does not go further in the code.

If you run flash initialization before MX_APPE_Process(); without a debugger, the code goes further and lets you press the buttons, lighting up the LEDs. Only if you try to enter standby when pressing the SW1 button, it will go into a fault. If you start the flash init in the RTC callback, then nothing will happen, and the code will not reach the test run of the LED.

As far as I can see, it is the flash driver functions that are causing issues.

I would be extremely grateful for your help

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FilipKremen
ST Employee

Hello,

as you mentioned, it's necessary to add definition of FD_WaitForSemAvailable() function as it is in the RFWithFlash example. Otherwise, it's up to the user to repeat the flash processing.

Also, please read a note in app_conf.h file (above #define CFG_USE_SEQ_TO_WAIT_FOR_SEM) where it is described. I hope this can help you with the project.

 

Best regards,

Filip Kremen

 

View solution in original post

10 REPLIES 10
IlliaGx
Associate III

If I run the write task through the sequencer, everything proceeds without errors; however, I still can't write the correct data to the flash.

IlliaGx
Associate III

I think I was able to localize the problem. I made a slightly new version of the project. The config is successfully written if I go through the flash write part in the debugger. However, if I just flash the board and look at the result in real time, a write error occurs. I attach the project below
Regards

FilipKremen
ST Employee

Hello,

could you please send any screenshots that would describe the issue more in detail?

Also, if you could send the steps that should be followed to reproduce the issue.

Thank you.

Best regards,

Filip Kremen

Hello. Thanks for the reply.
I set a breakpoint on the Config_LoadOrInit function, and when the program execution reaches it, I go through it step by step in the debugger. I go inside Config_WriteEntryToFlash and the functions that are there. Let me know if you need anything else.

FilipKremen
ST Employee

Hello,

could you please describe it more in detail? I don't understand what I should set in the project, so I cannot reproduce it on my side.

I also don't see the definition of FD_Wrapper_InitConfig() function. Would it be possible to prepare a step-by-step scenario for reproducing the issue?

Thank you.

Best regards,

Filip Kremen

 

I apologize for confusing you. FD_Wrapper_InitConfig(); should remain commented out. The idea is that I start the RTC timer for 5 seconds to wait for the sequencer to start (I can't start tasks if the sequencer isn't already running in the while loop, can I?). Then, after 5 seconds, I start the task UTIL_SEQ_SetTask(1 << CFG_TASK_FLASH_OPERATION_REQ_ID, CFG_SCH_PRIO_0); in the RTC timer callback. It starts the Config_LoadOrInit(void) function. This function then has conditions that trigger 1, 2, or 3 LEDs. The first LED means VALID CONFIG FOUND, the second that the erase or write failed, and the third that the write succeeded. I try running this again and get different results sometimes. For example, just now I failed to erase the flash in the debug. I think I may have found the problem and enabled CFG_USE_SEQ_TO_WAIT_FOR_SEM == 1 as in that example-source. But I don't know if this is correct, and maybe it should work without it.

FilipKremen
ST Employee

Hello,

as you mentioned, it's necessary to add definition of FD_WaitForSemAvailable() function as it is in the RFWithFlash example. Otherwise, it's up to the user to repeat the flash processing.

Also, please read a note in app_conf.h file (above #define CFG_USE_SEQ_TO_WAIT_FOR_SEM) where it is described. I hope this can help you with the project.

 

Best regards,

Filip Kremen

 

Thank you very much!

I would also like to make a small clarification: can I call simple UTIL_SEQ_SetTask without timers or anything similar in the part of the code before the while(1) loop, where I have the sequencer running? Or should I wait until MX_APPE_Process(); and use a timer to start some tasks?

Regards

FilipKremen
ST Employee

Hello,

yes, it can be done this way.

Please visit our Wiki page about Sequencer. (section 3.3)

Utility:Sequencer - stm32mcu

Best regards,

Filip Kremen