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, utzig, tfAteba, barthess

shilow
Posts: 10
Joined: Mon Dec 16, 2013 9:04 am
Location: Ukraine
Contact:

how to handle operating system exceptions?

Postby shilow » Thu Dec 29, 2022 7:59 pm

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: 14462
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1078 times
Been thanked: 922 times
Contact:

Re: how to handle operating system exceptions?

Postby Giovanni » Thu Dec 29, 2022 8:06 pm

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
Location: Ukraine
Contact:

Re: how to handle operating system exceptions?

Postby shilow » Thu Dec 29, 2022 8:47 pm

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: 14462
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1078 times
Been thanked: 922 times
Contact:

Re: how to handle operating system exceptions?  Topic is solved

Postby Giovanni » Thu Dec 29, 2022 8:59 pm

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
Location: Ukraine
Contact:

Re: how to handle operating system exceptions?

Postby shilow » Thu Dec 29, 2022 9:17 pm

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: 14462
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1078 times
Been thanked: 922 times
Contact:

Re: how to handle operating system exceptions?

Postby Giovanni » Fri Dec 30, 2022 7:40 am

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


Return to “General Support”

Who is online

Users browsing this forum: Google [Bot] and 4 guests