cancel
Showing results for 
Search instead for 
Did you mean: 

Manage STM32F205RG flash programming and other tasks at the same time.

Smit
Associate II

Hi,

I have an application where the device must respond to another device as a part of UART communication @ 1 sec. However, at the same time to log 200 bytes of data upon update of a variable, I need to log it into Flash at Sector 11 of STM32F205RGYX_FLASH MCU so reprogramming Flash takes 1-2 sec of blocking erase cycle as stated in the datasheet, and then by it missed to respond to messages from another device also observed timeout at another end.
_legacyfs_online_stmicro_images_0693W00000biwPPQAY.png​Can we have any mechanism that reduces the erase cycle time for Sector 11 or any optimized way out to manage communication and reprogramming flash simultaneously?

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

Welcome, @Community member​, to the community!

Well, what you are observing is a typical case of single bank flash limitation. In order to run a program and have data in the flash at the same time, you need either so-called dual bank flash or a routine that you execute from RAM.

Dual bank flash requires additional effort (separation of the flash into two blocks, second charge pump, etc), so it is not offered in the STM32F0 family for cost reasons. So you should either switch to a family and derivative that support dual bank flash (e.g. STM32L0, STM32G0), or copy your routine needed while writing the flash to RAM and execute it there.

Hope that helps?

Regards

/Peter

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

View solution in original post

7 REPLIES 7
Peter BENSCH
ST Employee

Welcome, @Community member​, to the community!

Well, what you are observing is a typical case of single bank flash limitation. In order to run a program and have data in the flash at the same time, you need either so-called dual bank flash or a routine that you execute from RAM.

Dual bank flash requires additional effort (separation of the flash into two blocks, second charge pump, etc), so it is not offered in the STM32F0 family for cost reasons. So you should either switch to a family and derivative that support dual bank flash (e.g. STM32L0, STM32G0), or copy your routine needed while writing the flash to RAM and execute it there.

Hope that helps?

Regards

/Peter

In order 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.
Danish1
Lead II

I'm not sure which stm32f0 you mean. Please could you give us more of the part number.

I had a quick check on a couple of them and they show mass erase times of 40 ms.

FLASH programming or erase times are a significant problem. The stm32 processor cannot read from FLASH at the same time as either erasing or writing it.

  • Some (larger) stm32 have "dual-bank" FLASH, where one can perform a read or write to one bank while executing code from the other.
  • If you have small urgent functions that must keep running during FLASH programming / erase, you can put them in RAM and execute from there. But you must ensure that all accesses are to/from RAM during this time - for example any interrupts and the vector table will also have to be in RAM.
  • Why must the 128k page be erased? Could you reorganise the memory so that smaller pages get erased instead? (Note: If this is for firmware update, most people accept that there is some loss of functionality during the update process).

Pardon mentioning part number here as STM32F205RGYX.

The same applies to STM32F2, except that other families can be considered as alternatives, e.g. STM32F4 or STM32H5.

In order 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.
Smit
Associate II

Hi @Peter BENSCH​ , Does it take only 40ms for mass erase? as mentioned by @Danish​ ? as likely mentioned in the datasheet it should be around 8 to 16 sec or more.

No. That was a (random) stm32f0xx that I looked at. (Apologies if you'd already said which stm32 you were using; I now see you mention stm32f205, although that could have been added by an edit).

Stm32f205 takes as long as you say.

But the workarounds still apply.

Smit
Associate II

Got it! thanks for the clarification sorry for any inconvenience!