how to handle operating system exceptions? Topic is solved

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

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
shilow
Posts: 10
Joined: Mon Dec 16, 2013 9:04 am

how to handle operating system exceptions?

Post by shilow »

Hi.

what i mean:
- I use i2cMasterTransmitTimeout() - if communication with the device is lost, the system "freezes" (https://git.heaven.pp.ua/Heaven/Accum-T ... /INA3221.c, line 83),
- if there is not enough stack size for the thread - the system "freezes",
- trying to send an event - for some reason the system "freezes" (https://git.heaven.pp.ua/Heaven/Accum-T ... src/main.c, line 172).

how to find and correct the causes of such behavior?

thank you.

P.S.: forgot to add - if you set the optimization level to 3 (-O3), then sending the event works.

when my code works or doesn't work depending on the compiler or its settings - it's very annoying and disturbs my sleep.
Last edited by shilow on Thu Dec 29, 2022 8:31 pm, edited 1 time in total.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: how to handle operating system exceptions?

Post by Giovanni »

Hi,

Try this article: http://www.chibios.org/dokuwiki/doku.ph ... ebug_guide

Is it helpful?

Giovanni
shilow
Posts: 10
Joined: Mon Dec 16, 2013 9:04 am

Re: how to handle operating system exceptions?

Post by shilow »

Giovanni wrote:Hi,
Try this article: http://www.chibios.org/dokuwiki/doku.ph ... ebug_guide


Do I understand correctly that it is possible to determine the cause of SysHalt only using the hardware debugger?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: how to handle operating system exceptions?

Post by Giovanni »

Correct, you need to examine the string pointed by the chSysHalt() parameter. It is possible to "hook" the function and print the string somewhere but the debugger is usually the easiest and safest way (after a crash your "print" function could fail as well).

giovanni
shilow
Posts: 10
Joined: Mon Dec 16, 2013 9:04 am

Re: how to handle operating system exceptions?

Post by shilow »

Giovanni wrote:Correct, you need to examine the string pointed by the chSysHalt() parameter. It is possible to "hook" the function and print the string somewhere but the debugger is usually the easiest and safest way (after a crash your "print" function could fail as well).


how to force chSysHalt() to output the string to the serial port? any example?
I will be very grateful.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: how to handle operating system exceptions?

Post by Giovanni »

I don't have an example, usually using the debugger is the easier thing to do.

You may try to start a serial driver beforehand then create a "write" function in polled mode, this way it can be used with interrupts disabled.

Giovanni
Post Reply