ChibiOS restart

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
plyatov
Posts: 25
Joined: Tue Feb 25, 2014 10:24 am
Been thanked: 2 times

ChibiOS restart

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ChibiOS restart

Post 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
Jeroen3
Posts: 35
Joined: Wed Apr 02, 2014 10:14 am

Re: ChibiOS restart

Post 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.
plyatov
Posts: 25
Joined: Tue Feb 25, 2014 10:24 am
Been thanked: 2 times

Re: ChibiOS restart

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ChibiOS restart

Post by Giovanni »

Look if there are errors in definitions of those SCB macros/structure.

Giovanni
plyatov
Posts: 25
Joined: Tue Feb 25, 2014 10:24 am
Been thanked: 2 times

Re: ChibiOS restart

Post 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!
Post Reply