Page 1 of 1
ChibiOS restart
Posted: Tue Aug 19, 2014 1:35 pm
by plyatov
Hello everybody!
Please, advise how to correctly restart ChibiOS.
For safety reasons, my project (based on STM32L152RBT6) need to have posibility of device restart in case of some activated software flag.
Direct call of ResetHandler() does not help and leads to hangup.
Best wishes.
--
Igor
Re: ChibiOS restart
Posted: Tue Aug 19, 2014 1:51 pm
by Giovanni
Hi,
I think that the safest way is to trigger a software reset, it is the SYSRESETREQ bit of the Cortex-M3, see the ARM document.
Jumping to ResetHandler fails because the main stack is not reinitialized by doing that, it is done in HW on reset.
Giovanni
Re: ChibiOS restart
Posted: Wed Aug 20, 2014 10:36 am
by Jeroen3
Map chSysHalt() to your custom port_halt() defined in your fault handler file.
Depending on your debugger connection, printout the trace buffer, stackdump and reason for failure. (dbg_panic_msg)
Then possibly store what thread caused it to some backup memory to determine if you need a "safe" mode next time. ( currp )
System reset can be done using mentioned SYSRESETREQ, or hardware watchdog timer.
Just make sure not to use much stack or heap memory in the fault handlers since these may be depleted.
Re: ChibiOS restart
Posted: Fri Aug 22, 2014 11:12 am
by plyatov
Jeroen3 wrote:Map chSysHalt() to your custom port_halt() defined in your fault handler file.
Depending on your debugger connection, printout the trace buffer, stackdump and reason for failure. (dbg_panic_msg)
Then possibly store what thread caused it to some backup memory to determine if you need a "safe" mode next time. ( currp )
depleted.
I don't understand why you recommend this. I don't have unexpected "panic" situations to debug.
Reset of device by software is defined in ours Project Definition document. This is only one of many required features.
I already tried "SCB->AIRCR |= SCB_AIRCR_SYSRESETREQ;", but no any reaction on its execution. The MCU does not reset.
Any ideas?
Re: ChibiOS restart
Posted: Fri Aug 22, 2014 11:17 am
by Giovanni
Look if there are errors in definitions of those SCB macros/structure.
Giovanni
Re: ChibiOS restart
Posted: Fri Aug 22, 2014 11:32 am
by plyatov
Issue resolved by usage of special VECTKEY (0x05FA) in bits 31-16 of SCB->AIRCR register.
The "SCB->AIRCR = 0x05fa0000 | SCB_AIRCR_SYSRESETREQ;" does reset of MCU.
Thanks for information!