System dies after several days - system tick problem?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: System dies after several days - system tick problem?

Post by Giovanni »

I will look into instrumenting that code some more.

Giovanni
User avatar
Erikk
Posts: 10
Joined: Wed Jan 22, 2014 1:26 pm
Been thanked: 1 time

Re: System dies after several days - system tick problem?

Post by Erikk »

Im also getting errors when working with Virtual Timers on a Stm32f4-discovery.
Im using the chibios 3.0 release inside the latest Chibistudio and compiling with -O2.


Setting timer Virtualtimer for the first time, inside a normal thread:

Code: Select all

  chSysLock();
  chVTDoSetI(&vt_can_broadcast, MS2ST(2000), can_vt_cb, NULL);
  chSysUnlock();



Callback:

Code: Select all

void can_vt_cb(void* arg){
  chSysLockFromISR();
  chBSemSignalI(&SemCanVt);
  chVTSetI(&vt_can_broadcast, MS2ST(2000), can_vt_cb, arg);
  chSysUnlockFromISR();
};




Always when running the chVTSetI inside the callback, it hangs with reason: 0x8002760 "stStartAlarm".

BUT, its works flawlessly when compiling with -O0 instead of -O2.

Any thoughts?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: System dies after several days - system tick problem?

Post by Giovanni »

Interesting, I have to verify that scenario (setting a timer from a timer callback).

Giovanni
User avatar
Erikk
Posts: 10
Joined: Wed Jan 22, 2014 1:26 pm
Been thanked: 1 time

Re: System dies after several days - system tick problem?

Post by Erikk »

After adding some more code to the program it hangs up even with -O0.

Only way to make it work is to make the thread sleep for a certain time instead of using a virtual timer to release a semaphore.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: System dies after several days - system tick problem?

Post by Giovanni »

Don't worry, that error is a very specific error condition, should be easy to implement a fix.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: System dies after several days - system tick problem?

Post by Giovanni »

Hi,

I committed a tentative fix for this issue, could you test it?

Giovanni
User avatar
Erikk
Posts: 10
Joined: Wed Jan 22, 2014 1:26 pm
Been thanked: 1 time

Re: System dies after several days - system tick problem?

Post by Erikk »

Works perfectly!
Thanks.
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: System dies after several days - system tick problem?

Post by steved »

Going backwards from my perspective, I'm afraid.

The code I started running on 14th March is still running - 10 days continuous operation (unless we had a power cut, which I would probably have noticed). This is using a delta of 2. It had some improvements over the code which originally triggered my post; these eliminated a couple of virtual timers (most of the time) and also increaased the minimum timeout to 2ms.

Since then I've made a small improvement in what I believe to be my longest ISR (character receive) although retriggering a virtual timer is probably the longest part of the execution time.

This evening I've run the latest Chibi repository contents and my latest code with deltas of 2, 3 and 4, and all fail. With delta=2 it took around an hour, while with larger deltas it was minutes or less.

I'll try and roll back my code to the version that's been running for a long time, in case I've unintentionally broken something. That'll be tomorrow evening.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: System dies after several days - system tick problem?

Post by Giovanni »

I think you should not seek solutions that minimize the problem, that would be hiding the real cause. If you could put together a small project that I could test it would be the best solution, try to maximize the effect instead.

Giovanni
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Re: System dies after several days - system tick problem?

Post by rew »

i.e. make sure that it works with delta=4 and THEN switch back to delta=2.
Post Reply