cancel
Showing results for 
Search instead for 
Did you mean: 

RAM not getting written before reset on stm32f769n

Daniel Moberg
Associate II

I am working on a hard fault handler were I want to store some key values into ram before resetting. This data will then be further handled at next boot up.

My problem is that the data does not get written into RAM unless I step through the writing code with a debugger. I am using the NVIC_SystemReset for resetting which comes with the STM sdk and looks like below.

**
  \brief   System Reset
  \details Initiates a system reset request to reset the MCU.
 */
__STATIC_INLINE void NVIC_SystemReset(void)
{
  __DSB();                                                          /* Ensure all outstanding memory accesses included
                                                                       buffered write are completed before reset */
  SCB->AIRCR  = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
                 SCB_AIRCR_SYSRESETREQ_Msk);
  __DSB();                                                          /* Ensure completion of memory access */
 
  for(;;)                                                           /* wait until reset */
  {
    __NOP();
  }
}

According to the documentation the __DSB() macro should take care of ensuring that any pending memory writes are completed.

Since the data gets written when stepping through with the debugger I am ruling out optimizations issues.

The compiler used is gcc-arm-none-eabi-7-2017-q4-major and my target is the stm32f769ni.

1 ACCEPTED SOLUTION

Accepted Solutions

SCB_DisableDCache();

*((unsigned long *)0x2004FFF0) = 0xDEADBEEF; // 320KB STM32F7xx

__DSB();

NVIC_SystemReset();

Updated posts at the end here might also be of interest

https://community.st.com/s/question/0D50X00009XkXKUSA3/jump-to-internal-bootloader-with-stm32f7

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

View solution in original post

4 REPLIES 4
AvaTar
Lead

Didn't work with the F7 extensively, but perhaps you should turn off the data caches before writing.

And check you exempt said memory region/addresses from startup initialization.

David Littell
Senior III

The cache needs to be flushed, not just turned off. Definitely check that the RAM area you're using isn't touched by the bootloader.

SCB_DisableDCache();

*((unsigned long *)0x2004FFF0) = 0xDEADBEEF; // 320KB STM32F7xx

__DSB();

NVIC_SystemReset();

Updated posts at the end here might also be of interest

https://community.st.com/s/question/0D50X00009XkXKUSA3/jump-to-internal-bootloader-with-stm32f7

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

Thanks a lot, The SCB_DisableDCache did the trick.

Found the following documentation as well which described the cache on the target.

https://www.st.com/content/ccc/resource/technical/document/application_note/group0/08/dd/25/9c/4d/83/43/12/DM00272913/files/DM00272913.pdf/jcr:content/translations/en.DM00272913.pdf