2018-09-17 04:54 AM
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.
Solved! Go to Solution.
2018-09-17 06:23 AM
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
2018-09-17 05:26 AM
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.
2018-09-17 05:41 AM
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.
2018-09-17 06:23 AM
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
2018-09-17 06:38 AM
Thanks a lot, The SCB_DisableDCache did the trick.
Found the following documentation as well which described the cache on the target.