cancel
Showing results for 
Search instead for 
Did you mean: 

Reset using syscfg->aircr fails when run from RAM

frackers
Senior

Running an stm32f407...

I have some flash programming bootstrap code that runs in RAM and on completion the device is reset by writing 0x05FA0004 to the syscfg->aircr register. When run from flash this works fine but running it from RAM it ends up at location 0x0 but there is no flash there for it to execute.

Sitting in a while (1) loop and waiting for a watchdog timeout works fine but that adds a huge delay as the watchdog by default is set up at maximum timeout (25 seconds) and of course it can't be changed once set.

Works great on a stm32f303 and a stm32f301 MCUs!!

3 REPLIES 3

Remap the 0x00000000 area to FLASH (in SYSCFG_MEMRMP.MEM_MODE) either before or after reset.

The former implies to run the portion of code which switches and resets from RAM at 0x20000000

The latter implies to write the value of SP and PC at the first addresses in RAM, and a portion of the startup code which would perform the switch positioned so, that its continuation is in FLASH.

I would go for the former.

JW

frackers
Senior

Thanks for the response...

I'm wondering if it's a debugger issue as looking at address 0x0 with Eclipse & Openocd in the memory browser, it looks like Flash memory to me but the debugger can't execute it (unable to set breakpoint). I also checked the value of SYSCFG_MEMRMP.MEM_MODE (address 0x40013800) which is correct (0b000) to map in Flash @ 0x0.

Here is my reset code - basically a copy from the F4 HAL, it's just that it is running from RAM.

// magic numbers!!
#define AIRCR_RESET_REQ     0x05FA0004
 
   __DSB();                                                          /* Ensure all outstanding memory accesses included                                                                        buffered write are completed before reset */
   SCB->AIRCR = (uint32_t) AIRCR_RESET_REQ;
 
   __DSB();                                                          /* Ensure completion of memory access */
 
   for(;;)                                                           /* wait until reset */
   {
      __NOP();
   }

Using instruction step to move through this and the memory browser continues to see valid data at 0x0 but the MCU/debugger seems unable to do a fetch!

Is the F4 that much different to the F3s where the code works?

I'm not sure about the debugger functionality across reset. Try perhaps other forms of instrumentation (wiggling pins).

JW