Page 2 of 2

Re: Soft reset

Posted: Sat Sep 06, 2014 4:02 pm
by rambo
@MarkusS

I end up in _unhandled_exception for some reason:

Code: Select all

(gdb) break ResetHandler
Breakpoint 1 at 0x8001580: file ChibiOS/os/ports/GCC/ARMCMx/crt0.c, line 282.
(gdb) cont
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, ResetHandler () at ChibiOS/os/ports/GCC/ARMCMx/crt0.c:282
282     uint32_t *magic_word =  (uint32_t *)(SYMVAL(__ram_end__) - 4); // look at the last word in ram
(gdb) step
283     if (*magic_word == 0xDEADBEEF) {
(gdb) step
373   }
(gdb) step
284         *magic_word = 0; // reset magic flag
(gdb) step
285         ((funcp_t) (*(uint32_t *)0x1FFF0004U))(); // jump into boot loader
(gdb) step
284         *magic_word = 0; // reset magic flag
(gdb) step
285         ((funcp_t) (*(uint32_t *)0x1FFF0004U))(); // jump into boot loader
(gdb) step
^C
Program received signal SIGINT, Interrupt.
_unhandled_exception () at ChibiOS/os/ports/GCC/ARMCMx/STM32F4xx/vectors.c:226
226   void _unhandled_exception(void) {
(gdb) bt
#0  _unhandled_exception ()
    at ChibiOS/os/ports/GCC/ARMCMx/STM32F4xx/vectors.c:226
#1  <signal handler called>
#2  0x00000000 in ?? ()
#3  0x1fff3d2a in ?? ()
#4  0x1fff3d2a in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

Re: Soft reset

Posted: Tue Mar 03, 2015 11:57 pm
by ych
MarkusS,

Thank you for your code examples, it helps :).

In the end I improve your example by moving changes which you made in os/ports/GCC/ARMCMx/crt0.c to board.c in __early_init function

Code: Select all

void __early_init(void) {
  if (MAGIC_DATA_CHECK()) {
    MAGIC_DATA_CLEAN();
    __set_CONTROL(0);
    __set_MSP((*(uint32_t *)0x1FFF0000U)); // this constant taken from "Device-dependent bootloader parameters" section of AN2606
    ((void (*)(void)) (*(uint32_t *)0x1FFF0004U))();
  } else {
    stm32_clock_init();
  }
}

and yes I init stack pointer (as described int video tutorial), because I have issue without it.

Re: Soft reset

Posted: Thu Mar 26, 2015 8:45 pm
by Korken
Did anyone get it working without using the magic during startup?
I've been trying to jump too the bootloader as well (after all deinit of ChibiOS and clocks), but the chip (STM32F405) just resets instead...
Also I've been searching the AN2606 why it resets, but I cannot find an explanation.

Re: Soft reset

Posted: Tue Jul 05, 2016 6:58 am
by alex31
Hello,

I occasionally use NVIC_SystemReset and it works for all my projects ... but one.

I have a project where NVIC_SystemReset, and even chibios watchdog don't do anything, the MCU (stm32F4, chibios 16.1.5) continue
to run after an explicit reset request or watchog counter reaching end.

Any idea before i begin the game of difference between the projects where it works and this one who think he is chuck norris ?

Alexandre

Re: Soft reset

Posted: Tue Jul 05, 2016 7:10 am
by Giovanni
I cannot imagine a way to make a reset-resistant application even if I wish to do so...

Giovanni

Re: Soft reset

Posted: Tue Jul 05, 2016 8:20 am
by alex31
got it.

I was running on debugger (black magic probe, master branch) , and for an unknown reason, the bmp maintain NRST pin at high level,
and this cancel software reset.

Alexandre

Re: Soft reset

Posted: Mon Jan 01, 2018 4:54 pm
by aGuegu
For STM32F103, coretx M-3 based chip,

Code: Select all

void softreset(void) {
  *(uint32_t *)(0xE000ED0CUL) = 0x05FA0000UL | (*(uint32_t *)(0xE000ED0CUL) & 0x0700) | 0x04;
}


It is mainly the NVIC_SystemReset in core_cm3.h in stdperiph lib. Other cores have this function too.

According to RM0008, this software reset works same as the external NRST pin reset.

Re: Soft reset

Posted: Thu Jun 10, 2021 1:08 am
by sabdulqadir
Giovanni wrote:Hi,

It depends :-)

There is procedure to shutdown entirely the OS, it is described in this article: http://www.chibios.org/dokuwiki/doku.ph ... os:stop_os

If you have threads performing critical operations like writes in EEPROM or Flash then you may want to safely stop the threads then perform the reset.

Giovanni

Can you update the link?

Thanks,
AQ