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
ChibiOS restart
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: ChibiOS restart
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
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
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.
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
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?
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: ChibiOS restart
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!
The "SCB->AIRCR = 0x05fa0000 | SCB_AIRCR_SYSRESETREQ;" does reset of MCU.
Thanks for information!